diff options
author | Reid Kleckner <reid@kleckner.net> | 2015-03-09 22:45:16 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2015-03-09 22:45:16 +0000 |
commit | 4c27f8d49ee8755c9083a6313090d7afd0dda5cf (patch) | |
tree | 4257c49e7c27fee4d9d57702f10aa08bc9136baf /test/CodeGen/X86/dwarf-eh-prepare.ll | |
parent | 9e065f52fcf0c77f7375f7f354069684de56e6d4 (diff) |
Reland r229944: EH: Prune unreachable resume instructions during Dwarf EH preparation
Fix the double-deletion of AnalysisResolver when delegating through to
Dwarf EH preparation by creating one from scratch. Hopefully the new
pass manager simplifies this.
This reverts commit r229952.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231719 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86/dwarf-eh-prepare.ll')
-rw-r--r-- | test/CodeGen/X86/dwarf-eh-prepare.ll | 115 |
1 files changed, 111 insertions, 4 deletions
diff --git a/test/CodeGen/X86/dwarf-eh-prepare.ll b/test/CodeGen/X86/dwarf-eh-prepare.ll index a3a70da866c..25572d868da 100644 --- a/test/CodeGen/X86/dwarf-eh-prepare.ll +++ b/test/CodeGen/X86/dwarf-eh-prepare.ll @@ -7,12 +7,13 @@ @int_typeinfo = global i8 0 declare void @might_throw() +declare void @cleanup() -define i32 @simple_catch() { +define i32 @simple_cleanup_catch() { invoke void @might_throw() to label %cont unwind label %lpad -; CHECK: define i32 @simple_catch() +; CHECK-LABEL: define i32 @simple_cleanup_catch() ; CHECK: invoke void @might_throw() cont: @@ -22,15 +23,18 @@ cont: lpad: %ehvals = landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0 + cleanup catch i8* @int_typeinfo %ehptr = extractvalue { i8*, i32 } %ehvals, 0 %ehsel = extractvalue { i8*, i32 } %ehvals, 1 + call void @cleanup() %int_sel = call i32 @llvm.eh.typeid.for(i8* @int_typeinfo) %int_match = icmp eq i32 %ehsel, %int_sel br i1 %int_match, label %catch_int, label %eh.resume ; CHECK: lpad: ; CHECK: landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0 +; CHECK: call void @cleanup() ; CHECK: call i32 @llvm.eh.typeid.for ; CHECK: br i1 @@ -41,11 +45,114 @@ catch_int: ; CHECK: ret i32 1 eh.resume: - resume { i8*, i32 } %ehvals + %tmp_ehvals = insertvalue { i8*, i32 } undef, i8* %ehptr, 0 + %new_ehvals = insertvalue { i8*, i32 } %tmp_ehvals, i32 %ehsel, 1 + resume { i8*, i32 } %new_ehvals ; CHECK: eh.resume: -; CHECK: call void @_Unwind_Resume(i8* %{{.*}}) +; CHECK-NEXT: call void @_Unwind_Resume(i8* %ehptr) } + +define i32 @catch_no_resume() { + invoke void @might_throw() + to label %cont unwind label %lpad + +cont: + ret i32 0 + +lpad: + %ehvals = landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0 + catch i8* @int_typeinfo + %ehptr = extractvalue { i8*, i32 } %ehvals, 0 + %ehsel = extractvalue { i8*, i32 } %ehvals, 1 + %int_sel = call i32 @llvm.eh.typeid.for(i8* @int_typeinfo) + %int_match = icmp eq i32 %ehsel, %int_sel + br i1 %int_match, label %catch_int, label %eh.resume + +catch_int: + ret i32 1 + +eh.resume: + %tmp_ehvals = insertvalue { i8*, i32 } undef, i8* %ehptr, 0 + %new_ehvals = insertvalue { i8*, i32 } %tmp_ehvals, i32 %ehsel, 1 + resume { i8*, i32 } %new_ehvals +} + +; Check that we can prune the unreachable resume instruction. + +; CHECK-LABEL: define i32 @catch_no_resume() { +; CHECK: invoke void @might_throw() +; CHECK: ret i32 0 +; CHECK: lpad: +; CHECK: landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0 +; CHECK-NOT: br i1 +; CHECK: ret i32 1 +; CHECK-NOT: call void @_Unwind_Resume +; CHECK: {{^[}]}} + + +define i32 @catch_cleanup_merge() { + invoke void @might_throw() + to label %inner_invoke unwind label %outer_lpad +inner_invoke: + invoke void @might_throw() + to label %cont unwind label %inner_lpad +cont: + ret i32 0 + +outer_lpad: + %ehvals1 = landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0 + catch i8* @int_typeinfo + br label %catch.dispatch + +inner_lpad: + %ehvals2 = landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0 + cleanup + catch i8* @int_typeinfo + call void @cleanup() + br label %catch.dispatch + +catch.dispatch: + %ehvals = phi { i8*, i32 } [ %ehvals1, %outer_lpad ], [ %ehvals2, %inner_lpad ] + %ehptr = extractvalue { i8*, i32 } %ehvals, 0 + %ehsel = extractvalue { i8*, i32 } %ehvals, 1 + %int_sel = call i32 @llvm.eh.typeid.for(i8* @int_typeinfo) + %int_match = icmp eq i32 %ehsel, %int_sel + br i1 %int_match, label %catch_int, label %eh.resume + +catch_int: + ret i32 1 + +eh.resume: + %tmp_ehvals = insertvalue { i8*, i32 } undef, i8* %ehptr, 0 + %new_ehvals = insertvalue { i8*, i32 } %tmp_ehvals, i32 %ehsel, 1 + resume { i8*, i32 } %new_ehvals +} + +; We can't prune this merge because one landingpad is a cleanup pad. + +; CHECK-LABEL: define i32 @catch_cleanup_merge() +; CHECK: invoke void @might_throw() +; CHECK: invoke void @might_throw() +; CHECK: ret i32 0 +; +; CHECK: outer_lpad: +; CHECK: landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0 +; CHECK: br label %catch.dispatch +; +; CHECK: inner_lpad: +; CHECK: landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0 +; CHECK: call void @cleanup() +; CHECK: br label %catch.dispatch +; +; CHECK: catch.dispatch: +; CHECK: call i32 @llvm.eh.typeid.for +; CHECK: br i1 +; CHECK: catch_int: +; CHECK: ret i32 1 +; CHECK: eh.resume: +; CHECK-NEXT: call void @_Unwind_Resume(i8* %ehptr) + declare i32 @__gxx_personality_v0(...) declare i32 @llvm.eh.typeid.for(i8*) |