diff --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp --- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp +++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp @@ -245,6 +245,11 @@ FunctionAnalysisManager &AM) { auto &TTI = AM.getResult(F); Options.AC = &AM.getResult(F); + if (F.hasFnAttribute(Attribute::OptForFuzzing)) { + Options.setSimplifyCondBranch(false).setFoldTwoEntryPHINode(false); + } else { + Options.setSimplifyCondBranch(true).setFoldTwoEntryPHINode(true); + } if (!simplifyFunctionCFG(F, TTI, Options)) return PreservedAnalyses::all(); PreservedAnalyses PA; diff --git a/llvm/test/Transforms/SimplifyCFG/opt-for-fuzzing.ll b/llvm/test/Transforms/SimplifyCFG/opt-for-fuzzing.ll --- a/llvm/test/Transforms/SimplifyCFG/opt-for-fuzzing.ll +++ b/llvm/test/Transforms/SimplifyCFG/opt-for-fuzzing.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -simplifycfg -S | FileCheck %s +; RUN: opt < %s -passes=simplifycfg -S | FileCheck %s define i32 @foo(i32 %x) optforfuzzing { entry: