[llvm-commits] [llvm] r45515 - /llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
Evan Cheng
evan.cheng at apple.com
Wed Jan 2 15:39:00 PST 2008
Author: evancheng
Date: Wed Jan 2 17:38:59 2008
New Revision: 45515
URL: http://llvm.org/viewvc/llvm-project?rev=45515&view=rev
Log:
X86 PIC JIT bug fix: relocations for constantpool and jumptable.
Modified:
llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=45515&r1=45514&r2=45515&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Wed Jan 2 17:38:59 2008
@@ -246,13 +246,12 @@
emitGlobalAddress(RelocOp->getGlobal(), rt, RelocOp->getOffset(),
PCAdj, false, IsPIC);
} else if (RelocOp->isConstantPoolIndex()) {
- // Must be in 64-bit mode.
- emitConstPoolAddress(RelocOp->getIndex(), X86::reloc_pcrel_word,
+ unsigned rt = Is64BitMode ? X86::reloc_pcrel_word : X86::reloc_picrel_word;
+ emitConstPoolAddress(RelocOp->getIndex(), rt,
RelocOp->getOffset(), PCAdj, IsPIC);
} else if (RelocOp->isJumpTableIndex()) {
- // Must be in 64-bit mode.
- emitJumpTableAddress(RelocOp->getIndex(), X86::reloc_pcrel_word,
- PCAdj, IsPIC);
+ unsigned rt = Is64BitMode ? X86::reloc_pcrel_word : X86::reloc_picrel_word;
+ emitJumpTableAddress(RelocOp->getIndex(), rt, PCAdj, IsPIC);
} else {
assert(0 && "Unknown value to relocate!");
}
@@ -269,14 +268,14 @@
if (Op3.isGlobalAddress()) {
DispForReloc = &Op3;
} else if (Op3.isConstantPoolIndex()) {
- if (Is64BitMode) {
+ if (Is64BitMode || IsPIC) {
DispForReloc = &Op3;
} else {
DispVal += MCE.getConstantPoolEntryAddress(Op3.getIndex());
DispVal += Op3.getOffset();
}
} else if (Op3.isJumpTableIndex()) {
- if (Is64BitMode) {
+ if (Is64BitMode || IsPIC) {
DispForReloc = &Op3;
} else {
DispVal += MCE.getJumpTableEntryAddress(Op3.getIndex());
More information about the llvm-commits
mailing list