Manual-sync mirror of chromium.googlesource.com/external/github.com/llvm/llvm-project (bare monorepo, no subtree suffix)
Find a file
Pranav Bhandarkar e949b65442
[flang][OpenMP] Fix alias analysis for omp.private copy region block arguments to help inline hlfir.assign to improve time taken in LTO. (#209539)
## 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>
2026-07-24 13:56:30 -05:00
.ci [libc++] Rename pre-commit CI workflows (#211844) 2026-07-24 14:56:19 -04:00
.github [libc++] Rename pre-commit CI workflows (#211844) 2026-07-24 14:56:19 -04:00
bolt [BOLT] Fix pwrite assertion failure via a new safePWrite wrapper (#198569) 2026-07-24 19:55:26 +08:00
clang clang/AMDGPU: Migrate cc1 tests to subarch triples (5) (#211840) 2026-07-24 20:53:07 +02:00
clang-tools-extra [clang-tidy] Add performance-expensive-value-or check (#200166) 2026-07-24 00:33:39 +02:00
cmake Bump version to 24.0.0git (#209473) 2026-07-14 09:21:03 -04:00
compiler-rt [compiler-rt] FreeBSD kernel headers in baremetal libprofile (#211278) 2026-07-24 13:17:34 -04:00
cross-project-tests cross-project-tests: Migrate amdgpu tests to use subarch triples (#210115) 2026-07-24 17:38:34 +02:00
flang [flang][OpenMP] Fix alias analysis for omp.private copy region block arguments to help inline hlfir.assign to improve time taken in LTO. (#209539) 2026-07-24 13:56:30 -05:00
flang-rt [flang][cuda] Fix device-variable leaks and reset-safe cleanup (#209865) 2026-07-20 03:59:27 -07:00
libc [libc][termios] Make termios hermetic and fix its compatibility with glibc 2.42 or after. (#211039) 2026-07-24 13:31:41 -04:00
libclc libclc: Fix signed 0 handling in sincospi (#211260) 2026-07-23 06:24:44 +02:00
libcxx [libc++] Rename pre-commit CI workflows (#211844) 2026-07-24 14:56:19 -04:00
libcxxabi [runtimes] LLVM 24 version bumps (#211262) 2026-07-22 12:38:40 -04:00
libsycl [libsycl][NFC] Move the cmake msvc DLL check (#193485) 2026-07-20 16:55:25 +02:00
libunwind [libunwind][AArch64] Support .cfi_set_ra_state (#209950) 2026-07-23 11:46:36 -07:00
lld [NFC][test][ELF] Improve ppc32-ifunc-nonpreemptible-(no)pic.s (#210611) 2026-07-23 19:00:40 +01:00
lldb [lldb] Recover a WebAssembly function's mangled name from its declaration (#211707) 2026-07-24 13:40:25 -05:00
llvm AMDGPU: Reject unrecognized amdgpu subarch in TargetID parsing (#211866) 2026-07-24 18:52:13 +00:00
llvm-libgcc [docs] Finish misc MyST migration (#210209) 2026-07-17 11:56:59 -07:00
mlir [IR] Make semantics of strictfp consistent v2 (#211769) 2026-07-24 18:02:54 +00:00
offload [OFFLOAD][L0] Properly consume errors in program validation (#211799) 2026-07-24 16:49:57 +02:00
openmp FIX some OMPT tests that fail on RISC-V (#156914) 2026-07-24 11:24:36 +02:00
orc-rt [orc-rt] Add comment to clarify intended control flow. NFC. (#211454) 2026-07-23 13:25:32 +10:00
polly [Polly] Fix memory leak in DependenceAnalysis::Result::abandonDepende… (#211514) 2026-07-23 17:56:00 +05:30
runtimes Remove debug leftovers (#211068) 2026-07-21 23:23:13 -07:00
third-party Fix a warning and an uninitialized variable in benchmark (#200927) 2026-06-02 13:49:06 -07:00
utils [libc] Convert readv, writev, and read_write tests to use pipes (#210725) 2026-07-24 10:34:52 +02:00
.clang-format
.clang-format-ignore [Docs] Update coding standard for TD files (#200848) 2026-06-01 21:35:58 +01:00
.clang-tidy
.git-blame-ignore-revs Add "Split clang/lib/CodeGen/CGBuiltin.cpp" to .git-blame-ignore-revs (#203419) 2026-06-12 12:03:28 +01:00
.gitattributes
.gitignore gitignore: Add emacs lock files (#205055) 2026-06-22 18:19:29 +02:00
.mailmap mailmap: Add entries for Peter Collingbourne. (#210526) 2026-07-18 11:02:06 -07:00
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE.TXT
pyproject.toml [docs] Create utils/docs (#203962) 2026-06-24 15:12:48 -04:00
README.md [libc++] Rename pre-commit CI workflows (#211844) 2026-07-24 14:56:19 -04:00
SECURITY.md [SECURITY.md] add pointers to "what is a security issue" (#177372) 2026-01-22 17:19:09 -07:00

The LLVM Compiler Infrastructure

OpenSSF Scorecard OpenSSF Best Practices libc++

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.