diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2020-05-20 20:05:07 -0400 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2020-05-23 13:49:50 -0400 |
commit | cdd006eec9409923f9a56b9026ce2cb72e7b71dc (patch) | |
tree | 98205d8adba2d46c0e4b36ad4440b5dd5e4f20e6 /llvm/lib | |
parent | 27fe841aa650a24fd98da2fb6c6eb2fca806a63f (diff) | |
download | llvm-cdd006eec9409923f9a56b9026ce2cb72e7b71dc.zip llvm-cdd006eec9409923f9a56b9026ce2cb72e7b71dc.tar.gz llvm-cdd006eec9409923f9a56b9026ce2cb72e7b71dc.tar.bz2 |
SimplifyCFG: Clean up optforfuzzing implementation
This should function as any other SimplifyCFGOption rather than having
the transform check and specially consider the attribute itself.
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 18 |
2 files changed, 16 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp index ac53ff3..2e459c9 100644 --- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp +++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp @@ -281,6 +281,14 @@ struct CFGSimplifyPass : public FunctionPass { return false; Options.AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F); + if (F.hasFnAttribute(Attribute::OptForFuzzing)) { + Options.setSimplifyCondBranch(false) + .setFoldTwoEntryPHINode(false); + } else { + Options.setSimplifyCondBranch(true) + .setFoldTwoEntryPHINode(true); + } + auto &TTI = getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F); return simplifyFunctionCFG(F, TTI, Options); } diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 5bccb7d..9afc18e 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -2336,9 +2336,6 @@ static bool FoldTwoEntryPHINode(PHINode *PN, const TargetTransformInfo &TTI, // 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); @@ -5969,8 +5966,7 @@ static BasicBlock *allPredecessorsComeFromSameSource(BasicBlock *BB) { bool SimplifyCFGOpt::simplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) { BasicBlock *BB = BI->getParent(); - const Function *Fn = BB->getParent(); - if (Fn && Fn->hasFnAttribute(Attribute::OptForFuzzing)) + if (!Options.SimplifyCondBranch) return false; // Conditional branch @@ -6184,11 +6180,13 @@ bool SimplifyCFGOpt::simplifyOnce(BasicBlock *BB) { IRBuilder<> Builder(BB); - // 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<PHINode>(BB->begin())) - if (PN->getNumIncomingValues() == 2) - Changed |= FoldTwoEntryPHINode(PN, TTI, DL); + 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<PHINode>(BB->begin())) + if (PN->getNumIncomingValues() == 2) + Changed |= FoldTwoEntryPHINode(PN, TTI, DL); + } Instruction *Terminator = BB->getTerminator(); Builder.SetInsertPoint(Terminator); |