Skip to content

Commit 815453f

Browse files
authored
[profcheck] Disable verification of selects on vector conditions. (#167973)
We don't currently support profile metadata on selects where the condition is a vector. Issue #147390
1 parent b713484 commit 815453f

File tree

3 files changed

+30
-38
lines changed

3 files changed

+30
-38
lines changed

llvm/lib/Transforms/Utils/ProfileVerify.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,11 @@ bool ProfileInjector::inject() {
102102
for (auto &BB : F) {
103103
if (AnnotateSelect) {
104104
for (auto &I : BB) {
105-
if (isa<SelectInst>(I) && !I.getMetadata(LLVMContext::MD_prof))
106-
setBranchWeights(I, {SelectTrueWeight, SelectFalseWeight},
107-
/*IsExpected=*/false);
105+
if (auto *SI = dyn_cast<SelectInst>(&I))
106+
if (!SI->getCondition()->getType()->isVectorTy() &&
107+
!I.getMetadata(LLVMContext::MD_prof))
108+
setBranchWeights(I, {SelectTrueWeight, SelectFalseWeight},
109+
/*IsExpected=*/false);
108110
}
109111
}
110112
auto *Term = getTerminatorBenefitingFromMDProf(BB);
@@ -185,9 +187,11 @@ PreservedAnalyses ProfileVerifierPass::run(Function &F,
185187
for (const auto &BB : F) {
186188
if (AnnotateSelect) {
187189
for (const auto &I : BB)
188-
if (isa<SelectInst>(I) && !I.getMetadata(LLVMContext::MD_prof))
189-
F.getContext().emitError(
190-
"Profile verification failed: select annotation missing");
190+
if (auto *SI = dyn_cast<SelectInst>(&I))
191+
if (!SI->getCondition()->getType()->isVectorTy() &&
192+
!I.getMetadata(LLVMContext::MD_prof))
193+
F.getContext().emitError(
194+
"Profile verification failed: select annotation missing");
191195
}
192196
if (const auto *Term =
193197
ProfileInjector::getTerminatorBenefitingFromMDProf(BB))

llvm/test/Transforms/PGOProfile/profcheck-select.ll

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
; RUN: not opt -passes=prof-verify %t/verify-missing.ll 2>&1 | FileCheck %t/verify-missing.ll
1616

1717
; verify we can disable it. It's sufficient to see opt not failing.
18-
; RUN: opt -passes=prof-verify -profcheck-annotate-select=0 %t/verify-missing.ll
18+
; RUN: opt -passes=prof-verify -profcheck-annotate-select=0 --disable-output %t/verify-missing.ll
19+
20+
; verify vector selects without profiles are OK. It's sufficient opt doesn't fail.
21+
; RUN: opt -passes=prof-verify --disable-output %t/verify-vec.ll
22+
1923

2024
;--- inject.ll
2125
declare void @foo(i32 %a);
@@ -24,8 +28,16 @@ define void @bar(i1 %c) {
2428
call void @foo(i32 %v)
2529
ret void
2630
}
31+
32+
define <2 x i32> @vec(<2 x i1> %c, <2 x i32> %v1, <2 x i32> %v2) {
33+
%r = select <2 x i1> %c, <2 x i32> %v1, <2 x i32> %v2
34+
ret <2 x i32> %r
35+
}
36+
2737
; CHECK-LABEL: @bar
2838
; CHECK: %v = select i1 %c, i32 1, i32 2, !prof !1
39+
; CHECK-LABEL: @vec
40+
; CHECK-NOT: select {{.*}} !prof
2941
; CHECK: !0 = !{!"function_entry_count", i64 1000}
3042
; CHECK: !1 = !{!"branch_weights", i32 2, i32 3}
3143

@@ -64,4 +76,10 @@ define void @bar(i1 %c) !prof !0 {
6476
ret void
6577
}
6678
!0 = !{!"function_entry_count", i64 1000}
67-
; CHECK: Profile verification failed: select annotation missing
79+
; CHECK: Profile verification failed: select annotation missing
80+
81+
;--- verify-vec.ll
82+
define <2 x i32> @vec(<2 x i1> %c, <2 x i32> %v1, <2 x i32> %v2) !prof !{!"function_entry_count", i32 10} {
83+
%r = select <2 x i1> %c, <2 x i32> %v1, <2 x i32> %v2
84+
ret <2 x i32> %r
85+
}

llvm/utils/profcheck-xfail.txt

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ DebugInfo/Generic/block-asan.ll
2424
DebugInfo/X86/asan_debug_info.ll
2525
LTO/X86/diagnostic-handler-remarks-with-hotness.ll
2626
Other/optimization-remarks-auto.ll
27-
Other/X86/debugcounter-partiallyinlinelibcalls.ll
2827
Transforms/AtomicExpand/ARM/atomic-expansion-v7.ll
2928
Transforms/AtomicExpand/SPARC/partword.ll
3029
Transforms/Attributor/align.ll
@@ -94,8 +93,6 @@ Transforms/CodeGenPrepare/NVPTX/bypass-slow-div-constant-numerator.ll
9493
Transforms/CodeGenPrepare/NVPTX/bypass-slow-div.ll
9594
Transforms/CodeGenPrepare/NVPTX/bypass-slow-div-not-exact.ll
9695
Transforms/CodeGenPrepare/NVPTX/bypass-slow-div-special-cases.ll
97-
Transforms/CodeGenPrepare/X86/vec-shift-inseltpoison.ll
98-
Transforms/CodeGenPrepare/X86/vec-shift.ll
9996
Transforms/Coroutines/coro-await-suspend-lower-invoke.ll
10097
Transforms/Coroutines/coro-await-suspend-lower.ll
10198
Transforms/Coroutines/coro-byval-param.ll
@@ -182,8 +179,6 @@ Transforms/GlobalOpt/shrink-global-to-bool-check-debug.ll
182179
Transforms/GlobalOpt/shrink-global-to-bool-opaque-ptrs.ll
183180
Transforms/GVN/debugloc-load-select.ll
184181
Transforms/GVN/load-through-select-dbg.ll
185-
Transforms/GVN/masked-load-store.ll
186-
Transforms/GVN/masked-load-store-no-mem-dep.ll
187182
Transforms/GVN/opaque-ptr.ll
188183
Transforms/GVN/pr69301.ll
189184
Transforms/GVN/pre-invalid-prof-metadata.ll
@@ -236,9 +231,6 @@ Transforms/IndVarSimplify/pr45835.ll
236231
Transforms/IndVarSimplify/preserving-debugloc-rem-div.ll
237232
Transforms/InstCombine/2004-09-20-BadLoadCombine.ll
238233
Transforms/InstCombine/2005-04-07-UDivSelectCrash.ll
239-
Transforms/InstCombine/AArch64/sve-intrinsic-sel.ll
240-
Transforms/InstCombine/AArch64/sve-intrinsic-simplify-binop.ll
241-
Transforms/InstCombine/AArch64/sve-intrinsic-simplify-shift.ll
242234
Transforms/InstCombine/add-mask.ll
243235
Transforms/InstCombine/add-shl-mul-umax.ll
244236
Transforms/InstCombine/and2.ll
@@ -274,7 +266,6 @@ Transforms/InstCombine/fmul-bool.ll
274266
Transforms/InstCombine/fmul.ll
275267
Transforms/InstCombine/fneg.ll
276268
Transforms/InstCombine/fold-ctpop-of-not.ll
277-
Transforms/InstCombine/fold-ext-eq-c-with-op.ll
278269
Transforms/InstCombine/free-inversion.ll
279270
Transforms/InstCombine/icmp-and-lowbit-mask.ll
280271
Transforms/InstCombine/icmp.ll
@@ -294,8 +285,6 @@ Transforms/InstCombine/loadstore-metadata.ll
294285
Transforms/InstCombine/logical-select-inseltpoison.ll
295286
Transforms/InstCombine/logical-select.ll
296287
Transforms/InstCombine/lshr.ll
297-
Transforms/InstCombine/masked_intrinsics-inseltpoison.ll
298-
Transforms/InstCombine/masked_intrinsics.ll
299288
Transforms/InstCombine/memchr-11.ll
300289
Transforms/InstCombine/memchr-2.ll
301290
Transforms/InstCombine/memchr-3.ll
@@ -332,14 +321,11 @@ Transforms/InstCombine/select-and-or.ll
332321
Transforms/InstCombine/select-cmp-br.ll
333322
Transforms/InstCombine/select-cmp.ll
334323
Transforms/InstCombine/select-factorize.ll
335-
Transforms/InstCombine/select_frexp.ll
336324
Transforms/InstCombine/select.ll
337325
Transforms/InstCombine/select-min-max.ll
338326
Transforms/InstCombine/select-of-symmetric-selects.ll
339327
Transforms/InstCombine/select-select.ll
340328
Transforms/InstCombine/shift.ll
341-
Transforms/InstCombine/shuffle-select-narrow-inseltpoison.ll
342-
Transforms/InstCombine/shuffle-select-narrow.ll
343329
Transforms/InstCombine/simplify-demanded-fpclass.ll
344330
Transforms/InstCombine/sink-not-into-another-hand-of-logical-and.ll
345331
Transforms/InstCombine/sink-not-into-another-hand-of-logical-or.ll
@@ -355,11 +341,8 @@ Transforms/InstCombine/sub-xor-cmp.ll
355341
Transforms/InstCombine/truncating-saturate.ll
356342
Transforms/InstCombine/unordered-fcmp-select.ll
357343
Transforms/InstCombine/urem-via-cmp-select.ll
358-
Transforms/InstCombine/vec_sext.ll
359-
Transforms/InstCombine/vector-urem.ll
360344
Transforms/InstCombine/wcslen-1.ll
361345
Transforms/InstCombine/wcslen-3.ll
362-
Transforms/InstCombine/X86/blend_x86.ll
363346
Transforms/InstCombine/X86/x86-avx512-inseltpoison.ll
364347
Transforms/InstCombine/X86/x86-avx512.ll
365348
Transforms/InstCombine/xor-and-or.ll
@@ -607,36 +590,25 @@ Transforms/OpenMP/spmdization_indirect.ll
607590
Transforms/OpenMP/spmdization.ll
608591
Transforms/OpenMP/spmdization_no_guarding_two_reaching_kernels.ll
609592
Transforms/OpenMP/spmdization_remarks.ll
610-
Transforms/PartiallyInlineLibCalls/X86/good-prototype.ll
611593
Transforms/PGOProfile/comdat.ll
612594
Transforms/PGOProfile/memop_profile_funclet_wasm.ll
613595
Transforms/PGOProfile/X86/macho.ll
614596
Transforms/PhaseOrdering/AArch64/constraint-elimination-placement.ll
615597
Transforms/PhaseOrdering/AArch64/globals-aa-required-for-vectorization.ll
616-
Transforms/PhaseOrdering/AArch64/hoisting-sinking-required-for-vectorization.ll
617-
Transforms/PhaseOrdering/AArch64/predicated-reduction.ll
618-
Transforms/PhaseOrdering/AArch64/quant_4x4.ll
619-
Transforms/PhaseOrdering/ARM/arm_mean_q7.ll
620-
Transforms/PhaseOrdering/vector-select.ll
621-
Transforms/PhaseOrdering/X86/blendv-select.ll
622598
Transforms/PhaseOrdering/X86/merge-functions2.ll
623599
Transforms/PhaseOrdering/X86/merge-functions3.ll
624600
Transforms/PhaseOrdering/X86/merge-functions.ll
625601
Transforms/PhaseOrdering/X86/pr52078.ll
626-
Transforms/PhaseOrdering/X86/pr67803.ll
627602
Transforms/PhaseOrdering/X86/preserve-access-group.ll
628-
Transforms/PhaseOrdering/X86/vector-reductions.ll
629603
Transforms/PreISelIntrinsicLowering/AArch64/expand-exp.ll
630604
Transforms/PreISelIntrinsicLowering/AArch64/expand-log.ll
631-
Transforms/PreISelIntrinsicLowering/expand-vp.ll
632605
Transforms/PreISelIntrinsicLowering/PowerPC/memset-pattern.ll
633606
Transforms/PreISelIntrinsicLowering/RISCV/memset-pattern.ll
634607
Transforms/PreISelIntrinsicLowering/X86/memcpy-inline-non-constant-len.ll
635608
Transforms/PreISelIntrinsicLowering/X86/memset-inline-non-constant-len.ll
636609
Transforms/PreISelIntrinsicLowering/X86/memset-pattern.ll
637610
Transforms/SampleProfile/pseudo-probe-profile-mismatch-thinlto.ll
638611
Transforms/SampleProfile/remarks-hotness.ll
639-
Transforms/SandboxVectorizer/special_opcodes.ll
640612
Transforms/ScalarizeMaskedMemIntrin/AArch64/expand-masked-load.ll
641613
Transforms/ScalarizeMaskedMemIntrin/AArch64/expand-masked-store.ll
642614
Transforms/ScalarizeMaskedMemIntrin/AArch64/streaming-compatible-expand-masked-gather-scatter.ll
@@ -675,5 +647,3 @@ Transforms/UnifyLoopExits/switch.ll
675647
Transforms/UnifyLoopExits/undef-phis.ll
676648
Transforms/Util/libcalls-opt-remarks.ll
677649
Transforms/Util/lowerswitch.ll
678-
Transforms/VectorCombine/AArch64/shuffletoidentity.ll
679-
Transforms/VectorCombine/X86/shuffle-of-selects.ll

0 commit comments

Comments
 (0)