lipengcheng
2013-Nov-06 18:16 UTC
[LLVMdev] "-relocation-model=static" does not work in llc compiler ?
Hi LLVM, When I compile code using llc with options " -relocation-model=static", the generated code still has relative addressing using *rip* frame pointer. May I know how to get rid of frame pointer and totally using absolute addressing ? E.g. callq *addr(%rip). Here *addr* is a global variable, and I want the global address shows up here, instead of relative addressing. In this sense, can we say " -relocation-model=static" doesn't work ? One more thing, When I compile with O0, O1, the generated code is absolute addressing. like, callq *addr. but when compiling with O2, O3, the generated code is relative addressing, callq *addr(%rip). How could I make it always absolute addressing ? Thanks, - Pengcheng
Tim Northover
2013-Nov-06 18:37 UTC
[LLVMdev] "-relocation-model=static" does not work in llc compiler ?
Hi Pengcheng,> When I compile code using llc with options " -relocation-model=static", the generated code still has > relative addressing using *rip* frame pointer. May I know how to get rid of frame pointer and totally > using absolute addressing ? > > E.g. > callq *addr(%rip). > Here *addr* is a global variable, and I want the global address shows up here, > instead of relative addressing. > In this sense, can we say " -relocation-model=static" doesn't work ?I think you may be misinterpreting "static". It doesn't mean "only use absolute relocations" but rather "you don't *have* to use position-independent relocations" (as PIC requires to make shared libraries work). In this case, the default ("small") code model in x86-64 guarantees that all code and data will be in the low 2GB of the address space so it's more efficient for the compiler to use PC-relative addressing anyway. If you also give "-code-model=large" then LLVM won't assume that "addr" is nearby so it'll use a movabsq with a static relocation. Cheers. Tim.
Tim Northover
2013-Nov-06 18:45 UTC
[LLVMdev] "-relocation-model=static" does not work in llc compiler ?
> If you also give "-code-model=large" then LLVM won't assume that > "addr" is nearby so it'll use a movabsq with a static relocation.Actually, it seems our own Eli has written rather a good description of these code models: http://eli.thegreenplace.net/2012/01/03/understanding-the-x64-code-models/. Well worth the read (the default models he talks about at the top are essentially "static"). Cheers. Tim.
Seemingly Similar Threads
- [LLVMdev] "-relocation-model=static" does not work in llc compiler ?
- [LLVMdev] "-relocation-model=static" does not work in llc compiler ?
- [LLVMdev] "-relocation-model=static" does not work in llc compiler ?
- [LLVMdev] "-relocation-model=static" does not work in llc compiler ?
- [LLVMdev] Compiling issues: undefined reference to `.Lline_table_start1'