[PATCH] D32249: [PartialInl] Enhance partial inliner to handle more complex conditions

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 19 16:58:17 PDT 2017


wmi added inline comments.


================
Comment at: lib/Transforms/IPO/PartialInlining.cpp:40
 
+  // Finds a ghain of blocks (starting from function entry)
+  // that guards a return block. Returns the ReturnBlock and NonReturnBlock.
----------------
nit: ghain --> chain


================
Comment at: lib/Transforms/IPO/PartialInlining.cpp:110-119
+  for (auto &BB : *F) {
+    TerminatorInst *TI = BB.getTerminator();
+    if (isa<ReturnInst>(TI)) {
+      ReturnBlock = &BB;
+      ReturnCount++;
+    }
   }
----------------
Here we add a limitation that the function only has one return BB to be a partial inline candidate. Is it required?  Can we walk forward from entry instead of backward from the return block so as to avoid the requirement of finding single return BB?


================
Comment at: lib/Transforms/IPO/PartialInlining.cpp:158-166
+  // Now walk up the chain till the function entry is reached:
+  BasicBlock *CurrEntryInChain = LastEntryInChain;
+  do {
+    Entries.push_back(CurrEntryInChain);
+    if (CurrEntryInChain == EntryBlock)
+      break;
+
----------------
Here we allows a node on the chain with more than two successors. Will such case bring us problem later during extracting?


================
Comment at: test/Transforms/CodeExtractor/MultiConditions.ll:5
+define i32 @bar(i32) local_unnamed_addr #0 {
+  %2 = icmp slt i32 %0, 0
+  br i1 %2, label %6, label %3
----------------
we can use opt -instnamer to rename the temporaries.


https://reviews.llvm.org/D32249





More information about the llvm-commits mailing list