[Mlir-commits] [mlir] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)
    Johannes Doerfert 
    llvmlistbot at llvm.org
       
    Tue Oct 24 12:49:21 PDT 2023
    
    
  
================
@@ -1736,26 +1750,20 @@ OpenMPIRBuilder::createTask(const LocationDescription &Loc,
 
     StaleCI->eraseFromParent();
 
-    // Emit the body for wrapper function
-    BasicBlock *WrapperEntryBB =
-        BasicBlock::Create(M.getContext(), "", WrapperFunc);
-    Builder.SetInsertPoint(WrapperEntryBB);
+    Builder.SetInsertPoint(TaskAllocaBB, TaskAllocaBB->begin());
     if (HasShareds) {
-      llvm::Value *Shareds =
-          Builder.CreateLoad(VoidPtr, WrapperFunc->getArg(1));
-      Builder.CreateCall(&OutlinedFn, {Shareds});
-    } else {
-      Builder.CreateCall(&OutlinedFn);
+      LoadInst *Shareds = Builder.CreateLoad(VoidPtr, OutlinedFn.getArg(1));
+      OutlinedFn.getArg(1)->replaceUsesWithIf(
+          Shareds, [Shareds](Use &U) { return U.getUser() != Shareds; });
+    }
+
+    while (!ToBeDeleted.empty()) {
+      ToBeDeleted.top()->eraseFromParent();
+      ToBeDeleted.pop();
----------------
jdoerfert wrote:
There is no need to pop anything, we have this code in other places already, why do we need to come up with new and exciting ways to do the same thing?
```
for (auto *TBD : ToBeDeleted)
  TBD->eraseFromParent
```
https://github.com/llvm/llvm-project/pull/67723
    
    
More information about the Mlir-commits
mailing list