Skip to content

Commit ce1b047

Browse files
authored
[SelectOptimize] Respect optnone (#170858)
Add the missing skipFunction() call so that optnone attributes and opt-bisect-limit is respected.
1 parent c13bf9e commit ce1b047

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

llvm/lib/CodeGen/SelectOptimize.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ class SelectOptimize : public FunctionPass {
313313
}
314314

315315
bool runOnFunction(Function &F) override {
316+
if (skipFunction(F))
317+
return false;
318+
316319
return Impl.runOnFunction(F, *this);
317320
}
318321

llvm/test/CodeGen/X86/select-optimize.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ define i32 @weighted_select1(i32 %a, i32 %b, i1 %cmp) {
2323
ret i32 %sel
2424
}
2525

26+
; But don't do anything for optnone functions.
27+
define i32 @weighted_select1_optnone(i32 %a, i32 %b, i1 %cmp) optnone noinline {
28+
; CHECK-LABEL: @weighted_select1_optnone(
29+
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP:%.*]], i32 [[A:%.*]], i32 [[B:%.*]], !prof [[PROF16]]
30+
; CHECK-NEXT: ret i32 [[SEL]]
31+
;
32+
%sel = select i1 %cmp, i32 %a, i32 %b, !prof !15
33+
ret i32 %sel
34+
}
35+
2636
; If a select is obviously predictable (reversed profile weights),
2737
; turn it into a branch.
2838
define i32 @weighted_select2(i32 %a, i32 %b, i1 %cmp) {

0 commit comments

Comments
 (0)