[cfe-dev] [llvm-dev] How to debug if LTO generate wrong code?

Rafael EspĂ­ndola via cfe-dev cfe-dev at lists.llvm.org
Tue May 31 06:21:05 PDT 2016


On 31 May 2016 at 01:08, Shi, Steven <steven.shi at intel.com> wrote:
> Hi Mehdi,
> What's the default code model for x86_64 Mac OS X App?  Andrew showed me some example code of Mac OS X App as below, which looks to use the small code model but can run at  >4GB high address.

Small, but PIC.



> For example if you read a global like this the compiler will generate this code.
> int constant = 0;
>
> int get_constant(void)
> {
>         return constant;
> }


Compiling for ELF with -FPIE -Os I get

get_constant:                           # @get_constant
# BB#0:                                 # %entry
        movl    constant(%rip), %eax
        retq

Which should also be able to run at any address.

Cheers,
Rafael



More information about the cfe-dev mailing list