[PATCH] D89590: [NPM][SimplifyCFGPass] For OptForFuzzing attribute, disable SimplifyCondBranch and FoldTwoEntryPHINode in NPM

Zequan Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 16 13:22:03 PDT 2020


zequanwu updated this revision to Diff 298739.
zequanwu added a comment.

update test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89590/new/

https://reviews.llvm.org/D89590

Files:
  llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
  llvm/test/Transforms/SimplifyCFG/opt-for-fuzzing.ll


Index: llvm/test/Transforms/SimplifyCFG/opt-for-fuzzing.ll
===================================================================
--- llvm/test/Transforms/SimplifyCFG/opt-for-fuzzing.ll
+++ 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:
Index: llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
+++ llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
@@ -245,6 +245,10 @@
                                        FunctionAnalysisManager &AM) {
   auto &TTI = AM.getResult<TargetIRAnalysis>(F);
   Options.AC = &AM.getResult<AssumptionAnalysis>(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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89590.298739.patch
Type: text/x-patch
Size: 1141 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201016/a0a3c8c3/attachment.bin>


More information about the llvm-commits mailing list