[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:17:35 PDT 2026


sbryngelson wrote:

Filed the narrow fix as #211255, and a correction to what I wrote above.

The cold-callsite claim holds for the reproducer attached to #211132 but not for the larger kernel the throughput numbers in this PR come from. Measured with the unpatched compiler at gfx90a and gfx942:

| region | cost | threshold | rejected because |
|---|---|---|---|
| reproducer | 1280 | 495 | cold callsite; ordinary threshold is 2475 |
| WENO5 + HLLC, NEQ=8 | 3270 | 2750 | genuinely over the ordinary threshold |

So "the defect is not that the outlined region is too costly to inline" was too strong. For the small case it is coldness and #211255 fixes it. For the large case the cost really does exceed the threshold, and #211255 changes nothing: 196 VGPR / 64 B scratch / occupancy 2 before and after, throughput 0.99x / 0.98x / 1.01x at the three sizes.

Which leaves the second half of #211132 open, and it is the half that matters for this workload. The asymmetry with clang is that clang emits the target region body into the kernel directly while flang goes through CodeExtractor, so flang pays an inline-cost round trip clang never incurs, on a body that is identical. Raising a threshold to paper over that seems wrong, and `alwaysinline` is what ROCm/llvm-project#3485 is backing out.

Leaving this PR open for now rather than closing it, since it is the only thing on the table for the large-region case, but I do not think it should be merged as is. If the preference is to attack the structural cause instead, i.e. stop passing privatized locals by pointer through the outlining boundary in `applyWorkshareLoopTarget` so the body is not inflated before the inliner sees it, I am happy to take that on.

This affects performance-critical applications on large AMD GPU supercomputers, including [MFC](https://github.com/MFlowCode/MFC).

All numbers above come from the validated reproducers included with this report and are independently reproducible; they stand on their own.

This was found and root-caused with the assistance of AI tools.


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


More information about the flang-commits mailing list