mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-03 17:32:59 +00:00
Use shouldAssumeDSOLocal in isOffsetFoldingLegal.
This makes it slightly more powerful for dynamic-no-pic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273704 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c0b6cd2c10
commit
fddccef6cb
@ -311,17 +311,22 @@ TargetLowering::getPICJumpTableRelocBaseExpr(const MachineFunction *MF,
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
TargetLowering::isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const {
|
TargetLowering::isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const {
|
||||||
// Assume that everything is safe in static mode.
|
const TargetMachine &TM = getTargetMachine();
|
||||||
if (getTargetMachine().getRelocationModel() == Reloc::Static)
|
Reloc::Model RM = TM.getRelocationModel();
|
||||||
return true;
|
const GlobalValue *GV = GA->getGlobal();
|
||||||
|
const Triple &TargetTriple = TM.getTargetTriple();
|
||||||
|
|
||||||
// In dynamic-no-pic mode, assume that known defined values are safe.
|
// If the address is not even local to this DSO we will have to load it from
|
||||||
if (getTargetMachine().getRelocationModel() == Reloc::DynamicNoPIC &&
|
// a got and then add the offset.
|
||||||
GA && GA->getGlobal()->isStrongDefinitionForLinker())
|
if (!shouldAssumeDSOLocal(RM, TargetTriple, *GV->getParent(), GV))
|
||||||
return true;
|
return false;
|
||||||
|
|
||||||
// Otherwise assume nothing is safe.
|
// If the code is position independent we will have to add a base register.
|
||||||
return false;
|
if (RM == Reloc::PIC_)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Otherwise we can do it.
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
10
test/CodeGen/X86/ga-offset2.ll
Normal file
10
test/CodeGen/X86/ga-offset2.ll
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
; RUN: llc < %s -mtriple=i686-apple-darwin -relocation-model=dynamic-no-pic | FileCheck %s
|
||||||
|
|
||||||
|
@var = external hidden global i32
|
||||||
|
@p = external hidden global i32*
|
||||||
|
|
||||||
|
define void @f() {
|
||||||
|
; CHECK: movl $_var+40, _p
|
||||||
|
store i32* getelementptr (i32, i32* @var, i64 10), i32** @p
|
||||||
|
ret void
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user