Questions tagged [llvm]

1

votes
2

answer
551

Views

llvm - get label of br instruction

My question is simple. Given an instruction of type branch, how do I extract the label out of it? For example: br label %while.cond Should give me while.cond br label %while.end Should give me while.end br i1 %cmp1, label %if.then, label %if.end Should give me if, if.then, if.end respectively.
Eren555
1

votes
1

answer
412

Views

Trying to cross compile Python I'm getting an unrecognised emulation mode

I've been working on a GitHub project that cross compiles Python for Android https://github.com/GRRedWings/python3-android/tree/clang Google is deprecating gcc in the NDK soon, so I have been trying to switch from using gcc, to clang. I stumbled across this project a couple of years back and have...
GR Envoy
1

votes
1

answer
46

Views

Cast from uint8_t* to StringRef

I'm using ExecutionEngine.cpp. I want to get StringRef from found addresses by the following code: const APInt &IntVal; uint8_t *y2 = reinterpret_cast(const_cast(IntVal.getRawData())); int v2 = *reinterpret_cast(y2); StringRef* Src1V=cast(y2); I got this error: home/rasha/llvm/llvm/include/llvm/Sup...
R.Omar
1

votes
1

answer
55

Views

Does OpenMP hints bypass the vectorisation legality check in llvm

I am currently looking into how '#pragma omp for simd' is actually recognised in llvm. To my knowledge, clang will parse it and set metadata in IR to indicate this force-vectorisation hint and later optimisation passes would read it and vectorise the marked loop. Therefore, the loop should be vector...
PST
1

votes
1

answer
422

Views

How do I uninstall `libllvm3.8 (1:3.8-2ubuntu4)` and install `libllvm3.8 (= 1:3.8-2ubuntu1)`?

I'm trying to install UnrealEngine4 by following the instructions here: https://github.com/Microsoft/AirSim/blob/master/docs/build_linux.md. When I run ./Setup.sh in the UnrealEngine4 repository, I get the following error: The following packages have unmet dependencies: clang-3.8 : Depends: libclang...
Carson Tang
1

votes
0

answer
152

Views

LLVM IRBuilder::CreateGlobalStringPtr Segmentation Fault

I'm facing an issue where IRBuilder::CreateGlobalStringPtr causes a segmentation fault on Ubuntu Trusty using the development branch of LLVM. I do not get a segfault on my mac book or when using older LLVM Versions (4, 5, or 6). I created a little Gist that reproduces the issue. I also tried to anal...
Micha Reiser
1

votes
0

answer
60

Views

Exploring c++ forward declarations of nested types and a standards compliance teaser?

I recently, thanks to awesome Jan 9th 2018 planet clang team work and others great articles, figured out how to configure my dev-setup to integrate llvm 7.0, visual studio 2017 15.5.6 for 32-bit and 64-bit Intel architecture. My motivation for this was forced by Microsoft's 15.4.X breaking std lib...
smallscript
1

votes
1

answer
117

Views

How to get Instruction in MachineInstr?

I wanted to know variable dependence in a real register (like X86:EAX, EBX ...). So, I have created an IR-PASS that can identify dependencies on the IR. This pass uses the newly added variables unsigned HasDependency: 1; and unsigned HasMaybeDependency: 1; in the Value class. . . // Use the same typ...
RollRat
1

votes
1

answer
113

Views

LLVM physical register mapping

I have some function in LLVM IR, which has some input arguments. However, I want to keep an argument passed in a register, and I want to compile it only for x86. For instance, I am writing a function containing adding instruction: %sum = add i64 %val1, %val2 and no matter which args are in the list,...
ultrablox
1

votes
2

answer
261

Views

LLVM - How to Construct llvm::Value from a std::string

std::string myIR = '%3 = alloca i32, align 4'; How would I convert a C++ std::string (such as the one above) to a llvm::Value? I can put an llvm::Instruction into a std:string like this SO answer shows, but I am unsure on how to go from a std::string to an llvm::Instruction or a llvm::Value.
Chris Smyth
1

votes
1

answer
188

Views

Get rid of LLVM's Unconditional Branch

Consider this IR: label0: ret i32 0 br label %1 How do I get rid of the unconditional branch instruction? I have type casted it to BranchInst class and used removeFromParent() or eraseFromParent() but I'm getting this error. BranchInst *BI = dyn_cast(i); if(BI->isUnconditional()) BI->removeFromP...
Sourav Das
1

votes
0

answer
62

Views

How does llvm allocate and get element in union?

I have the following C code and the IR for function caller(). Can anyone explain why it allocates [2 x %struct.C] for karg1? Or more generally, how LLVM optimize a union? And I'm confused with the GEP instructions of %karg1.sub. int cmd = 1; struct T { int tuner; char name[32]; unsigned long rangel...
Crystal
1

votes
0

answer
383

Views

Parsing LLVM IR from bitcode file

I am trying to parse LLVM IR from a bit code file. I went through the following steps. hello.cpp #include int main() { std::cout
budchan chao
1

votes
0

answer
140

Views

How to build recent Clang RPMs for Red Hat 7?

I need to provide recent versions of Clang (5, 6 or 7 for test) to developers teams working on RH7.x boxes (today they are using the EPEL release 3.4.2) I would like to build same packages as the EPEL ones: (And the ability to change the RPM release if I need to rebuild them) clang-devel-6.0.0-1.el...
Destroyica
1

votes
0

answer
57

Views

Find clang::Type in Clang AST by name

In Clang AST, is it possible to find type by name? For example I have qualified name : nspace::my_type. How can I check if type is present in current translation unit?
random
1

votes
0

answer
109

Views

How to generate a call graph of a function with LLVM

The current -dot-callgraph pass will generate a call graph for the entire module, but I only want to generate a call graph of a function, which means the starting point is the specified function, and it contains all the functions that could be called from this function, directly and indirectly.
gkso
1

votes
0

answer
178

Views

How can I call exported functions (dynamically in LLVM IR)?

I want to call the exported functions (functions from the shared libs - .dll, .so, end so on). From what I’ve seen so far, it’s seemed, as I can’t, because IR have no stack (is it true, about the stack?). With the C++, I can write something like this (for x86): // args - an array of a tagged u...
zk-t
1

votes
1

answer
148

Views

How to build the Rust compiler to use a custom fork of LLVM?

AMD released an optimized version of the LLVM toolchain named AOCC. Rust uses LLVM as the native code generator. Is it possible to use this LLVM instead of the fork from the Rust team?
CNAmira
1

votes
1

answer
163

Views

Instruction ID or number in LLVM IR

In Execution.cpp, I can get all instructions and the values of all variables. Is there any method to get the ID or the number of each instruction.
R.Omar
1

votes
0

answer
63

Views

Easiest way to evaluate constant SVal

I'm trying to find the easiest way to get the value in a constant SVal. Currently I am doing something along the lines of: SVal s = ...; // Get valid SVal from somewhere int64_t val = 0; // Will hold value of SVal if (!s.isUnknownOrUndef() && s.isConstant()) { switch (s.getBaseKind()) { case NonLocK...
1

votes
0

answer
101

Views

can clang static analyzer create .plist files in custom directory?

By default Clang-static-analyzer creates .plist files in current directory (from where the static analyzer is run). Is there any way to make it generate .plist files in a custom directory?
Hemant
1

votes
1

answer
102

Views

Figure out function signatures of precompiled functions during JIT in LLVM

I am currently working on implementing a JIT compiler using LLVM. The problem I have is that a portion of the compiler runtime is implemented in C. From my intermediate representation, I can generate all native functions. However, certain operations in the language require calls to these external...
JKRT
1

votes
1

answer
96

Views

Hashtables in llvm using ocaml

I'm working on a toy programming language/compiler using ocaml and its llvm bindings. I want to have hashtables/hashmaps as a built in data structure for my language however I'm confused as to how to go about them. I know the llvm c++ api has an ADT directory with a bunch of data structures that wo...
wow
1

votes
0

answer
87

Views

LLVM fails to optimize simple function

I'm using LLVM C++ API to generate a very simple function. Here's the IR output: target datalayout = 'e-m:e-i64:64-f80:128-n8:16:32:64-S128' define i64 @'foo'(i64) { %2 = alloca i64 store i64 %0, i64* %2 %3 = load i64, i64* %2 ret i64 %3 } I expect LLVM to get rid of the superfluous stores/loads whe...
llvm newbie
1

votes
0

answer
81

Views

Clang diagnostics and clang-check differs in warning count

For the following snippet #include enum index{ one = 5, two, three, four, five }; int fun(){ int arr[3] = {1,2,3}; int i = arr[index::one]; printf('%d\n', i); int j = arr[index::four]; printf('%d\n', j); return 0; } Clang diagnostic reports two warnings (which is actually correct) whereas clang-...
Hemant
1

votes
0

answer
69

Views

Error while Compiling AFL LLVM_MODE

I'm trying to compile afl llvm_mode for the last few hours with no luck. I downloaded many clang+llvm version from 6.0 to 3.6 and made sure bin is in my path. I then compiled afl, cded to llvm_mode and executed make I'm always receiving the same error: [email protected]:~/Desktop/Challenges/afl/llvm_mode#...
Daniel Israeli
1

votes
0

answer
242

Views

Using clang static analyzer with cross compiled toolchain

I am trying to set up static analysis for our code base which is cross compiled for a ARM based CPU. It appears that scan-build provided by clang is one of the best open source solutions for this. When I run scan-build, this is what I get. $ scan-build-3.8 --use-cc=arm-linux-gnueabi-gcc --analyzer-t...
Rohit Walavalkar
1

votes
0

answer
84

Views

Parse GCC builtin functions with Clang

I want to know if it is possible to parse GCC builtin functions with clang like int __builtin_ctz (unsigned int x), int __builtin_clz (unsigned int x). The reason I want to do so is that if I try and parse a C++ file including any of the standard libraries, and with correct include folders, the cla...
Moustafa Mahmoud
1

votes
0

answer
79

Views

Undefined symbols when using opt with custom LLVM pass on Mac

I would like some help figuring out this head-scratcher. Sorry for the long post! Environment Mac OS X, 10.10.5 'Yosemite' Clang/LLVM 6.0.0, built from source on 2018 Mar 9 C++14 source code CMake 3.11.0 Ninja 1.8.2 Note: I do NOT have Apple's Clang/LLVM toolchain -- I carefully removed it in 2016 b...
Chirag Bharadwaj
1

votes
1

answer
638

Views

Clang 3.8 error: invalid linker name in argument '-fuse-ld=gold-2.25'

I am using Clang 3.8 on CentOS 7.4 to compile a C++ app using third party libraries and their (complicated) makefiles. When including their makefile and running my own I am getting the following error during linkage: clang-3.8: error: invalid linker name in argument '-fuse-ld=gold-2.25' I had a look...
user997112
1

votes
1

answer
47

Views

Painlessly change type of a GlobalVariable

In my IR I have a string global constant: @.str = private unnamed_addr constant [6 x i8] c'Hello\00', align 1 This constant is used in various places across the module. I need to extend its initializer by few bytes. There is a GlobalVariable method to change it (setInitializer()), but it doesn't wor...
arrowd
1

votes
0

answer
455

Views

Xcode: Type 'struct dirent' has incompatible definitions in different translation units

I am trying to build a program with xv6's fs.h header file. I only have three files in my Xcode project: type.h(unmodified), fs.h(unmodified) and main.c as below. #include #include 'types.h' #include 'fs.h' int main(int argc, const char * argv[]) { // insert code here... printf('Hello, World!\n');...
Jay Wong
1

votes
1

answer
44

Views

How to reproduce clang's -O2 optimizations with LLVM tools?

Suppose I generate an unoptimized foo.ll using clang -S -emit-llvm foo.c. What steps do I need to take to get from foo.ll to optimized.s that's optimized as if it was produced by clang directly using -O2? (opt -S -O2 foo.ll -o optimized.ll; llc optimized.ll is not it.)
hsivonen
1

votes
0

answer
55

Views

How to Marshall LLVMSharp Function

So teaching myself some compiler design using ANTLR4 & LLVMSharp. Trying to add 2 doubles with a marshal function and the application crashes in debug mode only (possible stack corruption?) IR generated for the example below. There is no issue when marshalling integers as the parameters. define dou...
user2927848
1

votes
0

answer
40

Views

Identify self defined and declared functions

I'm working with c++ in a classroom work and we were asked to identify in llvm code which functions were defined by the user and which ones only have name, arguments and data types available. These must be identify by a c++ code, and I couldn'f find any function in c++ which could help me to disting...
Daniel
1

votes
0

answer
31

Views

How does LLVM emit AArch64's JumpTable?

There are ARM32's JumpTable description in ArmAsmPrinter.cpp, but there aren't any information of AArch64's JumpTable in AArch64AsmPrinter.cpp But, Compiler can emit JumpTable to Binaries. So, how does LLVM do it?
Twinkle HanA
1

votes
1

answer
74

Views

Pros and cons of graphical and linear intermediate representation in compiler design?

There are two kinds of intermediate representation (IR) in compiler design, briefly introduced here: graphical (e.g. abstract syntax tree) and linear (e.g. LLVM IR). What are the pros and cons of the two? I noticed Clang implemented both, but it seems only the linear representation (LLVM IR) is used...
Leedehai
1

votes
0

answer
99

Views

R calling user path to clang+llvm

how do we reset the paths that R uses to call clang: When trying to compile R package from source I get the the following error: * installing *source* package ‘sf’ ... ** package ‘sf’ successfully unpacked and MD5 sums checked configure: CC: /Users/user_name/opt/clang+llvm-4.0.1-x86_64-apple...
user2953274
1

votes
1

answer
98

Views

Issue Creating Vector LLVM

I am trying to create a vector and return it as a value using llvm. Here is what my code looks like: Value *ArrayAST::codeGen() { Type *dType = Type::getDoubleTy(mContext); Type *vectorType = VectorType::get(dType, 4); Value *emptyVector = UndefValue::get(vectorType); Constant *index0 = Constant::ge...
zoecarver
1

votes
0

answer
226

Views

Compilation error (ld: cannot find libmvec_nonshared.a,libmvec.so.1) while using Installed GCC-4.5.3

Unable to print traceback or stackdump using GCC-4.8.5 as starting with GCC version 4.6, the default setting has been changed to -fomit-frame-pointer. Read in the internet like the default can be reverted to -fno-omit-frame-pointer by configuring GCC with the --enable-frame-pointer configure option....

View additional questions