summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2016-06-24 18:48:36 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2016-06-24 18:48:36 +0000
commit88ae09e9be07d61d0c31024510a18d8ef6f15102 (patch)
tree7d24f1891001c8014971b4c4e396bded7c836de8 /llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
parentfbd5eef691f4d74317722dbf58016d07c14bedca (diff)
downloadbcm5719-llvm-88ae09e9be07d61d0c31024510a18d8ef6f15102.tar.gz
bcm5719-llvm-88ae09e9be07d61d0c31024510a18d8ef6f15102.zip
Use shouldAssumeDSOLocal in isOffsetFoldingLegal.
This makes it slightly more powerful for dynamic-no-pic. llvm-svn: 273704
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 9d6c855bb82..dc7bb7ca817 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -311,17 +311,22 @@ TargetLowering::getPICJumpTableRelocBaseExpr(const MachineFunction *MF,
bool
TargetLowering::isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const {
- // Assume that everything is safe in static mode.
- if (getTargetMachine().getRelocationModel() == Reloc::Static)
- return true;
+ const TargetMachine &TM = getTargetMachine();
+ Reloc::Model RM = TM.getRelocationModel();
+ const GlobalValue *GV = GA->getGlobal();
+ const Triple &TargetTriple = TM.getTargetTriple();
+
+ // If the address is not even local to this DSO we will have to load it from
+ // a got and then add the offset.
+ if (!shouldAssumeDSOLocal(RM, TargetTriple, *GV->getParent(), GV))
+ return false;
- // In dynamic-no-pic mode, assume that known defined values are safe.
- if (getTargetMachine().getRelocationModel() == Reloc::DynamicNoPIC &&
- GA && GA->getGlobal()->isStrongDefinitionForLinker())
- return true;
+ // If the code is position independent we will have to add a base register.
+ if (RM == Reloc::PIC_)
+ return false;
- // Otherwise assume nothing is safe.
- return false;
+ // Otherwise we can do it.
+ return true;
}
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud