## Summary This PR fixes https://github.com/llvm/llvm-project/issues/200922 - a compile-time regression affecting firstprivate clauses on simple arrays in OpenMP target regions. When `InlineHLFIRAssign` checks whether to inline `hlfir.assign` operations in `omp.private` copy regions, the alias analysis conservatively returns `MayAlias` for the copy region block arguments (`%arg0` mold vs `%arg1` private). This prevents inlining and forces a fallback to `fir.call @_FortranAAssign`, which: - Pulls in 89 runtime functions via LTO - Creates 550K+ abstract attributes in OpenMPOpt - Causes severe compile-time degradation (60%+ increase in some cases) **Example:** ```fortran !$omp target firstprivate(array) ! ... use array ... !$omp end target ``` The firstprivate copy generates an `omp.private` copy region where the assignment from the original array to the private copy cannot be inlined due to conservative aliasing assumptions. ## Root Cause and Solution The FIR alias analysis did not recognize that `omp.private` copy region block arguments are guaranteed by the OpenMP specification to reference different memory locations: - `%arg0` (mold) - the original variable - `%arg1` (private) - freshly allocated private storage created in the init region Since the private copy is allocated fresh, these arguments **cannot alias**. So, this PR adds special-case handling in `flang/lib/Optimizer/Analysis/AliasAnalysis.cpp` to recognize `omp.private` copy region block arguments and correctly return `NoAlias`. This allows `InlineHLFIRAssign` to inline the assignment into an element-wise loop, avoiding the expensive runtime call entirely. Assisted by: Claude Sonnet --------- Co-authored-by: Claude Sonnet 4 <noreply@anthropic.com> |
||
|---|---|---|
| .ci | ||
| .github | ||
| bolt | ||
| clang | ||
| clang-tools-extra | ||
| cmake | ||
| compiler-rt | ||
| cross-project-tests | ||
| flang | ||
| flang-rt | ||
| libc | ||
| libclc | ||
| libcxx | ||
| libcxxabi | ||
| libsycl | ||
| libunwind | ||
| lld | ||
| lldb | ||
| llvm | ||
| llvm-libgcc | ||
| mlir | ||
| offload | ||
| openmp | ||
| orc-rt | ||
| polly | ||
| runtimes | ||
| third-party | ||
| utils | ||
| .clang-format | ||
| .clang-format-ignore | ||
| .clang-tidy | ||
| .git-blame-ignore-revs | ||
| .gitattributes | ||
| .gitignore | ||
| .mailmap | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTING.md | ||
| LICENSE.TXT | ||
| pyproject.toml | ||
| README.md | ||
| SECURITY.md | ||
The LLVM Compiler Infrastructure
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called "LLVM". This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Getting the Source Code and Building LLVM
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Getting in touch
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.