[llvm] r200404 - Add support for PC-relative non-extern relocations to RuntimeDyldMachO.
Lang Hames
lhames at gmail.com
Wed Jan 29 10:31:35 PST 2014
Author: lhames
Date: Wed Jan 29 12:31:35 2014
New Revision: 200404
URL: http://llvm.org/viewvc/llvm-project?rev=200404&view=rev
Log:
Add support for PC-relative non-extern relocations to RuntimeDyldMachO.
Also replaces testcase for r180790 (support for absolute non-externs relocs)
with a more robust version.
<rdar://problem/15864721>
Modified:
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
llvm/trunk/test/ExecutionEngine/MCJIT/non-extern-addend.ll
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp?rev=200404&r1=200403&r2=200404&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp Wed Jan 29 12:31:35 2014
@@ -382,6 +382,8 @@ void RuntimeDyldMachO::processRelocation
uint64_t Addr;
Sec.getAddress(Addr);
Value.Addend = Addend - Addr;
+ if (IsPCRel)
+ Value.Addend += Offset + NumBytes;
}
if (Arch == Triple::x86_64 && (RelType == MachO::X86_64_RELOC_GOT ||
Modified: llvm/trunk/test/ExecutionEngine/MCJIT/non-extern-addend.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/MCJIT/non-extern-addend.ll?rev=200404&r1=200403&r2=200404&view=diff
==============================================================================
--- llvm/trunk/test/ExecutionEngine/MCJIT/non-extern-addend.ll (original)
+++ llvm/trunk/test/ExecutionEngine/MCJIT/non-extern-addend.ll Wed Jan 29 12:31:35 2014
@@ -1,12 +1,22 @@
; RUN: %lli_mcjit %s > /dev/null
+; RUN: %lli_mcjit -code-model=small %s > /dev/null
-define i32 @foo(i32 %X, i32 %Y, double %A) {
- %cond212 = fcmp ueq double %A, 2.000000e+00 ; <i1> [#uses=1]
- %cast110 = zext i1 %cond212 to i32 ; <i32> [#uses=1]
- ret i32 %cast110
+define i32 @foo(i32 %x, i32 %y, double %d) {
+entry:
+ %d.int64 = bitcast double %d to i64
+ %d.top64 = lshr i64 %d.int64, 32
+ %d.top = trunc i64 %d.top64 to i32
+ %d.bottom = trunc i64 %d.int64 to i32
+ %topCorrect = icmp eq i32 %d.top, 3735928559
+ %bottomCorrect = icmp eq i32 %d.bottom, 4277009102
+ %right = and i1 %topCorrect, %bottomCorrect
+ %nRight = xor i1 %right, true
+ %retVal = zext i1 %nRight to i32
+ ret i32 %retVal
}
define i32 @main() {
- %reg212 = call i32 @foo( i32 0, i32 1, double 1.000000e+00 ) ; <i32> [#uses=1]
- ret i32 %reg212
+entry:
+ %call = call i32 @foo(i32 0, i32 1, double 0xDEADBEEFFEEDFACE)
+ ret i32 %call
}
More information about the llvm-commits
mailing list