Skip to content

Commit aeb0fdf

Browse files
committed
[SimplifyCFG] Respect optforfuzzing in NPM pass
Regression caused by refactoring in cdd006e. See discussion in https://reviews.llvm.org/D89917. Reviewed By: arsenm, morehouse Differential Revision: https://reviews.llvm.org/D91473
1 parent 618f11b commit aeb0fdf

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ PreservedAnalyses SimplifyCFGPass::run(Function &F,
245245
FunctionAnalysisManager &AM) {
246246
auto &TTI = AM.getResult<TargetIRAnalysis>(F);
247247
Options.AC = &AM.getResult<AssumptionAnalysis>(F);
248+
if (F.hasFnAttribute(Attribute::OptForFuzzing)) {
249+
Options.setSimplifyCondBranch(false).setFoldTwoEntryPHINode(false);
250+
} else {
251+
Options.setSimplifyCondBranch(true).setFoldTwoEntryPHINode(true);
252+
}
248253
if (!simplifyFunctionCFG(F, TTI, Options))
249254
return PreservedAnalyses::all();
250255
PreservedAnalyses PA;

llvm/test/Transforms/SimplifyCFG/opt-for-fuzzing.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt < %s -simplifycfg -S | FileCheck %s
2+
; RUN: opt < %s -passes=simplifycfg -S | FileCheck %s
23

34
define i32 @foo(i32 %x) optforfuzzing {
45
entry:

0 commit comments

Comments
 (0)