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 @@ -273,14 +273,6 @@ return false; Options.AC = &getAnalysis().getAssumptionCache(F); - if (F.hasFnAttribute(Attribute::OptForFuzzing)) { - Options.setSimplifyCondBranch(false) - .setFoldTwoEntryPHINode(false); - } else { - Options.setSimplifyCondBranch(true) - .setFoldTwoEntryPHINode(true); - } - auto &TTI = getAnalysis().getTTI(F); return simplifyFunctionCFG(F, TTI, Options); } diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -2415,6 +2415,9 @@ // dependence information for this check, but simplifycfg can't keep it up // to date, and this catches most of the cases we care about anyway. BasicBlock *BB = PN->getParent(); + const Function *Fn = BB->getParent(); + if (Fn && Fn->hasFnAttribute(Attribute::OptForFuzzing)) + return false; BasicBlock *IfTrue, *IfFalse; Value *IfCond = GetIfCondition(BB, IfTrue, IfFalse); @@ -6055,7 +6058,8 @@ bool SimplifyCFGOpt::simplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) { BasicBlock *BB = BI->getParent(); - if (!Options.SimplifyCondBranch) + const Function *Fn = BB->getParent(); + if (Fn && Fn->hasFnAttribute(Attribute::OptForFuzzing)) return false; // Conditional branch @@ -6270,13 +6274,11 @@ IRBuilder<> Builder(BB); - if (Options.FoldTwoEntryPHINode) { - // If there is a trivial two-entry PHI node in this basic block, and we can - // eliminate it, do so now. - if (auto *PN = dyn_cast(BB->begin())) - if (PN->getNumIncomingValues() == 2) - Changed |= FoldTwoEntryPHINode(PN, TTI, DL); - } + // If there is a trivial two-entry PHI node in this basic block, and we can + // eliminate it, do so now. + if (auto *PN = dyn_cast(BB->begin())) + if (PN->getNumIncomingValues() == 2) + Changed |= FoldTwoEntryPHINode(PN, TTI, DL); Instruction *Terminator = BB->getTerminator(); Builder.SetInsertPoint(Terminator);