Index: lib/Transforms/Utils/Local.cpp =================================================================== --- lib/Transforms/Utils/Local.cpp +++ lib/Transforms/Utils/Local.cpp @@ -1431,6 +1431,7 @@ NewCall->setCallingConv(II->getCallingConv()); NewCall->setAttributes(II->getAttributes()); NewCall->setDebugLoc(II->getDebugLoc()); + NewCall->copyMetadata(*II); II->replaceAllUsesWith(NewCall); // Follow the call by a branch to the normal destination. Index: test/Transforms/SimplifyCFG/invoke_unwind.ll =================================================================== --- test/Transforms/SimplifyCFG/invoke_unwind.ll +++ test/Transforms/SimplifyCFG/invoke_unwind.ll @@ -72,4 +72,21 @@ br label %rethrow } +declare i32 @test4_dummy_callee() + +; This testcase checks to see if the simplifycfg pass converting invoke +; instructions preserves metadata. +define i32 @test4() personality i32 (...)* @__gxx_personality_v0 { +; CHECK-LABEL: @test4( +; CHECK-NEXT: call i32 @test4_dummy_callee(), !range !0, !test4_metadata !1 +; CHECK-NEXT: ret i32 %result + %result = invoke i32 @test4_dummy_callee( ) + to label %1 unwind label %Rethrow, !range !{i32 1, i32 10}, !test4_metadata !{i32 -1} + ret i32 %result +Rethrow: + %exn = landingpad {i8*, i32} + catch i8* null + resume { i8*, i32 } %exn +} + declare i32 @__gxx_personality_v0(...)