[llvm] r242840 - [AsmPrinter] Check for valid constants in handleIndirectSymViaGOTPCRel
Bruno Cardoso Lopes
bruno.cardoso at gmail.com
Tue Jul 21 14:45:42 PDT 2015
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
More information about the llvm-commits
mailing list