[llvm] r256690 - [WinEH] Tighten parentPad verifier checks

Joseph Tremoulet via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 2 07:24:24 PST 2016


Author: josepht
Date: Sat Jan  2 09:24:24 2016
New Revision: 256690

URL: http://llvm.org/viewvc/llvm-project?rev=256690&view=rev
Log:
[WinEH] Tighten parentPad verifier checks

Summary: A catchswitch cannot be a parent of a cleanuppad or another catchswitch.

Reviewers: rnk, andrew.w.kaylor, majnemer

Subscribers: llvm-commits

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

Modified:
    llvm/trunk/lib/IR/Verifier.cpp
    llvm/trunk/test/Bitcode/compatibility.ll
    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=256690&r1=256689&r2=256690&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Sat Jan  2 09:24:24 2016
@@ -3019,8 +3019,7 @@ void Verifier::visitCleanupPadInst(Clean
          &CPI);
 
   auto *ParentPad = CPI.getParentPad();
-  Assert(isa<CatchSwitchInst>(ParentPad) || isa<ConstantTokenNone>(ParentPad) ||
-             isa<CleanupPadInst>(ParentPad) || isa<CatchPadInst>(ParentPad),
+  Assert(isa<ConstantTokenNone>(ParentPad) || isa<FuncletPadInst>(ParentPad),
          "CleanupPadInst has an invalid parent.", &CPI);
 
   User *FirstUser = nullptr;
@@ -3077,8 +3076,7 @@ void Verifier::visitCatchSwitchInst(Catc
   }
 
   auto *ParentPad = CatchSwitch.getParentPad();
-  Assert(isa<CatchSwitchInst>(ParentPad) || isa<ConstantTokenNone>(ParentPad) ||
-             isa<CleanupPadInst>(ParentPad) || isa<CatchPadInst>(ParentPad),
+  Assert(isa<ConstantTokenNone>(ParentPad) || isa<FuncletPadInst>(ParentPad),
          "CatchSwitchInst has an invalid parent.", ParentPad);
 
   visitTerminatorInst(CatchSwitch);

Modified: llvm/trunk/test/Bitcode/compatibility.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/compatibility.ll?rev=256690&r1=256689&r2=256690&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/compatibility.ll (original)
+++ llvm/trunk/test/Bitcode/compatibility.ll Sat Jan  2 09:24:24 2016
@@ -859,17 +859,23 @@ catchpad:
   ; CHECK-NEXT: br label %body
 
 body:
-  invoke void @f.ccc() to label %continue unwind label %terminate
+  invoke void @f.ccc() to label %continue unwind label %terminate.inner
   catchret from %catch to label %return
   ; CHECK: catchret from %catch to label %return
 
 return:
   ret i32 0
 
+terminate.inner:
+  cleanuppad within %catch []
+  unreachable
+  ; CHECK: cleanuppad within %catch []
+  ; CHECK-NEXT: unreachable
+
 terminate:
-  cleanuppad within %cs []
+  cleanuppad within none []
   unreachable
-  ; CHECK: cleanuppad within %cs []
+  ; CHECK: cleanuppad within none []
   ; CHECK-NEXT: unreachable
 
 continue:

Modified: llvm/trunk/test/Verifier/invalid-eh.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/invalid-eh.ll?rev=256690&r1=256689&r2=256690&view=diff
==============================================================================
--- llvm/trunk/test/Verifier/invalid-eh.ll (original)
+++ llvm/trunk/test/Verifier/invalid-eh.ll Sat Jan  2 09:24:24 2016
@@ -2,6 +2,11 @@
 ; RUN: sed -e s/.T2:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK2 %s
 ; RUN: sed -e s/.T3:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK3 %s
 ; RUN: sed -e s/.T4:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK4 %s
+; RUN: sed -e s/.T5:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK5 %s
+; RUN: sed -e s/.T6:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK6 %s
+; RUN: sed -e s/.T7:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK7 %s
+
+declare void @g()
 
 ;T1: define void @f() {
 ;T1:   entry:
@@ -36,3 +41,49 @@
 ;T4:     cleanupret from %x unwind to caller
 ;T4:     ; CHECK4: CleanupReturnInst needs to be provided a CleanupPad
 ;T4: }
+
+;T5: define void @f() personality void ()* @g {
+;T5:   entry:
+;T5:     ret void
+;T5:   switch:
+;T5:     %cs = catchswitch within none [label %catch] unwind to caller
+;T5:   catch:
+;T5:     catchpad within %cs []
+;T5:     unreachable
+;T5:   bogus:
+;T5:     cleanuppad within %cs []
+;T5:     ; CHECK5: CleanupPadInst has an invalid parent
+;T5:     unreachable
+;T5: }
+
+;T6: define void @f() personality void ()* @g {
+;T6:   entry:
+;T6:     ret void
+;T6:   switch1:
+;T6:     %cs1 = catchswitch within none [label %catch1] unwind label %catch2
+;T6:     ; CHECK6: Block containg CatchPadInst must be jumped to only by its catchswitch
+;T6:   catch1:
+;T6:     catchpad within %cs1 []
+;T6:     unreachable
+;T6:   switch2:
+;T6:     %cs2 = catchswitch within none [label %catch2] unwind to caller
+;T6:   catch2:
+;T6:     catchpad within %cs2 []
+;T6:     unreachable
+;T6: }
+
+;T7: define void @f() personality void ()* @g {
+;T7:   entry:
+;T7:     ret void
+;T7:   switch1:
+;T7:     %cs1 = catchswitch within none [label %catch1] unwind to caller
+;T7:   catch1:
+;T7:     catchpad within %cs1 []
+;T7:     unreachable
+;T7:   switch2:
+;T7:     %cs2 = catchswitch within %cs1 [label %catch2] unwind to caller
+;T7:     ; CHECK7: CatchSwitchInst has an invalid parent
+;T7:   catch2:
+;T7:     catchpad within %cs2 []
+;T7:     unreachable
+;T7: }




More information about the llvm-commits mailing list