[llvm] r242840 - [AsmPrinter] Check for valid constants in handleIndirectSymViaGOTPCRel

Bruno Cardoso Lopes bruno.cardoso at gmail.com
Wed Jul 22 14:28:51 PDT 2015


I think it's pretty safe and we should merge, it fixes a regression
from 3.6 sine the changes only affect a path that used to work prior
to introducing handleIndirectSymViaGOTPCRel (r230264).

On Wed, Jul 22, 2015 at 6:22 PM, Hans Wennborg <hans at chromium.org> wrote:
> Is this something we should merge to 3.7 (from reading the PR I'm not
> sure at what version the bug appeared)
>
> On Tue, Jul 21, 2015 at 2:45 PM, Bruno Cardoso Lopes
> <bruno.cardoso at gmail.com> wrote:
>> Author: bruno
>> Date: Tue Jul 21 16:45:42 2015
>> New Revision: 242840
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=242840&view=rev
>> Log:
>> [AsmPrinter] Check for valid constants in handleIndirectSymViaGOTPCRel
>>
>> Check whether BaseCst is valid before extracting a GlobalValue.
>> This fixes PR24163.
>>
>> Patch by David Majnemer.
>>
>> Modified:
>>     llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
>>     llvm/trunk/test/MC/MachO/cstexpr-gotpcrel-64.ll
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=242840&r1=242839&r2=242840&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Jul 21 16:45:42 2015
>> @@ -2101,7 +2101,7 @@ static void handleIndirectSymViaGOTPCRel
>>    if (!AP.GlobalGOTEquivs.count(GOTEquivSym))
>>      return;
>>
>> -  const GlobalValue *BaseGV = dyn_cast<GlobalValue>(BaseCst);
>> +  const GlobalValue *BaseGV = dyn_cast_or_null<GlobalValue>(BaseCst);
>>    if (!BaseGV)
>>      return;
>>
>>
>> Modified: llvm/trunk/test/MC/MachO/cstexpr-gotpcrel-64.ll
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/cstexpr-gotpcrel-64.ll?rev=242840&r1=242839&r2=242840&view=diff
>> ==============================================================================
>> --- llvm/trunk/test/MC/MachO/cstexpr-gotpcrel-64.ll (original)
>> +++ llvm/trunk/test/MC/MachO/cstexpr-gotpcrel-64.ll Tue Jul 21 16:45:42 2015
>> @@ -1,6 +1,7 @@
>>  ; RUN: llc -mtriple=x86_64-apple-darwin %s -o %t
>>  ; RUN:  FileCheck %s -check-prefix=X86 < %t
>>  ; RUN:  FileCheck %s -check-prefix=X86-GOT-EQUIV < %t
>> +; RUN:  FileCheck %s -check-prefix=X86-NOGOT-EQUIV < %t
>>
>>  ; GOT equivalent globals references can be replaced by the GOT entry of the
>>  ; final symbol instead.
>> @@ -86,10 +87,15 @@ define i32** @t1() {
>>  }
>>
>>  ; Do not crash when a pattern cannot be matched as a GOT equivalent
>> -
>> +define void @foo() {
>> +; X86-NOGOT-EQUIV-LABEL: _foo:
>> +; X86-NOGOT-EQUIV: leaq  _b(%rip), %rax
>> +  store i8** @b, i8*** null
>> +  ret void
>> +}
>>  @a = external global i8
>>  @b = internal unnamed_addr constant i8* @a
>>
>> -; X86-LABEL: _c:
>> -; X86:   .quad _b
>> +; X86-NOGOT-EQUIV-LABEL: _c:
>> +; X86-NOGOT-EQUIV:   .quad _b
>>  @c = global i8** @b
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc



More information about the llvm-commits mailing list