diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1985,6 +1985,11 @@ NewCall->setAttributes(II->getAttributes()); NewCall->setDebugLoc(II->getDebugLoc()); NewCall->copyMetadata(*II); + + // If the invoke had profile metadata, drop it. + if (NewCall->hasMetadata(LLVMContext::MD_prof)) + NewCall->setMetadata(LLVMContext::MD_prof, nullptr); + return NewCall; } diff --git a/llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll b/llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll --- a/llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll +++ b/llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll @@ -7,9 +7,10 @@ define i32 @test1() personality i32 (...)* @__gxx_personality_v0 { ; CHECK-LABEL: @test1( ; CHECK-NEXT: call void @bar() +; CHECK-NOT: !prof ; CHECK-NEXT: ret i32 0 invoke void @bar( ) - to label %1 unwind label %Rethrow + to label %1 unwind label %Rethrow, !prof !0 ret i32 0 Rethrow: %exn = landingpad {i8*, i32} @@ -17,6 +18,8 @@ resume { i8*, i32 } %exn } +!0 = !{!"branch_weights", i32 369, i32 0} + define i32 @test2() personality i32 (...)* @__gxx_personality_v0 { ; CHECK-LABEL: @test2( ; CHECK-NEXT: call void @bar() [ "foo"(i32 100) ]