-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[profcheck] Disable verification of selects on vector conditions. #167973
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,9 +102,11 @@ bool ProfileInjector::inject() { | |
| for (auto &BB : F) { | ||
| if (AnnotateSelect) { | ||
| for (auto &I : BB) { | ||
| if (isa<SelectInst>(I) && !I.getMetadata(LLVMContext::MD_prof)) | ||
| setBranchWeights(I, {SelectTrueWeight, SelectFalseWeight}, | ||
| /*IsExpected=*/false); | ||
| if (auto *SI = dyn_cast<SelectInst>(&I)) | ||
| if (!SI->getCondition()->getType()->isVectorTy() && | ||
| !I.getMetadata(LLVMContext::MD_prof)) | ||
| setBranchWeights(I, {SelectTrueWeight, SelectFalseWeight}, | ||
| /*IsExpected=*/false); | ||
| } | ||
| } | ||
| auto *Term = getTerminatorBenefitingFromMDProf(BB); | ||
|
|
@@ -185,9 +187,11 @@ PreservedAnalyses ProfileVerifierPass::run(Function &F, | |
| for (const auto &BB : F) { | ||
| if (AnnotateSelect) { | ||
| for (const auto &I : BB) | ||
| if (isa<SelectInst>(I) && !I.getMetadata(LLVMContext::MD_prof)) | ||
| F.getContext().emitError( | ||
| "Profile verification failed: select annotation missing"); | ||
| if (auto *SI = dyn_cast<SelectInst>(&I)) | ||
| if (!SI->getCondition()->getType()->isVectorTy() && | ||
| !I.getMetadata(LLVMContext::MD_prof)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
| F.getContext().emitError( | ||
| "Profile verification failed: select annotation missing"); | ||
| } | ||
| if (const auto *Term = | ||
| ProfileInjector::getTerminatorBenefitingFromMDProf(BB)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,11 @@ | |
| ; RUN: not opt -passes=prof-verify %t/verify-missing.ll 2>&1 | FileCheck %t/verify-missing.ll | ||
|
|
||
| ; verify we can disable it. It's sufficient to see opt not failing. | ||
| ; RUN: opt -passes=prof-verify -profcheck-annotate-select=0 %t/verify-missing.ll | ||
| ; RUN: opt -passes=prof-verify -profcheck-annotate-select=0 --disable-output %t/verify-missing.ll | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we disabling output? It should just go nowhere.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when you run the lit test at the command line, it gets printed out. |
||
|
|
||
| ; verify vector selects without profiles are OK. It's sufficient opt doesn't fail. | ||
| ; RUN: opt -passes=prof-verify --disable-output %t/verify-vec.ll | ||
|
|
||
|
|
||
| ;--- inject.ll | ||
| declare void @foo(i32 %a); | ||
|
|
@@ -24,8 +28,16 @@ define void @bar(i1 %c) { | |
| call void @foo(i32 %v) | ||
| ret void | ||
| } | ||
|
|
||
| define <2 x i32> @vec(<2 x i1> %c, <2 x i32> %v1, <2 x i32> %v2) { | ||
| %r = select <2 x i1> %c, <2 x i32> %v1, <2 x i32> %v2 | ||
| ret <2 x i32> %r | ||
| } | ||
|
|
||
| ; CHECK-LABEL: @bar | ||
| ; CHECK: %v = select i1 %c, i32 1, i32 2, !prof !1 | ||
| ; CHECK-LABEL: @vec | ||
| ; CHECK-NOT: select {{.*}} !prof | ||
| ; CHECK: !0 = !{!"function_entry_count", i64 1000} | ||
| ; CHECK: !1 = !{!"branch_weights", i32 2, i32 3} | ||
|
|
||
|
|
@@ -64,4 +76,10 @@ define void @bar(i1 %c) !prof !0 { | |
| ret void | ||
| } | ||
| !0 = !{!"function_entry_count", i64 1000} | ||
| ; CHECK: Profile verification failed: select annotation missing | ||
| ; CHECK: Profile verification failed: select annotation missing | ||
|
|
||
| ;--- verify-vec.ll | ||
| define <2 x i32> @vec(<2 x i1> %c, <2 x i32> %v1, <2 x i32> %v2) !prof !{!"function_entry_count", i32 10} { | ||
| %r = select <2 x i1> %c, <2 x i32> %v1, <2 x i32> %v2 | ||
| ret <2 x i32> %r | ||
| } | ||
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.
Probably more readable if we have a
if (!SI->...->isVectorTy() { continue; }.Uh oh!
There was an error while loading. Please reload this page.
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.
would need more instructions, what am I missing.