[llvm] r231456 - X86: Form IMGREL relocations for LLVM Functions
David Majnemer
david.majnemer at gmail.com
Fri Mar 6 00:11:32 PST 2015
Author: majnemer
Date: Fri Mar 6 02:11:32 2015
New Revision: 231456
URL: http://llvm.org/viewvc/llvm-project?rev=231456&view=rev
Log:
X86: Form IMGREL relocations for LLVM Functions
We supported forming IMGREL relocations from ConstantExprs involving
__ImageBase if the minuend was a GlobalVariable. Extend this
functionality to all GlobalObjects.
Modified:
llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp
llvm/trunk/test/MC/COFF/ir-to-imgrel.ll
Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=231456&r1=231455&r2=231456&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Fri Mar 6 02:11:32 2015
@@ -96,14 +96,12 @@ const MCExpr *X86WindowsTargetObjectFile
SubRHS->getPointerAddressSpace() != 0)
return nullptr;
- // Both ptrtoint instructions must wrap global variables:
+ // Both ptrtoint instructions must wrap global objects:
// - Only global variables are eligible for image relative relocations.
- // - The subtrahend refers to the special symbol __ImageBase, a global.
- const GlobalVariable *GVLHS =
- dyn_cast<GlobalVariable>(SubLHS->getPointerOperand());
- const GlobalVariable *GVRHS =
- dyn_cast<GlobalVariable>(SubRHS->getPointerOperand());
- if (!GVLHS || !GVRHS)
+ // - The subtrahend refers to the special symbol __ImageBase, a GlobalVariable.
+ const auto *GOLHS = dyn_cast<GlobalObject>(SubLHS->getPointerOperand());
+ const auto *GVRHS = dyn_cast<GlobalVariable>(SubRHS->getPointerOperand());
+ if (!GOLHS || !GVRHS)
return nullptr;
// We expect __ImageBase to be a global variable without a section, externally
@@ -116,10 +114,10 @@ const MCExpr *X86WindowsTargetObjectFile
return nullptr;
// An image-relative, thread-local, symbol makes no sense.
- if (GVLHS->isThreadLocal())
+ if (GOLHS->isThreadLocal())
return nullptr;
- return MCSymbolRefExpr::Create(TM.getSymbol(GVLHS, Mang),
+ return MCSymbolRefExpr::Create(TM.getSymbol(GOLHS, Mang),
MCSymbolRefExpr::VK_COFF_IMGREL32,
getContext());
}
Modified: llvm/trunk/test/MC/COFF/ir-to-imgrel.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/ir-to-imgrel.ll?rev=231456&r1=231455&r2=231456&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/ir-to-imgrel.ll (original)
+++ llvm/trunk/test/MC/COFF/ir-to-imgrel.ll Fri Mar 6 02:11:32 2015
@@ -4,3 +4,8 @@
; X64: .quad "?x@@3HA"@IMGREL
@"\01?x@@3HA" = global i64 sub nsw (i64 ptrtoint (i64* @"\01?x@@3HA" to i64), i64 ptrtoint (i8* @__ImageBase to i64)), align 8
+
+declare void @f()
+
+; X64: .quad f at IMGREL
+ at fp = global i64 sub nsw (i64 ptrtoint (void ()* @f to i64), i64 ptrtoint (i8* @__ImageBase to i64)), align 8
More information about the llvm-commits
mailing list