[llvm] [LTT] Mark as unkown weak function tests. (PR #167399)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 17 10:02:15 PST 2025
https://github.com/mtrofin updated https://github.com/llvm/llvm-project/pull/167399
>From b4835b483e296dc22786cf3addea8e7ec4cc62a7 Mon Sep 17 00:00:00 2001
From: Mircea Trofin <mtrofin at google.com>
Date: Mon, 10 Nov 2025 12:33:12 -0800
Subject: [PATCH] [LTT] Mark as unkown weak function tests.
---
llvm/lib/Transforms/IPO/LowerTypeTests.cpp | 3 +++
llvm/test/Transforms/LowerTypeTests/function-weak.ll | 5 +++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index 94663ff928a0b..fa35eef2c00f5 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1469,6 +1469,9 @@ void LowerTypeTestsModule::replaceWeakDeclarationWithJumpTablePtr(
Constant::getNullValue(F->getType()));
Value *Select = Builder.CreateSelect(ICmp, JT,
Constant::getNullValue(F->getType()));
+
+ if (auto *SI = dyn_cast<SelectInst>(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
More information about the llvm-commits
mailing list