[llvm-branch-commits] [llvm] [mlir] [OMPIRBuilder] Support runtime number of teams and threads, and SPMD mode (PR #116051)

Johannes Doerfert via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Nov 17 09:04:08 PST 2024


================
@@ -6758,6 +6793,27 @@ static Expected<Function *> createOutlinedFunction(
   auto Func =
       Function::Create(FuncType, GlobalValue::InternalLinkage, FuncName, M);
 
+  // Forward target-cpu and target-features function attributes from the
+  // original function to the new outlined function.
+  Function *ParentFn = Builder.GetInsertBlock()->getParent();
+
+  auto TargetCpuAttr = ParentFn->getFnAttribute("target-cpu");
+  if (TargetCpuAttr.isStringAttribute())
+    Func->addFnAttr(TargetCpuAttr);
+
+  auto TargetFeaturesAttr = ParentFn->getFnAttribute("target-features");
+  if (TargetFeaturesAttr.isStringAttribute())
+    Func->addFnAttr(TargetFeaturesAttr);
+
+  if (OMPBuilder.Config.isTargetDevice()) {
+    std::vector<llvm::WeakTrackingVH> LLVMCompilerUsed;
----------------
jdoerfert wrote:

Why do you need a vector here, especially of tracking VH?
I guess what you want is:
```
auto *V = emitExecMode(...)
emitUsed("llvm.compiler.used", {V}, OMPBuilder.M);
```


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


More information about the llvm-branch-commits mailing list