[PATCH] D29740: Fix PR31896.

Evgeniy Stepanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 8 17:04:59 PST 2017


eugenis created this revision.

Address of an alias of a global with offset is incorrectly lowered as an address of the global (i.e. ignoring offset).

This is fixing a problem introduced in https://reviews.llvm.org/D23195 and reported in PR31896.

I'm not really sure this is a correct fix, but 
(a) I see no good reason for the chunk of the code that I'm removing to exist
(b) removing it does not break any tests and fixes PR31896


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,18 @@
+; PR31896: address of @XA should lower to XA, not to X.
+; RUN: llc < %s | FileCheck %s
+
+target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+target triple = "thumbv7--linux"
+
+ 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: movw r1, :lower16:XA
+; CHECK: movt r1, :upper16:XA
+; CHECK: str  r1, [r0]
Index: lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- lib/Target/ARM/ARMISelLowering.cpp
+++ lib/Target/ARM/ARMISelLowering.cpp
@@ -3067,8 +3067,6 @@
   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);


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


More information about the llvm-commits mailing list