[PATCH] D91473: [SimplifyCFG] Respect optforfuzzing in NPM pass

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 16 09:57:05 PST 2020


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaeb0fdff351b: [SimplifyCFG] Respect optforfuzzing in NPM pass (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91473

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,11 @@
                                        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: D91473.305543.patch
Type: text/x-patch
Size: 1152 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201116/f81e8c68/attachment.bin>


More information about the llvm-commits mailing list