[llvm] [mlir] [OpenMP][MLIR][OMPIRBuilder] Add a small optional constant alloca raise function pass to finalize, utilised in convertTarget (PR #78818)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 13 13:03:00 PST 2024


================
@@ -5043,6 +5088,12 @@ static Function *createOutlinedFunction(
 
   BasicBlock *UserCodeEntryBB = Builder.GetInsertBlock();
 
+  // As we embed the user code in the middle of our target region after we
+  // generate entry code, we must move what allocas we can into the entry
+  // block to avoid possible breaking optimisations for device
+  if (OMPBuilder.Config.isTargetDevice())
+    OMPBuilder.ConstantAllocaRaiseCandidates.emplace_back(Func);
----------------
agozillon wrote:

I unfortunately can only speak to AMD GPU backends as it's all I've tested the fortran offload examples I work with on and don't know enough about the other backends (e.g. NVIDIA) to really comment on them unfortunately. 

I can see if I can restrict it to the AMD target triple if that's something you'd like me to do to be cautious however? not sure how complicated it'd be to do so here, but I imagine it wouldn't be. 

I believe someone did manage to get some of the offloading working for NVIDIA GPU's a while ago if I recall correctly, but I am not sure how easy that was for them, so I could in theory test that if we'd like to as well. 

https://github.com/llvm/llvm-project/pull/78818


More information about the llvm-commits mailing list