[llvm] r295762 - Fix PR31896.

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 22 13:35:12 PST 2017


>From the PR, it sounds like this is fixing a bug from r278015, that is
a regression from 3.9.

Tim or Renato, what do you think about merging this?

On Wed, Feb 22, 2017 at 12:55 PM, Evgenii Stepanov
<eugeni.stepanov at gmail.com> wrote:
> Could this change be merged to 4.0?
>
> On Tue, Feb 21, 2017 at 12:17 PM, Evgeniy Stepanov via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>> Author: eugenis
>> Date: Tue Feb 21 14:17:34 2017
>> New Revision: 295762
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=295762&view=rev
>> Log:
>> Fix PR31896.
>>
>> Address of an alias of a global with offset is incorrectly lowered as an address of the global (i.e. ignoring offset).
>>
>> Added:
>>     llvm/trunk/test/CodeGen/ARM/alias_store.ll
>> Modified:
>>     llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
>>
>> Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=295762&r1=295761&r2=295762&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
>> +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Feb 21 14:17:34 2017
>> @@ -3077,17 +3077,20 @@ static SDValue promoteToConstantPool(con
>>    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())
>>
>> Added: llvm/trunk/test/CodeGen/ARM/alias_store.ll
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/alias_store.ll?rev=295762&view=auto
>> ==============================================================================
>> --- llvm/trunk/test/CodeGen/ARM/alias_store.ll (added)
>> +++ llvm/trunk/test/CodeGen/ARM/alias_store.ll Tue Feb 21 14:17:34 2017
>> @@ -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 r{{.*}}, [[L:.*]]
>> +; CHECK: [[L]]:
>> +; CHECK-NEXT: .long XA
>> +; CHECK: XA = X+1
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list