llvm

Conversion from ___attribute___((shared)) to addrspace(3) in Clang compiler when compiling CUDA files

半世苍凉 提交于 2019-12-02 10:52:54
问题 The clang compiler includes CUDA header file host_defines.h in which the __shared__ is defined as __attribute__((shared)) . When CUDA source files are compiled to internal representation (IR) using clang, the __shared__ gets converted to addrspace(3) . These address spaces can be observed in the clang file llvm/tools/clang/lib/Basic/Targets.cpp line number 1601 as an array static const unsigned NVPTXAddrSpaceMap[] = { 1, // opencl_global 3, // opencl_local 4, // opencl_constant // FIXME:

Creating local variable in function LLVM

此生再无相见时 提交于 2019-12-02 10:48:20
问题 In llvm::Module there are 2 interesting fields: typedef SymbolTableList<Function> FunctionListType; typedef SymbolTableList<GlobalVariable> GlobalListType; GlobalListType GlobalList; ///< The Global Variables in the module FunctionListType FunctionList; ///< The Functions in the module So, if we will define some functions or global variables, we will be able to use them from any other places of our program just asking our module for them. But what about function local variables? How to define

meaning of llvm[n] when compiling llvm, where n is an integer

喜夏-厌秋 提交于 2019-12-02 08:17:17
I'm compiling LLVM as well as clang. I noticed that the output of compilation has llvm[1]: or llvm[2]: or llvm[3] : prefixed to each line. What do those integers in brackets mean? It's the number of the compilation job ( make -j ). Helpful to trace compilation errors. Apparently, it's not connected to the number of the compilation job (can be easily checked via make -j 1). The autoconf-based build system indicates the "level" of the makefile inside the source tree). To be prices, it's a value of make's MAKELEVEL variable. The currently accepted answer is not correct. Furthermore, this is

How to get LLVM bitcode line number from CPP source code line number?

我的未来我决定 提交于 2019-12-02 07:56:57
I have a cpp file and the bitcode using clang 9. Now, I select a cpp line number from the source code and I want to get the LLVM bit code line number for this source code line instead of manually doing disassembly of bit code file and reading the file line by line. Please tell me if it is possible and how. There may not be a set of IR instructions that correspond clearly to that exact line... but it's possible, mostly. There is a function called Instruction::getDebugLoc() that returns the file name and line number for that particular instruction, if it returns anything at all. You can use that

Change Name of LLVM Function

荒凉一梦 提交于 2019-12-02 07:27:18
问题 I have a LLVM Module object which contains a particular function that I would like to rename. Is there any way of simply changing the name of a Function? 回答1: Given a module, you can look up a specific function by name using the getFunction method, or you can iterate over all the functions in the module using begin() and end() . From there, Function inherits from Value , so you can just use the setName method change the name. This will also automatically update all the references and calls to

what does machine value type “other” mean in llvm SDnodes

£可爱£侵袭症+ 提交于 2019-12-02 07:13:37
问题 I am trying to understand more deeply the instruction selection process in llvm and for that I am debuging step-by-step the CodeGenAndEmitDAG function. I have printed a small function (see below) just before the combine step - the first step in the above function. In the graph I see blue lines and it seems that they are always pointing at "ch" , which I think means "other" machine value type. What I don't understand is the meaning of the blue lines... what is this dependency ? And, am I right

What does this LLVM 1.5 warning mean? “protocol qualifiers without 'id' is archaic”

假如想象 提交于 2019-12-02 05:15:28
I've just tried compiling an iOS project using the the LLVM 1.5 compiler (included in XCode 3.2.3), and I got a lot of new warnings, including several like this: protocol qualifiers without 'id' is archaic For instance, this happens on lines like this: - (id)initWithContext:(NSManagedObjectContext *)context coordinator:(NSPersistentStoreCoordinator *)coordinator delegate:(<NSFetchedResultsControllerDelegate>)delegate; Now, I think this is probably a "naming conventions" warning, but anyone know what it really means? Archaic: extremely old or extremely old-fashioned . The warning means a

Run default optimization pipeline using modern LLVM

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 04:39:01
I'm using LLVM 7 and I have an llvm::Module that I'd like to optimize using the standard optimization pipeline. Unfortunately, there isn't a llvm::runDefaultOptimizations function that I can call. There seems to be a bajillion ways to optimize a module in LLVM. My searches on this topic have found many old/depreciated APIs and some examples that don't work on my system. I want to run all of the standard optimizations at -O3 with the least amount of hassle possible. I don't want to manually list all of the passes or even write a for loop. I thought llvm::PassBuilder:

Lack of autorelease optimization under ARC compiler

*爱你&永不变心* 提交于 2019-12-02 04:16:19
I was just wondering, why is there no autorelease pool optimization under the ARC compiler, where it would retain an object in the innermost scope, remove it from the autorelease pool and release once the object is no longer in use? To quote a very impractical example from another question, for(NSUInteger i = 0; i < 10000; i++) { for(NSUInteger j = 0; j < 10000; j++) { NSNumber* n = [NSNumber numberWithUnsignedInteger:j]; //NSLog(@"%@", n); //Disabled this to increase memory bloat faster. } } Without @autoreleasepool { ... } wrapping, memory grows and grows. Wrapping with @autoreleasepool ,

invalid value 'edge' in 'fsantize-coverage=edge' when using LLVM LibFuzzer

僤鯓⒐⒋嵵緔 提交于 2019-12-02 04:15:35
问题 http://llvm.org/docs/LibFuzzer.html I'm doing some works with libfuzzer now but when I do with the official toy example. when i run this command: clang++ -fsanitize=address -fsanitize-coverage=edge test-fuzzer.cc Fuzzer*.o there is an error happening that clang: error: invalid value 'edge' in 'fsanitize-coverage=edge' it seems that clang supports this argument but i'm wondering how i can see what value is supported... i installed llvm 3.6 by apt-get with unbuntu14.04... 回答1: The syntax of the