[llvm] r257275 - [WinEH] Fix catchpad pred verification

Joseph Tremoulet via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 9 20:32:04 PST 2016


Author: josepht
Date: Sat Jan  9 22:32:03 2016
New Revision: 257275

URL: http://llvm.org/viewvc/llvm-project?rev=257275&view=rev
Log:
[WinEH] Fix catchpad pred verification

Summary:
The code was simply ensuring that the catchpad's pred is its catchswitch,
which was letting cases slip through where the flow edge was the unwind
edge of the catchswitch rather than one of its catch clauses.

Reviewers: andrew.w.kaylor, rnk, majnemer

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D16011

Modified:
    llvm/trunk/lib/IR/Verifier.cpp
    llvm/trunk/test/Verifier/invalid-eh.ll

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=257275&r1=257274&r2=257275&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Sat Jan  9 22:32:03 2016
@@ -2996,6 +2996,9 @@ void Verifier::visitEHPadPredecessors(In
              "Block containg CatchPadInst must be jumped to "
              "only by its catchswitch.",
              CPI);
+    Assert(BB != CPI->getCatchSwitch()->getUnwindDest(),
+           "Catchswitch cannot unwind to one of its catchpads",
+           CPI->getCatchSwitch(), CPI);
     return;
   }
 

Modified: llvm/trunk/test/Verifier/invalid-eh.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/invalid-eh.ll?rev=257275&r1=257274&r2=257275&view=diff
==============================================================================
--- llvm/trunk/test/Verifier/invalid-eh.ll (original)
+++ llvm/trunk/test/Verifier/invalid-eh.ll Sat Jan  9 22:32:03 2016
@@ -17,6 +17,8 @@
 ; RUN: sed -e s/.T17:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK17 %s
 ; RUN: sed -e s/.T18:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK18 %s
 ; RUN: sed -e s/.T19:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK19 %s
+; RUN: sed -e s/.T20:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK20 %s
+; RUN: sed -e s/.T21:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK21 %s
 
 declare void @g()
 
@@ -339,3 +341,32 @@ declare void @g()
 ;T19:   unreachable:
 ;T19:     unreachable
 ;T19: }
+
+;T20: define void @f() personality void ()* @g {
+;T20:   entry:
+;T20:     ret void
+;T20:   switch:
+;T20:     %cs = catchswitch within none [label %catch] unwind label %catch
+;T20:     ; CHECK20: Catchswitch cannot unwind to one of its catchpads
+;T20:     ; CHECK20-NEXT: %cs = catchswitch within none [label %catch] unwind label %catch
+;T20:     ; CHECK20-NEXT: %cp = catchpad within %cs [i32 4]
+;T20:   catch:
+;T20:     %cp = catchpad within %cs [i32 4]
+;T20:     unreachable
+;T20: }
+
+;T21: define void @f() personality void ()* @g {
+;T21:   entry:
+;T21:     ret void
+;T21:   switch:
+;T21:     %cs = catchswitch within none [label %catch1] unwind label %catch2
+;T21:     ; CHECK21: Catchswitch cannot unwind to one of its catchpads
+;T21:     ; CHECK21-NEXT: %cs = catchswitch within none [label %catch1] unwind label %catch2
+;T21:     ; CHECK21-NEXT: %cp2 = catchpad within %cs [i32 2]
+;T21:   catch1:
+;T21:     %cp1 = catchpad within %cs [i32 1]
+;T21:     unreachable
+;T21:   catch2:
+;T21:     %cp2 = catchpad within %cs [i32 2]
+;T21:     unreachable
+;T21: }




More information about the llvm-commits mailing list