llvm.org GIT mirror llvm / 8de5c21
Merging r295762: ------------------------------------------------------------------------ r295762 | eugenis | 2017-02-21 12:17:34 -0800 (Tue, 21 Feb 2017) | 3 lines Fix PR31896. Address of an alias of a global with offset is incorrectly lowered as an address of the global (i.e. ignoring offset). ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@296002 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 2 years ago
2 changed file(s) with 24 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
30263026 return DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
30273027 }
30283028
3029 static bool isReadOnly(const GlobalValue *GV) {
3030 if (const GlobalAlias *GA = dyn_cast(GV))
3031 GV = GA->getBaseObject();
3032 return (isa(GV) && cast(GV)->isConstant()) ||
3033 isa(GV);
3034 }
3035
30293036 SDValue ARMTargetLowering::LowerGlobalAddressELF(SDValue Op,
30303037 SelectionDAG &DAG) const {
30313038 EVT PtrVT = getPointerTy(DAG.getDataLayout());
30323039 SDLoc dl(Op);
30333040 const GlobalValue *GV = cast(Op)->getGlobal();
30343041 const TargetMachine &TM = getTargetMachine();
3035 if (const GlobalAlias *GA = dyn_cast(GV))
3036 GV = GA->getBaseObject();
3037 bool IsRO =
3038 (isa(GV) && cast(GV)->isConstant()) ||
3039 isa(GV);
3042 bool IsRO = isReadOnly(GV);
30403043
30413044 // promoteToConstantPool only if not generating XO text section
30423045 if (TM.shouldAssumeDSOLocal(*GV->getParent(), GV) && !Subtarget->genExecuteOnly())
0 ; RUN: llc < %s -mtriple=arm-linux-gnueabi | FileCheck %s
1
2 @X = constant {i8, i8 } { i8 0, i8 0 }
3 @XA = alias i8, getelementptr inbounds ({ i8, i8 }, {i8, i8}* @X, i32 0, i32 1)
4
5 define void @f(i8** %p) align 2 {
6 entry:
7 store i8* @XA, i8 **%p, align 4
8 ret void
9 }
10
11 ; CHECK: f:
12 ; CHECK: ldr r{{.*}}, [[L:.*]]
13 ; CHECK: [[L]]:
14 ; CHECK-NEXT: .long XA
15 ; CHECK: XA = X+1