================
@@ -227,11 +228,44 @@ bool InstrumentorImpl::instrumentFunction(Function &Fn) {
     return Changed;
 
   InstrumentationCaches ICaches;
+  SmallVector<Instruction *> FinalTIs;
   ReversePostOrderTraversal<Function *> RPOT(&Fn);
-  for (auto &It : RPOT)
+  for (auto &It : RPOT) {
     for (auto &I : *It)
       Changed |= instrumentInstruction(I, ICaches);
+    
+    auto *TI = It->getTerminator();
+    if (!TI->getNumSuccessors())
+      FinalTIs.push_back(TI);
+  }
+
+  Value *FPtr = &Fn;
+  for (auto &ChoiceIt : IConf.IChoices[InstrumentationLocation::FUNCTION_PRE]) 
{
+    if (!ChoiceIt.second->Enabled)
+      continue;
+    // Count epochs eagerly.
+    ++IIRB.Epoch;
+
+    IIRB.IRB.SetInsertPointPastAllocas(cast<Function>(FPtr));
+    ensureDbgLoc(IIRB.IRB);
+    ChoiceIt.second->instrument(FPtr, IConf, IIRB, ICaches);
+    IIRB.returnAllocas();
+  }
 
+  for (auto &ChoiceIt :
+       IConf.IChoices[InstrumentationLocation::FUNCTION_POST]) {
+    if (!ChoiceIt.second->Enabled)
+      continue;
+    // Count epochs eagerly.
+    ++IIRB.Epoch;
+
+    for (auto *FinalTI : FinalTIs) {
----------------
arsenm wrote:

No auto 

https://github.com/llvm/llvm-project/pull/195378
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to