o.j.sivart at gmail.com
2010-May-13 09:05 UTC
[LLVMdev] Handling of thread_local globals by llc -march=cpp
Thanks for the quick reply and fix. Now it just means I have to hunt further in exploring why, in my simple test program, replacing the following line of code: GlobalVariable* global = new GlobalVariable(*MyModule, IntegerType::get(getGlobalContext(), 32), false, GlobalValue::ExternalLinkage, 0, "global"); with the following line of code: GlobalVariable* global = new GlobalVariable(*MyModule, IntegerType::get(getGlobalContext(), 32), false, GlobalValue::ExternalLinkage, 0, "global", 0, true); in order to create a thread local global variable instead of a standard global variable causes the function (which uses the global) produced by the following line of code: void *FPtr = MyExecutionEngine->getPointerToFunction(MyFunction); to segfault when I call it in the following sequence of code: int (*FP)() = (int (*)())FPtr; int res = FP(); when the function executes correctly in the case of instead having created a standard global variable. Doh! As far as I got with this was to note that the machine code produced for the function is attempting to still do a move from a memory location (and an inaccessible one at that: 0xfffffffc) instead of doing a move from an offset from the segment register. On 13/05/2010, at 5:13 PM, Anton Korobeynikov wrote:> Hello > >> I've been exploring thread local globals in llvm and as part of this investigation I ran llc -march=cpp over a trivial llvm bc file which uses thread local storage for a global. For some reason llc -march=cpp seems to ignore the thread_local and produce code to create a standard global. Is this expected behaviour, a known limitation, or otherwise? > Thanks for the report. Should be fixed in r103702 > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University
Anton Korobeynikov
2010-May-13 11:55 UTC
[LLVMdev] Handling of thread_local globals by llc -march=cpp
> int (*FP)() = (int (*)())FPtr; > int res = FP(); > > when the function executes correctly in the case of instead having created a standard global variable.What is the platform you're running the code on? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
o.j.sivart at gmail.com
2010-May-13 11:56 UTC
[LLVMdev] Handling of thread_local globals by llc -march=cpp
target triple = "i386-pc-linux-gnu" On 13/05/2010, at 9:25 PM, Anton Korobeynikov wrote:>> int (*FP)() = (int (*)())FPtr; >> int res = FP(); >> >> when the function executes correctly in the case of instead having created a standard global variable. > What is the platform you're running the code on? > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University
Reasonably Related Threads
- [LLVMdev] Handling of thread_local globals by llc -march=cpp
- [LLVMdev] Handling of thread_local globals by llc -march=cpp
- [LLVMdev] Handling of thread_local globals by llc -march=cpp
- [LLVMdev] Handling of thread_local globals by llc -march=cpp
- [LLVMdev] Handling of thread_local globals by llc -march=cpp