llvm

How to create a ConstantInt in LLVM?

感情迁移 提交于 2020-01-22 09:48:21
问题 I'm not sure how to create a ConstantInt in LLVM- I know the number I would like to create, but I'm unsure how I can make a ConstantInt representing that number; I can't seem to find the constructor I need in the documentation. I'm thinking it has to be along the lines of ConstantInt consVal = new ConstantInt(something here). I know I want it to be an int type, and I know my value... I just want to create a number! 回答1: Most things in LLVM are created through a static method call instead of

developing an llvm pass with cmake out of llvm source directory

社会主义新天地 提交于 2020-01-21 02:27:35
问题 I am trying to develop an llvm pass under my project directory. For that, I follow the info in http://llvm.org/docs/CMake.html#developing-llvm-pass-out-of-source. I create my CMakeFiles appropriately as in this link and my final project directory is like; |-- src | |-- CMakeLists.txt | |-- bigForPass | | |-- CMakeLists.txt | | |-- bigForPass.cpp | | |-- merged.bc | |-- build I also linked my source files with llvm root directory without any problem. Finally I make the build under the 'build'

developing an llvm pass with cmake out of llvm source directory

﹥>﹥吖頭↗ 提交于 2020-01-21 02:27:05
问题 I am trying to develop an llvm pass under my project directory. For that, I follow the info in http://llvm.org/docs/CMake.html#developing-llvm-pass-out-of-source. I create my CMakeFiles appropriately as in this link and my final project directory is like; |-- src | |-- CMakeLists.txt | |-- bigForPass | | |-- CMakeLists.txt | | |-- bigForPass.cpp | | |-- merged.bc | |-- build I also linked my source files with llvm root directory without any problem. Finally I make the build under the 'build'

Call llvm-config --prefix and use it in a BUILD rule

懵懂的女人 提交于 2020-01-20 05:29:44
问题 I have a following rule in WORKSPACE : new_local_repository( name = "llvm", path = "/opt/local/libexec/llvm-4.0", build_file= "llvm.BUILD") I would like to now use hardcoded path for llvm. llvm-config --prefix can give me the directory for llvm. What is the correct way to get this? Can I just use standard python commands (e.g. subprocess package)? 回答1: As @abergmeier said, you can create a custom repository rule, run the command, create a symlink pointing to its output, and create a BUILD

Call llvm-config --prefix and use it in a BUILD rule

大憨熊 提交于 2020-01-20 05:29:04
问题 I have a following rule in WORKSPACE : new_local_repository( name = "llvm", path = "/opt/local/libexec/llvm-4.0", build_file= "llvm.BUILD") I would like to now use hardcoded path for llvm. llvm-config --prefix can give me the directory for llvm. What is the correct way to get this? Can I just use standard python commands (e.g. subprocess package)? 回答1: As @abergmeier said, you can create a custom repository rule, run the command, create a symlink pointing to its output, and create a BUILD

LLVM IR: How to call a function in another .ll file

我是研究僧i 提交于 2020-01-17 06:09:26
问题 I am writing LLVM IR code, can I call a function in another .ll file? For example: In a.ll file, there is a function foo(); Can I use this function in b.ll, like just call foo? If so, how can I include a.ll Thanks 回答1: You need to add declaration of function foo in the ll file in which you are calling it, then as usual convert link ll files to generate executable llvm-link a.ll b.ll -o a.out example a.ll declare i32 @foo(i32) define i32 @main() { start: %0 = call i32 @foo(i32 0) ret i32 %0 }

LLVM - What does '!NodePtr->isKnownSentinel(), function operator*' means?

霸气de小男生 提交于 2020-01-17 06:02:28
问题 When I execute following IR: declare void @_puts(i32, ...) define void @main() { entry: %name = alloca i32 br i1 true, label %then, label %else then: ; preds = %entry call void (i32, ...) @_puts(i32 1, i32 1234) br label %end else: ; preds = %entry br label %end end: ; preds = %else, %then %if_val = phi i32 [ 1234, %then ], [ 0, %else ] entry1: ; No predecessors! store i32 %if_val, i32* %name %name2 = load i32, i32* %name call void (i32, ...) @_puts(i32 1, i32 %name2) ret void } I got

iOS project compilation

左心房为你撑大大i 提交于 2020-01-17 05:45:47
问题 I am working on a project accessing web service. I found a project http://d1xzuxjlafny7l.cloudfront.net/downloads/PromoTest.zip The above code include JSON library [project setting compiler = LLVM 4.2] And I tried to use partial code of that project in my project. So I copied the JSON library into my project [my project uses Apple LLVM 3.1] and then some error show up eg. SBJsonStreamWriterState **states; //error:Pointer to non-const type "SBJsonStreamWriterState *" with no explicit ownership

Unify output with different clang-format versions

蹲街弑〆低调 提交于 2020-01-16 00:43:23
问题 We've tried to beautify our code a bit with clang-format tool. In order to get unified result on all machines we've done clang-format --style=llvm --dump-config , which has been tuned a bit and stored into repo. The issue is that clang 10 and 9 seem to provide us with different output for exactly the same code. I've seen changes in comments alignment only so far, but it still breaks the whole idea of getting code style consistent. Another issue is that clang 9 is unable to parse some settings

LLVM how to set Attributes::NoUnwind to Function?

梦想的初衷 提交于 2020-01-15 10:14:12
问题 I think this is very simple question, but I can't resolve it. Very sad. So. When I do llc.exe -march=cpp test.bc I get interesting test.cpp with this piece of code: AttrListPtr func__Z2f1i_PAL; { SmallVector<AttributeWithIndex, 4> Attrs; AttributeWithIndex PAWI; PAWI.Index = 4294967295U; PAWI.Attrs = Attribute::None | Attribute::NoUnwind; Attrs.push_back(PAWI); func__Z2f1i_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end()); } But when I want to write string like PAWI.Attrs = Attribute::None |