[NFC] SimplifyCFGOptions: drop multi-parameter ctor, use default member-init
authorRoman Lebedev <lebedev.ri@gmail.com>
Wed, 15 Jul 2020 22:39:37 +0000 (01:39 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Wed, 15 Jul 2020 22:48:34 +0000 (01:48 +0300)
Likewise, just use the builder pattern.
Taking multiple params is unmaintainable.

llvm/include/llvm/Transforms/Scalar/SimplifyCFGOptions.h
llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp

index 42df3af..9855400 100644 (file)
@@ -21,29 +21,15 @@ namespace llvm {
 class AssumptionCache;
 
 struct SimplifyCFGOptions {
-  int BonusInstThreshold;
-  bool ForwardSwitchCondToPhi;
-  bool ConvertSwitchToLookupTable;
-  bool NeedCanonicalLoop;
-  bool SinkCommonInsts;
-  bool SimplifyCondBranch;
-  bool FoldTwoEntryPHINode;
+  int BonusInstThreshold = 1;
+  bool ForwardSwitchCondToPhi = false;
+  bool ConvertSwitchToLookupTable = false;
+  bool NeedCanonicalLoop = true;
+  bool SinkCommonInsts = false;
+  bool SimplifyCondBranch = true;
+  bool FoldTwoEntryPHINode = true;
 
-  AssumptionCache *AC;
-
-  SimplifyCFGOptions(unsigned BonusThreshold = 1,
-                     bool ForwardSwitchCond = false,
-                     bool SwitchToLookup = false, bool CanonicalLoops = true,
-                     bool SinkCommon = false,
-                     AssumptionCache *AssumpCache = nullptr,
-                     bool SimplifyCondBranch = true,
-                     bool FoldTwoEntryPHINode = true)
-      : BonusInstThreshold(BonusThreshold),
-        ForwardSwitchCondToPhi(ForwardSwitchCond),
-        ConvertSwitchToLookupTable(SwitchToLookup),
-        NeedCanonicalLoop(CanonicalLoops), SinkCommonInsts(SinkCommon),
-        SimplifyCondBranch(SimplifyCondBranch),
-        FoldTwoEntryPHINode(FoldTwoEntryPHINode), AC(AssumpCache) {}
+  AssumptionCache *AC = nullptr;
 
   // Support 'builder' pattern to set members by name at construction time.
   SimplifyCFGOptions &bonusInstThreshold(int I) {
index 4182966..3c375e0 100644 (file)
@@ -187,7 +187,7 @@ static BasicBlock *unifyReturnBlockSet(Function &F,
 
   for (BasicBlock *BB : ReturningBlocks) {
     // Cleanup possible branch to unconditional branch to the return.
-    simplifyCFG(BB, TTI, {2});
+    simplifyCFG(BB, TTI, SimplifyCFGOptions().bonusInstThreshold(2));
   }
 
   return NewRetBlock;