summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2017-02-21 20:17:34 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2017-02-21 20:17:34 +0000
commit1fd19c6e5df00c8a9025a0d62d0f37c0643072ed (patch)
tree63a9b2e3368cfeec97742153a8b71621522d1cb3 /llvm
parent0eec53cb41523790c47e6d1d4a9c98c15d33e9b6 (diff)
downloadbcm5719-llvm-1fd19c6e5df00c8a9025a0d62d0f37c0643072ed.tar.gz
bcm5719-llvm-1fd19c6e5df00c8a9025a0d62d0f37c0643072ed.zip
Fix PR31896.
Address of an alias of a global with offset is incorrectly lowered as an address of the global (i.e. ignoring offset). llvm-svn: 295762
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/ARM/ARMISelLowering.cpp13
-rw-r--r--llvm/test/CodeGen/ARM/alias_store.ll16
2 files changed, 24 insertions, 5 deletions
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 3eed8495adf..ccebf465fc5 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -3077,17 +3077,20 @@ static SDValue promoteToConstantPool(const GlobalValue *GV, SelectionDAG &DAG,
return DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
}
+static bool isReadOnly(const GlobalValue *GV) {
+ if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV))
+ GV = GA->getBaseObject();
+ return (isa<GlobalVariable>(GV) && cast<GlobalVariable>(GV)->isConstant()) ||
+ isa<Function>(GV);
+}
+
SDValue ARMTargetLowering::LowerGlobalAddressELF(SDValue Op,
SelectionDAG &DAG) const {
EVT PtrVT = getPointerTy(DAG.getDataLayout());
SDLoc dl(Op);
const GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
const TargetMachine &TM = getTargetMachine();
- if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV))
- GV = GA->getBaseObject();
- bool IsRO =
- (isa<GlobalVariable>(GV) && cast<GlobalVariable>(GV)->isConstant()) ||
- isa<Function>(GV);
+ bool IsRO = isReadOnly(GV);
// promoteToConstantPool only if not generating XO text section
if (TM.shouldAssumeDSOLocal(*GV->getParent(), GV) && !Subtarget->genExecuteOnly())
diff --git a/llvm/test/CodeGen/ARM/alias_store.ll b/llvm/test/CodeGen/ARM/alias_store.ll
new file mode 100644
index 00000000000..48f21fc03ec
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/alias_store.ll
@@ -0,0 +1,16 @@
+; RUN: llc < %s -mtriple=arm-linux-gnueabi | FileCheck %s
+
+@X = constant {i8, i8 } { i8 0, i8 0 }
+@XA = alias i8, getelementptr inbounds ({ i8, i8 }, {i8, i8}* @X, i32 0, i32 1)
+
+define void @f(i8** %p) align 2 {
+entry:
+ store i8* @XA, i8 **%p, align 4
+ ret void
+}
+
+; CHECK: f:
+; CHECK: ldr r{{.*}}, [[L:.*]]
+; CHECK: [[L]]:
+; CHECK-NEXT: .long XA
+; CHECK: XA = X+1
OpenPOWER on IntegriCloud