-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Description
int foo = 32;
int* go()
{
return &foo;
}
compiled with clang on windows:
clang.exe -mcmodel=medium -Wl,/SUBSYSTEM:CONSOLE -o a.exe -nostdlib -Wl,-entry:go test.cpp
used to generate:
llvm-objdump.exe -d a.exe
Disassembly of section .text:
0000000140001000 <.text>:
140001000: 48 b8 00 30 00 40 01 00 00 00 movabsq $0x140003000, %rax # imm = 0x140003000
14000100a: c3 retq
After commit c04a05d
more specific this chunk:
- CodeModel::Model M = getTargetMachine().getCodeModel();
+ // The following OpFlags under RIP-rel PIC use RIP.
if (Subtarget.isPICStyleRIPRel() &&
- (M == CodeModel::Small || M == CodeModel::Kernel))
+ (OpFlags == X86II::MO_NO_FLAG || OpFlags == X86II::MO_COFFSTUB ||
+ OpFlags == X86II::MO_DLLIMPORT))
return X86ISD::WrapperRIP;
The output changes to
0000000140001000 <.text>:
140001000: 48 8d 05 f9 1f 00 00 leaq 0x1ff9(%rip), %rax # 0x140003000
140001007: c3 retq
I think its wrong to generate rip relative with mcmodel=medium.