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(GV)) + GV = GA->getBaseObject(); + return (isa(GV) && cast(GV)->isConstant()) || + isa(GV); +} + SDValue ARMTargetLowering::LowerGlobalAddressELF(SDValue Op, SelectionDAG &DAG) const { EVT PtrVT = getPointerTy(DAG.getDataLayout()); SDLoc dl(Op); const GlobalValue *GV = cast(Op)->getGlobal(); const TargetMachine &TM = getTargetMachine(); - if (const GlobalAlias *GA = dyn_cast(GV)) - GV = GA->getBaseObject(); - bool IsRO = - (isa(GV) && cast(GV)->isConstant()) || - isa(GV); + bool IsRO = isReadOnly(GV); // promoteToConstantPool only if not generating XO text section if (TM.shouldAssumeDSOLocal(*GV->getParent(), GV) && !Subtarget->genExecuteOnly()) 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 + +@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 r1, [[L:.*]] +; CHECK: [[L]]: +; CHECK-NEXT: .long XA +; CHECK: XA = X+1