| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- ; RUN: opt -lint -disable-output < %s 2>&1 | FileCheck %s
- ; This test is meant to prove that the Verifier is able to identify a variety
- ; of errors with the llvm.eh.begincatch and llvm.eh.endcatch intrinsics.
- ; See cppeh-catch-intrinsics-clean for correct uses.
- target triple = "x86_64-pc-windows-msvc"
- declare void @llvm.eh.begincatch(i8*, i8*)
- declare void @llvm.eh.endcatch()
- @_ZTIi = external constant i8*
- ; Function Attrs: uwtable
- define void @test_missing_endcatch() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
- ; CHECK: Some paths from llvm.eh.begincatch may not reach llvm.eh.endcatch
- ; CHECK-NEXT: call void @llvm.eh.begincatch(i8* %exn, i8* null)
- entry:
- invoke void @_Z9may_throwv()
- to label %try.cont unwind label %lpad
- lpad: ; preds = %entry
- %0 = landingpad { i8*, i32 }
- catch i8* bitcast (i8** @_ZTIi to i8*)
- %exn = extractvalue { i8*, i32 } %0, 0
- %sel = extractvalue { i8*, i32 } %0, 1
- %1 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
- %matches = icmp eq i32 %sel, %1
- br i1 %matches, label %catch, label %eh.resume
- catch: ; preds = %lpad
- call void @llvm.eh.begincatch(i8* %exn, i8* null)
- call void @_Z10handle_intv()
- br label %invoke.cont2
- invoke.cont2: ; preds = %catch
- br label %try.cont
- try.cont: ; preds = %invoke.cont2, %entry
- ret void
- eh.resume: ; preds = %catch.dispatch
- resume { i8*, i32 } %0
- }
- ; Function Attrs: uwtable
- define void @test_missing_begincatch() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
- ; CHECK: llvm.eh.endcatch may be reachable without passing llvm.eh.begincatch
- ; CHECK-NEXT: call void @llvm.eh.endcatch()
- entry:
- invoke void @_Z9may_throwv()
- to label %try.cont unwind label %lpad
- lpad: ; preds = %entry
- %0 = landingpad { i8*, i32 }
- catch i8* bitcast (i8** @_ZTIi to i8*)
- %exn = extractvalue { i8*, i32 } %0, 0
- %sel = extractvalue { i8*, i32 } %0, 1
- %1 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
- %matches = icmp eq i32 %sel, %1
- br i1 %matches, label %catch, label %eh.resume
- catch: ; preds = %lpad
- call void @_Z10handle_intv()
- br label %invoke.cont2
- invoke.cont2: ; preds = %catch
- call void @llvm.eh.endcatch()
- br label %try.cont
- try.cont: ; preds = %invoke.cont2, %entry
- ret void
- eh.resume: ; preds = %catch.dispatch
- resume { i8*, i32 } %0
- }
- ; Function Attrs: uwtable
- define void @test_multiple_begin() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
- ; CHECK: llvm.eh.begincatch may be called a second time before llvm.eh.endcatch
- ; CHECK-NEXT: call void @llvm.eh.begincatch(i8* %exn, i8* null)
- ; CHECK-NEXT: call void @llvm.eh.begincatch(i8* %exn, i8* null)
- entry:
- invoke void @_Z9may_throwv()
- to label %try.cont unwind label %lpad
- lpad: ; preds = %entry
- %0 = landingpad { i8*, i32 }
- catch i8* bitcast (i8** @_ZTIi to i8*)
- %exn = extractvalue { i8*, i32 } %0, 0
- %sel = extractvalue { i8*, i32 } %0, 1
- %1 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
- %matches = icmp eq i32 %sel, %1
- br i1 %matches, label %catch, label %eh.resume
- catch: ; preds = %lpad
- call void @llvm.eh.begincatch(i8* %exn, i8* null)
- call void @_Z10handle_intv()
- br label %invoke.cont2
- invoke.cont2: ; preds = %catch
- call void @llvm.eh.begincatch(i8* %exn, i8* null)
- call void @llvm.eh.endcatch()
- br label %try.cont
- try.cont: ; preds = %invoke.cont2, %entry
- ret void
- eh.resume: ; preds = %catch.dispatch
- resume { i8*, i32 } %0
- }
- ; Function Attrs: uwtable
- define void @test_multiple_end() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
- ; CHECK: llvm.eh.endcatch may be called a second time after llvm.eh.begincatch
- ; CHECK-NEXT: call void @llvm.eh.endcatch()
- ; CHECK-NEXT: call void @llvm.eh.endcatch()
- entry:
- invoke void @_Z9may_throwv()
- to label %try.cont unwind label %lpad
- lpad: ; preds = %entry
- %0 = landingpad { i8*, i32 }
- catch i8* bitcast (i8** @_ZTIi to i8*)
- %exn = extractvalue { i8*, i32 } %0, 0
- %sel = extractvalue { i8*, i32 } %0, 1
- %1 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
- %matches = icmp eq i32 %sel, %1
- br i1 %matches, label %catch, label %eh.resume
- catch: ; preds = %lpad
- call void @llvm.eh.begincatch(i8* %exn, i8* null)
- call void @_Z10handle_intv()
- call void @llvm.eh.endcatch()
- br label %invoke.cont2
- invoke.cont2: ; preds = %catch
- call void @llvm.eh.endcatch()
- br label %try.cont
- try.cont: ; preds = %invoke.cont2, %entry
- ret void
- eh.resume: ; preds = %catch.dispatch
- resume { i8*, i32 } %0
- }
- ; Function Attrs: uwtable
- define void @test_begincatch_without_lpad() {
- ; CHECK: llvm.eh.begincatch may be reachable without passing a landingpad
- ; CHECK-NEXT: call void @llvm.eh.begincatch(i8* %exn, i8* null)
- entry:
- %exn = alloca i8
- call void @llvm.eh.begincatch(i8* %exn, i8* null)
- call void @_Z10handle_intv()
- br label %invoke.cont2
- invoke.cont2: ; preds = %catch
- call void @llvm.eh.endcatch()
- br label %try.cont
- try.cont: ; preds = %invoke.cont2, %entry
- ret void
- }
- ; Function Attrs: uwtable
- define void @test_branch_to_begincatch_with_no_lpad(i32 %fake.sel) personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
- ; CHECK: llvm.eh.begincatch may be reachable without passing a landingpad
- ; CHECK-NEXT: call void @llvm.eh.begincatch(i8* %exn2, i8* null)
- entry:
- %fake.exn = alloca i8
- invoke void @_Z9may_throwv()
- to label %catch unwind label %lpad
- lpad: ; preds = %entry
- %0 = landingpad { i8*, i32 }
- catch i8* bitcast (i8** @_ZTIi to i8*)
- %exn = extractvalue { i8*, i32 } %0, 0
- %sel = extractvalue { i8*, i32 } %0, 1
- %1 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
- %matches = icmp eq i32 %sel, %1
- br i1 %matches, label %catch, label %eh.resume
- invoke void @_Z9may_throwv()
- to label %try.cont unwind label %lpad
- catch: ; preds = %lpad, %entry
- %exn2 = phi i8* [%exn, %lpad], [%fake.exn, %entry]
- %sel2 = phi i32 [%sel, %lpad], [%fake.sel, %entry]
- call void @llvm.eh.begincatch(i8* %exn2, i8* null)
- call void @_Z10handle_intv()
- %matches1 = icmp eq i32 %sel2, 0
- br i1 %matches1, label %invoke.cont2, label %invoke.cont3
- invoke.cont2: ; preds = %catch
- call void @llvm.eh.endcatch()
- br label %try.cont
- invoke.cont3: ; preds = %catch
- call void @llvm.eh.endcatch()
- br label %eh.resume
- try.cont: ; preds = %invoke.cont2
- ret void
- eh.resume: ; preds = %catch.dispatch
- %lpad.val = insertvalue { i8*, i32 } undef, i32 0, 1
- resume { i8*, i32 } %lpad.val
- }
- ; Function Attrs: uwtable
- define void @test_branch_missing_endcatch() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
- ; CHECK: Some paths from llvm.eh.begincatch may not reach llvm.eh.endcatch
- ; CHECK-NEXT: call void @llvm.eh.begincatch(i8* %exn2, i8* null)
- entry:
- invoke void @_Z9may_throwv()
- to label %invoke.cont unwind label %lpad
- invoke.cont:
- invoke void @_Z9may_throwv()
- to label %invoke.cont unwind label %lpad1
- lpad: ; preds = %entry
- %0 = landingpad { i8*, i32 }
- catch i8* bitcast (i8** @_ZTIi to i8*)
- %exn = extractvalue { i8*, i32 } %0, 0
- %sel = extractvalue { i8*, i32 } %0, 1
- %1 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
- %matches = icmp eq i32 %sel, %1
- br i1 %matches, label %catch, label %eh.resume
- invoke void @_Z9may_throwv()
- to label %try.cont unwind label %lpad
- lpad1: ; preds = %entry
- %l1.0 = landingpad { i8*, i32 }
- cleanup
- catch i8* bitcast (i8** @_ZTIi to i8*)
- %exn1 = extractvalue { i8*, i32 } %l1.0, 0
- %sel1 = extractvalue { i8*, i32 } %l1.0, 1
- %l1.1 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
- %matchesl1 = icmp eq i32 %sel1, %l1.1
- br i1 %matchesl1, label %catch, label %eh.resume
- catch: ; preds = %lpad, %lpad1
- %exn2 = phi i8* [%exn, %lpad], [%exn1, %lpad1]
- %sel2 = phi i32 [%sel, %lpad], [%sel1, %lpad1]
- call void @llvm.eh.begincatch(i8* %exn2, i8* null)
- call void @_Z10handle_intv()
- %matches1 = icmp eq i32 %sel2, 0
- br i1 %matches1, label %invoke.cont2, label %invoke.cont3
- invoke.cont2: ; preds = %catch
- call void @llvm.eh.endcatch()
- br label %try.cont
- invoke.cont3: ; preds = %catch
- br label %eh.resume
- try.cont: ; preds = %invoke.cont2, %entry
- ret void
- eh.resume: ; preds = %catch.dispatch
- %lpad.val = insertvalue { i8*, i32 } undef, i32 0, 1
- resume { i8*, i32 } %lpad.val
- }
- declare void @_Z9may_throwv()
- declare i32 @__CxxFrameHandler3(...)
- ; Function Attrs: nounwind readnone
- declare i32 @llvm.eh.typeid.for(i8*)
- declare void @_Z10handle_intv()
|