[PATCH] D29740: Fix PR31896.

Evgeniy Stepanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 21 12:19:44 PST 2017


eugenis updated this revision to Diff 89262.
eugenis added a comment.

fixed the test


Repository:
  rL LLVM

https://reviews.llvm.org/D29740

Files:
  lib/Target/ARM/ARMISelLowering.cpp
  test/CodeGen/ARM/alias_store.ll


Index: test/CodeGen/ARM/alias_store.ll
===================================================================
--- /dev/null
+++ test/CodeGen/ARM/alias_store.ll
@@ -0,0 +1,16 @@
+; RUN: llc < %s -mtriple=arm-linux-gnueabi | FileCheck %s
+
+ at X = constant {i8, i8 } { i8 0, i8 0 }
+ at 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 r1, [[L:.*]]
+; CHECK: [[L]]:
+; CHECK-NEXT: .long XA
+; CHECK: XA = X+1
Index: lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- lib/Target/ARM/ARMISelLowering.cpp
+++ lib/Target/ARM/ARMISelLowering.cpp
@@ -3077,17 +3077,20 @@
   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())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29740.89262.patch
Type: text/x-patch
Size: 1805 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170221/d2d21f6f/attachment.bin>


More information about the llvm-commits mailing list