[flang-commits] [flang] [llvm] [OpenMPIRBuilder] Always inline device-outlined target regions (PR #211136)

Spencer Bryngelson via flang-commits flang-commits at lists.llvm.org
Wed Jul 22 06:04:22 PDT 2026


================
@@ -950,6 +955,13 @@ void OpenMPIRBuilder::finalize(Function *Fn) {
     if (TargetFeaturesAttr.isStringAttribute())
       OutlinedFn->addFnAttr(TargetFeaturesAttr);
 
+    // On device, keep the outlined region in the kernel: left standalone it is
+    // register allocated without the kernel's occupancy target. The function is
+    // still emitted for entry points that take its address (generic mode).
+    if (DeviceAlwaysInlineOutlined && Config.isTargetDevice() &&
+        !OutlinedFn->hasFnAttribute(Attribute::NoInline))
+      OutlinedFn->addFnAttr(Attribute::AlwaysInline);
----------------
sbryngelson wrote:

Correct, and I tried narrowing it. Marking only the `applyWorkshareLoopTarget` outline and leaving parallel and task alone gives 212 VGPR / 48 B scratch / occupancy 2, unchanged from baseline. The whole effect comes from the parallel outline. Details in the comment on the PR; the callsite turns out to be rejected as cold, not as expensive, so this patch is likely the wrong fix altogether.

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


More information about the flang-commits mailing list