Issue 114143
Summary commit c04a05d898982614a2df80d928b97ed4f8c49b60 broke mcmodel=medium on windows
Labels new issue
Assignees
Reporter erik895
    ```
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 c04a05d898982614a2df80d928b97ed4f8c49b60 
  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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to