[llvm] r225250 - X86: Don't make illegal GOTTPOFF relocations
David Majnemer
david.majnemer at gmail.com
Mon Jan 5 23:12:53 PST 2015
Author: majnemer
Date: Tue Jan 6 01:12:52 2015
New Revision: 225250
URL: http://llvm.org/viewvc/llvm-project?rev=225250&view=rev
Log:
X86: Don't make illegal GOTTPOFF relocations
"ELF Handling for Thread-Local Storage" specifies that R_X86_64_GOTTPOFF
relocation target a movq or addq instruction.
Prohibit the truncation of such loads to movl or addl.
This fixes PR22083.
Differential Revision: http://reviews.llvm.org/D6839
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.h
llvm/trunk/test/CodeGen/X86/tls-models.ll
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=225250&r1=225249&r2=225250&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Jan 6 01:12:52 2015
@@ -3862,6 +3862,18 @@ bool X86TargetLowering::isFPImmLegal(con
return false;
}
+bool X86TargetLowering::shouldReduceLoadWidth(SDNode *Load,
+ ISD::LoadExtType ExtTy,
+ EVT NewVT) const {
+ // "ELF Handling for Thread-Local Storage" specifies that R_X86_64_GOTTPOFF
+ // relocation target a movq or addq instruction: don't let the load shrink.
+ SDValue BasePtr = cast<LoadSDNode>(Load)->getBasePtr();
+ if (BasePtr.getOpcode() == X86ISD::WrapperRIP)
+ if (const auto *GA = dyn_cast<GlobalAddressSDNode>(BasePtr.getOperand(0)))
+ return GA->getTargetFlags() != X86II::MO_GOTTPOFF;
+ return true;
+}
+
/// \brief Returns true if it is beneficial to convert a load of a constant
/// to just the constant itself.
bool X86TargetLowering::shouldConvertConstantLoadToIntImm(const APInt &Imm,
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=225250&r1=225249&r2=225250&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Tue Jan 6 01:12:52 2015
@@ -770,6 +770,11 @@ namespace llvm {
return !X86ScalarSSEf64 || VT == MVT::f80;
}
+ /// Return true if we believe it is correct and profitable to reduce the
+ /// load node to a smaller type.
+ bool shouldReduceLoadWidth(SDNode *Load, ISD::LoadExtType ExtTy,
+ EVT NewVT) const override;
+
const X86Subtarget* getSubtarget() const {
return Subtarget;
}
Modified: llvm/trunk/test/CodeGen/X86/tls-models.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls-models.ll?rev=225250&r1=225249&r2=225250&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls-models.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls-models.ll Tue Jan 6 01:12:52 2015
@@ -128,6 +128,14 @@ entry:
; DARWIN: _internal_ie at TLVP
}
+define i32 @PR22083() {
+entry:
+ ret i32 ptrtoint (i32* @external_ie to i32)
+ ; X64-LABEL: PR22083:
+ ; X64: movq external_ie at GOTTPOFF(%rip), %rax
+ ; X64_PIC-LABEL: PR22083:
+ ; X64_PIC: movq external_ie at GOTTPOFF(%rip), %rax
+}
; ----- localexec specified -----
More information about the llvm-commits
mailing list