-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[LTT] Mark as unkown weak function tests. #167399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: users/mtrofin/11-07-_ltt_profcheck_set_branch_weights_for_complex_llvm.type.test_lowering
Are you sure you want to change the base?
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
| Constant::getNullValue(F->getType())); | ||
|
|
||
| if (auto *SI = dyn_cast<SelectInst>(Select)) | ||
| setExplicitlyUnknownBranchWeightsIfProfiled(*SI, DEBUG_TYPE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pcc a question - would it be technically possible to propagate information about the weak function from [thin]link over to this point, and thus know if we even need a select in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just add a TODO to consider that.
|
@llvm/pr-subscribers-llvm-transforms Author: Mircea Trofin (mtrofin) ChangesFull diff: https://github.com/llvm/llvm-project/pull/167399.diff 2 Files Affected:
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index 961a2ba2f58e5..6c5045f7c84ff 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1494,6 +1494,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
|
0c5994b to
660888e
Compare
a6bc19f to
2bc1823
Compare
660888e to
473fd29
Compare
473fd29 to
e7a9788
Compare
2bc1823 to
9a54c8d
Compare
teresajohnson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
| Constant::getNullValue(F->getType())); | ||
|
|
||
| if (auto *SI = dyn_cast<SelectInst>(Select)) | ||
| setExplicitlyUnknownBranchWeightsIfProfiled(*SI, DEBUG_TYPE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just add a TODO to consider that.

We don't have enough information to infer the probability of a weak function pointer being nullptr or not (open question if we could propagate this from the linker)
Issue #147390