summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Target/ARM/ARMISelLowering.cpp8
-rw-r--r--llvm/test/CodeGen/ARM/readonly-aliases.ll17
2 files changed, 22 insertions, 3 deletions
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 3527d049f50..2f4bc46f932 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -3171,9 +3171,11 @@ static SDValue promoteToConstantPool(const ARMTargetLowering *TLI,
bool ARMTargetLowering::isReadOnly(const GlobalValue *GV) const {
if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV))
- GV = GA->getBaseObject();
- return (isa<GlobalVariable>(GV) && cast<GlobalVariable>(GV)->isConstant()) ||
- isa<Function>(GV);
+ if (!(GV = GA->getBaseObject()))
+ return false;
+ if (const auto *V = dyn_cast<GlobalVariable>(GV))
+ return V->isConstant();
+ return isa<Function>(GV);
}
SDValue ARMTargetLowering::LowerGlobalAddress(SDValue Op,
diff --git a/llvm/test/CodeGen/ARM/readonly-aliases.ll b/llvm/test/CodeGen/ARM/readonly-aliases.ll
new file mode 100644
index 00000000000..c90650d3a81
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/readonly-aliases.ll
@@ -0,0 +1,17 @@
+; RUN: llc -mtriple thumbv7-unknown-linux-android -filetype asm -o - %s | FileCheck %s
+
+@a = protected constant <{ i32, i32 }> <{ i32 0, i32 0 }>
+@b = protected alias i32, getelementptr(i32, i32* getelementptr inbounds (<{ i32, i32 }>, <{ i32, i32 }>* @a, i32 0, i32 1), i32 -1)
+
+declare void @f(i32*)
+
+define void @g() {
+entry:
+ call void @f(i32* @b)
+ ret void
+}
+
+; CHECK-LABEL: g:
+; CHECK: movw [[REGISTER:r[0-9]+]], :lower16:b
+; CHECK: movt [[REGISTER]], :upper16:b
+
OpenPOWER on IntegriCloud