[SelectOptimize] Respect optnone (#170858)

Add the missing skipFunction() call so that optnone attributes and
opt-bisect-limit is respected.
This commit is contained in:
Nikita Popov
2025-12-15 09:21:02 +01:00
committed by GitHub
parent c13bf9eb26
commit ce1b04720a
2 changed files with 13 additions and 0 deletions

View File

@@ -313,6 +313,9 @@ public:
}
bool runOnFunction(Function &F) override {
if (skipFunction(F))
return false;
return Impl.runOnFunction(F, *this);
}

View File

@@ -23,6 +23,16 @@ define i32 @weighted_select1(i32 %a, i32 %b, i1 %cmp) {
ret i32 %sel
}
; But don't do anything for optnone functions.
define i32 @weighted_select1_optnone(i32 %a, i32 %b, i1 %cmp) optnone noinline {
; CHECK-LABEL: @weighted_select1_optnone(
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP:%.*]], i32 [[A:%.*]], i32 [[B:%.*]], !prof [[PROF16]]
; CHECK-NEXT: ret i32 [[SEL]]
;
%sel = select i1 %cmp, i32 %a, i32 %b, !prof !15
ret i32 %sel
}
; If a select is obviously predictable (reversed profile weights),
; turn it into a branch.
define i32 @weighted_select2(i32 %a, i32 %b, i1 %cmp) {