diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp index 31b5487ce6ec6..7b046978802db 100644 --- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp +++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp @@ -1493,6 +1493,9 @@ void LowerTypeTestsModule::replaceWeakDeclarationWithJumpTablePtr( Constant::getNullValue(F->getType())); Value *Select = Builder.CreateSelect(ICmp, JT, Constant::getNullValue(F->getType())); + + if (auto *SI = dyn_cast(Select)) + setExplicitlyUnknownBranchWeightsIfProfiled(*SI, DEBUG_TYPE); // For phi nodes, we need to update the incoming value for all operands // with the same predecessor. if (PN) diff --git a/llvm/test/Transforms/LowerTypeTests/function-weak.ll b/llvm/test/Transforms/LowerTypeTests/function-weak.ll index 4ea03b6c2c1fa..dbbe8fa4a0a9a 100644 --- a/llvm/test/Transforms/LowerTypeTests/function-weak.ll +++ b/llvm/test/Transforms/LowerTypeTests/function-weak.ll @@ -32,10 +32,10 @@ target triple = "x86_64-unknown-linux-gnu" declare !type !0 extern_weak void @f() ; CHECK: define zeroext i1 @check_f() -define zeroext i1 @check_f() { +define zeroext i1 @check_f() !prof !{!"function_entry_count", i32 10} { entry: ; CHECK: [[CMP:%.*]] = icmp ne ptr @f, null -; CHECK: [[SEL:%.*]] = select i1 [[CMP]], ptr @[[JT:.*]], ptr null +; CHECK: [[SEL:%.*]] = select i1 [[CMP]], ptr @[[JT:.*]], ptr null, !prof ![[SELPROF:[0-9]+]] ; CHECK: [[PTI:%.*]] = ptrtoint ptr [[SEL]] to i1 ; CHECK: ret i1 [[PTI]] ret i1 ptrtoint (ptr @f to i1) @@ -165,3 +165,4 @@ define i1 @foo(ptr %p) { ; CHECK-NEXT: } !0 = !{i32 0, !"typeid1"} +; CHECK: ![[SELPROF]] = !{!"unknown", !"lowertypetests"} \ No newline at end of file