[PATCH] D24627: X86: Do not produce GOT relocations on windows
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 15 13:54:40 PDT 2016
MatzeB created this revision.
MatzeB added a reviewer: rafael.
MatzeB added a subscriber: llvm-commits.
MatzeB set the repository for this revision to rL LLVM.
Herald added a subscriber: mcrosier.
r270209 ("Refactor X86 symbol access classification.") broke some EFI firmware projects targetting x86_64-pc-windows-macho. This patch fixes that:
Windows has no GOT relocations the way elf/darwin has.
"x86_64-pc-win32-macho" is sometimes used to build EFI firmware; Use windows style reloction (no-GOT) for this target.
Repository:
rL LLVM
https://reviews.llvm.org/D24627
Files:
lib/Target/TargetMachine.cpp
test/CodeGen/X86/x86-64-pic-12.ll
Index: test/CodeGen/X86/x86-64-pic-12.ll
===================================================================
--- /dev/null
+++ test/CodeGen/X86/x86-64-pic-12.ll
@@ -0,0 +1,27 @@
+; RUN: llc -o - %s -relocation-model=pic | FileCheck %s
+; Check that we do not get GOT relocations with the x86_64-pc-windows-macho
+; triple.
+target triple = "x86_64-pc-windows-macho"
+
+ at g = common global i32 0, align 4
+
+declare i32 @extbar()
+
+; CHECK-LABEL: bar:
+; CHECK: callq _extbar
+; CHECK: leaq _extbar(%rip),
+; CHECK-NOT: @GOT
+define i8* @bar() {
+ call i32 @extbar()
+ ret i8* bitcast (i32 ()* @extbar to i8*)
+}
+
+; CHECK-LABEL: foo:
+; CHECK: callq _bar
+; CHECK: movl _g(%rip),
+; CHECK-NOT: @GOT
+define i32 @foo() {
+ call i8* @bar()
+ %gval = load i32, i32* @g, align 4
+ ret i32 %gval
+}
Index: lib/Target/TargetMachine.cpp
===================================================================
--- lib/Target/TargetMachine.cpp
+++ lib/Target/TargetMachine.cpp
@@ -128,7 +128,7 @@
return false;
// Every other GV is local on COFF
- if (TT.isOSBinFormatCOFF())
+ if (TT.isOSBinFormatCOFF() || TT.isOSWindows())
return true;
if (GV && (GV->hasLocalLinkage() || !GV->hasDefaultVisibility()))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24627.71549.patch
Type: text/x-patch
Size: 1220 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160915/cd34c656/attachment.bin>
More information about the llvm-commits
mailing list