[PATCH] D25178: [CodeGen] Don't assume that a landing pad exists in setMustKeepGlobalVariables

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 5 13:46:14 PDT 2016


mstorsjo updated this revision to Diff 73692.
mstorsjo added a comment.

Added a test based on the pretty minimal IR that shows the issue.


https://reviews.llvm.org/D25178

Files:
  lib/CodeGen/GlobalMerge.cpp
  test/CodeGen/ARM/Windows/exceptions-opt.ll


Index: test/CodeGen/ARM/Windows/exceptions-opt.ll
===================================================================
--- /dev/null
+++ test/CodeGen/ARM/Windows/exceptions-opt.ll
@@ -0,0 +1,28 @@
+; RUN: llc -mtriple thumbv7--windows-msvc -o - %s | FileCheck %s
+
+%struct.B = type { i8 }
+
+@"\01?x@@3UB@@A" = global %struct.B zeroinitializer, align 1
+ at llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_exceptions.cpp, i8* null }]
+
+declare arm_aapcs_vfpcc void @"\01?f at B@@QAAXXZ"(%struct.B*) local_unnamed_addr #0
+
+declare arm_aapcs_vfpcc i32 @__CxxFrameHandler3(...)
+
+define internal arm_aapcs_vfpcc void @_GLOBAL__sub_I_exceptions.cpp() #1 personality i32 (...)* @__CxxFrameHandler3 {
+  invoke arm_aapcs_vfpcc void @"\01?f at B@@QAAXXZ"(%struct.B* nonnull @"\01?x@@3UB@@A")
+          to label %5 unwind label %1
+
+; <label>:1:                                      ; preds = %0
+  %2 = catchswitch within none [label %3] unwind to caller
+
+; <label>:3:                                      ; preds = %1
+  %4 = catchpad within %2 [i8* null, i32 64, i8* null]
+  catchret from %4 to label %5
+
+; <label>:5:                                      ; preds = %0, %3
+  ret void
+}
+
+; Only check that building this doesn't crash.
+; CHECK-LABEL: exceptions
Index: lib/CodeGen/GlobalMerge.cpp
===================================================================
--- lib/CodeGen/GlobalMerge.cpp
+++ lib/CodeGen/GlobalMerge.cpp
@@ -511,6 +511,7 @@
       if (!II) continue;
 
       const LandingPadInst *LPInst = II->getUnwindDest()->getLandingPadInst();
+      if (!LPInst) continue;
       // Look for globals in the clauses of the landing pad instruction
       for (unsigned Idx = 0, NumClauses = LPInst->getNumClauses();
            Idx != NumClauses; ++Idx)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25178.73692.patch
Type: text/x-patch
Size: 1845 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161005/af1a23c0/attachment.bin>


More information about the llvm-commits mailing list