LLVM/project 3eeb9b2flang/include/flang/Optimizer/Support AllocationPolicy.h, flang/include/flang/Optimizer/Transforms AllocationPlacementPolicy.h

[flang] add AllocationPolicy attribute to module and use it in InlineHLFIRCopy (#222013)

The StackArrays/AllocationPlacement pass cannot move fir.allocmem
created during InlineHLFIRCopy for the copy-in/cop-out buffers because
of there placement in branches.

Moving these allocmem outside of the branches is suboptimal as these
allocations may never occur at runtime (when the data is actually
already contiguous).
Extending the StackArrays pass is doable but very tedious (the data flow
analysis passes used in the pass cannot recognized "same
predicates"/understand that the two fir.if block that
allocate/deallocates will be both reached or never reached (even when
modifying InlineHLFIRCopy to use the same SSA value for both fir.if). So
this requires custom logic, and was adding 200 lines of non trivial code
to audit and I did not like it.

I decided to expose the allocation policy so that other passes can rely
on it. To make it the most flexible and future proof this is done via a

    [15 lines not shown]
DeltaFile
+146-0flang/include/flang/Optimizer/Support/AllocationPolicy.h
+130-0flang/test/HLFIR/inline-hlfir-copy-stack.fir
+119-0flang/lib/Optimizer/Support/AllocationPolicy.cpp
+102-16flang/lib/Optimizer/HLFIR/Transforms/InlineHLFIRCopy.cpp
+0-90flang/include/flang/Optimizer/Transforms/AllocationPlacementPolicy.h
+14-56flang/lib/Optimizer/Transforms/AllocationPlacement.cpp
+511-16218 files not shown
+766-20724 files

LLVM/project cb46e85llvm/lib/ExecutionEngine/JITLink ELF_riscv.cpp, llvm/test/ExecutionEngine/JITLink/RISCV ELF_relax_many_align.s

[JITLink][RISCV] Avoid quadratic removal of alignment edges (#222317)

We encountered this issue while using BOLT to instrument clang on
RISC-V. JITLink spent significant time removing alignment edges during
relaxation finalization in large code blocks with many alignment
relocations.

During RISC-V relaxation finalization, finalizeBlockRelax removes
AlignRelaxable edges individually from a block's edge vector. Each erase
shifts the remaining suffix, making this cleanup quadratic when the
number of alignment edges grows with the total edge count.

Compact surviving edges once and remove the trailing entries from the
back, preserving edge order and making cleanup linear. Count the
trailing entries before erasing to avoid comparing an invalidated
iterator.


These results support the performance benefit, but they come from

    [9 lines not shown]
DeltaFile
+29-0llvm/test/ExecutionEngine/JITLink/RISCV/ELF_relax_many_align.s
+9-6llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
+38-62 files

LLVM/project 46f9c22llvm/test/Transforms/Scalarizer bitcast-scalar-to-vector.ll bitcast-vector-to-scalar.ll

[Scalarizer] Update tests to use update_test_checks.py (#222460)

This PR is to address feedback on this comment:
https://github.com/llvm/llvm-project/pull/221033#discussion_r3973313815

requesting the tests use utils/update_test_checks.py instead.
DeltaFile
+24-18llvm/test/Transforms/Scalarizer/bitcast-vector-to-scalar.ll
+14-12llvm/test/Transforms/Scalarizer/bitcast-scalar-to-vector.ll
+38-302 files

LLVM/project cc45d4fllvm/test/Analysis/CostModel/X86 clmul.ll

[CostModel][X86] clmul.ll - add test coverage for vpclmulqdq targets (#222610)
DeltaFile
+48-23llvm/test/Analysis/CostModel/X86/clmul.ll
+48-231 files

LLVM/project 05d870boffload/include device.h, offload/libompaccsupport device.cpp

[offload][omp] Move strict threads & groups computation to libomptarget
DeltaFile
+177-3offload/libompaccsupport/device.cpp
+0-147offload/plugins-nextgen/common/src/PluginInterface.cpp
+7-63offload/plugins-nextgen/common/include/PluginInterface.h
+40-1offload/include/device.h
+9-9offload/test/offloading/ompx_bare_gridsize.c
+1-1offload/test/offloading/ompx_bare_multi_dim.cpp
+234-2242 files not shown
+235-2278 files

LLVM/project f47cf93offload/include device.h, offload/libompaccsupport PluginManager.cpp

[offload][omp] Move reading _kernel_environment to libomptarget
DeltaFile
+57-64offload/plugins-nextgen/common/include/PluginInterface.h
+26-47offload/plugins-nextgen/common/src/PluginInterface.cpp
+66-0offload/libompaccsupport/PluginManager.cpp
+19-0offload/include/device.h
+9-2offload/plugins-nextgen/cuda/src/rtl.cpp
+3-6offload/plugins-nextgen/common/src/RecordReplay.cpp
+180-1193 files not shown
+187-1259 files

LLVM/project f880fc1llvm/lib/Target/AMDGPU SIFixSGPRCopies.cpp

review: record the call in run to avoid re-scanning
DeltaFile
+12-13llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
+12-131 files

LLVM/project 19a9fd6llvm/lib/Target/AMDGPU SIFixSGPRCopies.cpp, llvm/test/CodeGen/AMDGPU ds_read2.ll merge-m0.mir

[AMDGPU] Don't merge M0 initializations across calls that clobber M0
DeltaFile
+133-0llvm/test/CodeGen/AMDGPU/merge-m0.mir
+18-5llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
+1-0llvm/test/CodeGen/AMDGPU/ds_read2.ll
+152-53 files

LLVM/project e4d4083llvm/include/llvm/Transforms/Utils CodeExtractor.h, llvm/lib/Frontend/OpenMP OMPIRBuilder.cpp

[OpenMP] Give the device shared memory allocations a debug location. (#221842)

Fixes https://github.com/llvm/llvm-project/issues/221831.

In generic mode on the device, the buffers that carry values into an
outlined region come from device shared memory rather than the stack, so
they are emitted as calls to `__kmpc_alloc_shared` and
`__kmpc_free_shared`. Those are definitions in the DeviceRTL, which
makes them inlinable calls, and the verifier requires an inlinable call
in a function with debug info to carry a !dbg location. None of these
calls had one, for two separate reasons.

1. `allocateVar()` and `deallocateVar()` took a bare insertion point, so
an override had no debug location to set on the runtime calls it emits
in place of the alloca the base class would have created. Fixed by
adding a `DebugLoc` parameter that carries one.

2. The `createOMPAllocShared `and `createOMPFreeShared` calls in
`createParallel` relied on the implicit conversion from an insertion

    [8 lines not shown]
DeltaFile
+43-0mlir/test/Target/LLVMIR/omptarget-debug-shared-alloc-loc.mlir
+20-15llvm/lib/Transforms/Utils/CodeExtractor.cpp
+14-7llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+4-2llvm/include/llvm/Transforms/Utils/CodeExtractor.h
+81-244 files

LLVM/project 11cf968llvm/utils/LLVMVisualizers llvm.natvis

[NATVIS] Fix ConstantInt APInt value access (#221719)

Ensure we peek through the APInt::U VAL / *pVal union
DeltaFile
+1-1llvm/utils/LLVMVisualizers/llvm.natvis
+1-11 files

LLVM/project 73f0077clang/lib/AST/ByteCode Compiler.cpp Pointer.h

Revert "[clang][bytecode] Use opaque pointers for decl-based dummy pointers" (#222599)

Reverts llvm/llvm-project#220917

Looks like this breaks some memory-sanitizier builders:
https://lab.llvm.org/buildbot/#/builders/169/builds/26405
https://lab.llvm.org/buildbot/#/builders/164/builds/25236
DeltaFile
+32-186clang/lib/AST/ByteCode/Interp.cpp
+27-80clang/lib/AST/ByteCode/Interp.h
+13-69clang/lib/AST/ByteCode/Pointer.cpp
+18-39clang/lib/AST/ByteCode/InterpBuiltin.cpp
+8-29clang/lib/AST/ByteCode/Pointer.h
+7-12clang/lib/AST/ByteCode/Compiler.cpp
+105-4158 files not shown
+123-44414 files

LLVM/project 38fb876llvm/lib/Transforms/Vectorize LoopVectorize.cpp

[LV][NFC] Move up getEpilogueTailLowering() (#222358)

This patch only moves up `getEpilogueTailLowering()` so that it can be
used by `planForEpilogueTF` as needed here: https://github.com/llvm/llvm-project/pull/208764
DeltaFile
+73-72llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+73-721 files

LLVM/project 26012d6llvm/test/Analysis/CostModel/X86 pdep.ll pext.ll

[CostModel][X86] Add baseline cost test for pdep/pext intrinsics (#222603)

Slow pdep/pext targets in particular are highly inaccurate
DeltaFile
+154-0llvm/test/Analysis/CostModel/X86/pdep.ll
+154-0llvm/test/Analysis/CostModel/X86/pext.ll
+308-02 files

LLVM/project 97d570doffload/include device.h, offload/libompaccsupport device.cpp

[offload][omp] Move strict threads & groups computation to libomptarget
DeltaFile
+177-3offload/libompaccsupport/device.cpp
+0-147offload/plugins-nextgen/common/src/PluginInterface.cpp
+7-63offload/plugins-nextgen/common/include/PluginInterface.h
+40-1offload/include/device.h
+9-9offload/test/offloading/ompx_bare_gridsize.c
+1-1offload/test/offloading/ompx_bare_multi_dim.cpp
+234-2242 files not shown
+235-2278 files

LLVM/project 3d08f9doffload/include device.h, offload/libompaccsupport PluginManager.cpp

[offload][omp] Move reading _kernel_environment to libomptarget
DeltaFile
+57-64offload/plugins-nextgen/common/include/PluginInterface.h
+26-47offload/plugins-nextgen/common/src/PluginInterface.cpp
+64-0offload/libompaccsupport/PluginManager.cpp
+19-0offload/include/device.h
+9-2offload/plugins-nextgen/cuda/src/rtl.cpp
+3-6offload/plugins-nextgen/common/src/RecordReplay.cpp
+178-1192 files not shown
+179-1258 files

LLVM/project abf3bd6clang/lib/CodeGen CGBuiltin.cpp, clang/test/DebugInfo/CXX verbose-trap.cpp

[clang][DebugInfo] Fix verbose trap source line (#222456)

The artificial inline location for `__builtin_verbose_trap` used line
zero. As a result, the emitted trap could inherit the preceding source
line in DWARF line tables.

Keep the artificial trap-message frame while assigning the builtin
call's line and column to the trap instruction.
DeltaFile
+4-4clang/test/DebugInfo/CXX/verbose-trap.cpp
+7-1clang/lib/CodeGen/CGBuiltin.cpp
+11-52 files

LLVM/project 365ad50llvm/lib/Transforms/Vectorize SLPVectorizer.cpp, llvm/lib/Transforms/Vectorize/SLPVectorizer SLPUtils.h SLPUtils.cpp

[SLP][modularisation][NFC] Move loop trip-count helpers to SLPUtils

Move the BoUpSLP-independent helpers findInnermostNonInvariantLoop and
getLoopTripCount out of SLPVectorizer.cpp into the self-contained
SLPVectorizer/SLPUtils.{h,cpp} module. getLoopTripCount reads the file-local
LoopAwareTripCount cl::opt, which stays static in SLPVectorizer.cpp and is
passed to the moved helper as an explicit parameter. NFC.

Part of the SLPVectorizer.cpp modularization effort:
https://discourse.llvm.org/t/modularizing-slpvectorizer-cpp/90922
DeltaFile
+2-34llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+33-0llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPUtils.cpp
+11-0llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPUtils.h
+46-343 files

LLVM/project 462e817clang/include/clang/Basic BuiltinsAMDGPU.td BuiltinsAMDGPUDocs.td, clang/test/CodeGenOpenCL builtins-amdgcn-gfx13-w32-err.cl builtins-amdgcn-gfx13-err.cl

[AMDGPU] Add intrinsics and builtins for v_cvt_scale_pk32_* instructions
DeltaFile
+1,308-0llvm/test/CodeGen/AMDGPU/llvm.amdgcn.cvt.scale.pk32.gfx13.ll
+60-0clang/include/clang/Basic/BuiltinsAMDGPUDocs.td
+58-0clang/test/CodeGenOpenCL/builtins-amdgcn-gfx13.cl
+26-0clang/test/CodeGenOpenCL/builtins-amdgcn-gfx13-err.cl
+24-0clang/include/clang/Basic/BuiltinsAMDGPU.td
+20-0clang/test/CodeGenOpenCL/builtins-amdgcn-gfx13-w32-err.cl
+1,496-07 files not shown
+1,546-913 files

LLVM/project fcd2f4allvm/lib/Transforms/Vectorize SLPVectorizer.cpp, llvm/lib/Transforms/Vectorize/SLPVectorizer SLPReductionUtils.h SLPReductionUtils.cpp

[SLP][modularisation][NFC] Move getReductionInstr/getAggregateSize to SLPReductionUtils

Move the BoUpSLP-independent helpers getReductionInstr and getAggregateSize
out of SLPVectorizer.cpp into the self-contained
SLPVectorizer/SLPReductionUtils.{h,cpp} module.

Part of the SLPVectorizer.cpp modularization effort:
https://discourse.llvm.org/t/modularizing-slpvectorizer-cpp/90922
DeltaFile
+0-79llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+77-0llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPReductionUtils.cpp
+16-0llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPReductionUtils.h
+93-793 files

LLVM/project e295581mlir/test/Integration/Dialect/Transform match_matmul.mlir

[MLIR]: Fix test after 70f5696e (#222601)

[MLIR]: Fix test after 70f5696e
DeltaFile
+1-1mlir/test/Integration/Dialect/Transform/match_matmul.mlir
+1-11 files

LLVM/project e46c2dbllvm/lib/Transforms/Vectorize SLPVectorizer.cpp, llvm/lib/Transforms/Vectorize/SLPVectorizer SLPUtils.h SLPUtils.cpp

[SLP][modularisation][NFC] Move isFirstInsertElement/getDebugLocFromPHI to SLPUtils

Move the BoUpSLP-independent helpers isFirstInsertElement and
getDebugLocFromPHI out of SLPVectorizer.cpp into the self-contained
SLPVectorizer/SLPUtils.{h,cpp} module.

Part of the SLPVectorizer.cpp modularization effort:
https://discourse.llvm.org/t/modularizing-slpvectorizer-cpp/90922
DeltaFile
+34-0llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPUtils.cpp
+0-33llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+12-0llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPUtils.h
+46-333 files

LLVM/project 05e74e7llvm/tools/opt optdriver.cpp opt.cpp

[opt] Move InitLLVM ownership to the standalone entry point (#222559)

Please Read: [RFC: Embeddable LLVM tool drivers for long-lived
hosts](https://discourse.llvm.org/t/rfc-embeddable-llvm-tool-drivers-for-long-lived-hosts/91754)
and [Why `InitLLVM` ownership matters section in the
RFC](https://discourse.llvm.org/t/rfc-embeddable-llvm-tool-drivers-for-long-lived-hosts/91754#p-367966-why-initllvm-ownership-matters-7)

`LLVMOptDriver` is already separated from the standalone `opt`
executable, but `optMain` currently constructs `InitLLVM` internally.
This means its destructor calls `llvm_shutdown()` whenever one driver
invocation finishes.

That is appropriate for a standalone executable, but not for a reusable
driver called by a long-lived host. For example,
[WasmBolt](https://github.com/anutosh491/WasmBolt) (try
[here](https://anutosh21.github.io/WasmBolt/)) invokes `opt`, `llc`,
Clang and LLD within one browser-hosted LLVM process and needs the LLVM
process state to remain alive between tool invocations.


    [15 lines not shown]
DeltaFile
+5-1llvm/tools/opt/opt.cpp
+0-3llvm/tools/opt/optdriver.cpp
+5-42 files

LLVM/project f3909e0llvm/test lit.cfg.py CMakeLists.txt, llvm/test/Transforms/Inline inlining-advisor-default.ll

[MLGO] Gate model tests on optimization-specific lit features (#217906)

### Context

`have_mlir_lowering` only indicates that `LLVM_MLGO_MODELS` is
non-empty. It does not identify which model type was compiled.

### Motivation

An inliner-only configuration incorrectly enabled regalloc-specific test
commands, and vice versa.

### Changes

Add `have_mlir_lowering_inliner` and `have_mlir_lowering_regalloc` lit
features derived from the corresponding model-generation targets. Update
MLGO tests to use the appropriate model-specific feature, including GN
configuration defaults.


I leveraged AI to write this PR.
DeltaFile
+10-0llvm/test/CMakeLists.txt
+3-3llvm/test/Transforms/Inline/inlining-advisor-default.ll
+3-3llvm/test/Transforms/Inline/ML/state-accounting-skip-non-cold.ll
+3-3llvm/test/Transforms/Inline/ML/enable-inline-advisor-printing-ml.ll
+3-3llvm/test/Transforms/Inline/ML/bounds-checks.ll
+6-0llvm/test/lit.cfg.py
+28-1211 files not shown
+51-3217 files

LLVM/project c632aa1offload/include device.h, offload/libompaccsupport device.cpp

[offload][omp] Move strict threads & groups computation to libomptarget
DeltaFile
+177-3offload/libompaccsupport/device.cpp
+0-147offload/plugins-nextgen/common/src/PluginInterface.cpp
+8-64offload/plugins-nextgen/common/include/PluginInterface.h
+40-1offload/include/device.h
+9-9offload/test/offloading/ompx_bare_gridsize.c
+1-1offload/test/offloading/ompx_bare_multi_dim.cpp
+235-2252 files not shown
+236-2288 files

LLVM/project 8ba1a86llvm/lib/Target/AMDGPU AMDGPU.td VOPInstructions.td, llvm/test/MC/AMDGPU gfx13_asm_vop3-fake16.s gfx13_asm_vop3.s

[AMDGPU] Add gfx13 MC support for v_cvt_scale_pk32_* instructions
DeltaFile
+220-0llvm/test/MC/AMDGPU/gfx13_asm_vop3_err.s
+121-0llvm/test/MC/AMDGPU/gfx13_asm_vop3.s
+120-0llvm/test/MC/AMDGPU/gfx13_asm_vop3-fake16.s
+18-0llvm/lib/Target/AMDGPU/VOP3Instructions.td
+7-0llvm/lib/Target/AMDGPU/VOPInstructions.td
+5-0llvm/lib/Target/AMDGPU/AMDGPU.td
+491-01 files not shown
+494-07 files

LLVM/project 0a678a8offload/include device.h, offload/libompaccsupport PluginManager.cpp

[offload][omp] Move reading _kernel_environment to libomptarget
DeltaFile
+59-66offload/plugins-nextgen/common/include/PluginInterface.h
+26-47offload/plugins-nextgen/common/src/PluginInterface.cpp
+64-0offload/libompaccsupport/PluginManager.cpp
+19-0offload/include/device.h
+3-6offload/plugins-nextgen/common/src/RecordReplay.cpp
+5-2offload/plugins-nextgen/cuda/src/rtl.cpp
+176-1212 files not shown
+177-1278 files

LLVM/project 5da4b50llvm/lib/Target/AMDGPU AMDGPULegalizerInfo.h AMDGPULegalizerInfo.cpp, llvm/test/CodeGen/AMDGPU trap.ll

[AMDGPU][GISel] Notify GISel observers when splitting trap blocks (#219128)

`legalizeTrapEndpgm` can split a MBB and move the instructions following
a trap. Since an instruction's parent block is part of its GISel CSE
profile, notify active observers around the moved instructions so they
are re-profiled with the new parent block.

CSE consistency gap exposed by #217258.

Assisted-by: Codex

---------

Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha at gmail.com>
Co-authored-by: GPT-5 Codex <noreply at openai.com>
DeltaFile
+21-7llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
+13-0llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-trap.mir
+7-0llvm/test/CodeGen/AMDGPU/trap.ll
+2-4llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.h
+43-114 files

LLVM/project 4394defllvm/lib/Target/AMDGPU AMDGPU.td, llvm/test/CodeGen/AMDGPU occupancy-levels.ll

[AMDGPU] Change physical VGPRs to 1024 for gfx13

GFX13 has 1024 physical VGPRs per SIMD in wave32 (512 in wave64)
DeltaFile
+34-30llvm/test/CodeGen/AMDGPU/occupancy-levels.ll
+0-1llvm/lib/Target/AMDGPU/AMDGPU.td
+34-312 files

LLVM/project bc25ad4mlir/lib/Conversion/ArithToEmitC ArithToEmitC.cpp, mlir/test/Conversion/ArithToEmitC arith-to-emitc.mlir

[mlir][emitc] Fix arith.{div,rem}ui index support (#221546)

These ops were failing to lower to emitc.{div,rem} when applied to index
operands since the code was:
- only checking for IntegerType, rejecting the !emitc.size_t into which
  IndexType is converted.
- using the original operands instead of the converted ops, creating
  unrealized_conversion_cast ops.
DeltaFile
+14-0mlir/test/Target/Cpp/arithmetic_operators.mlir
+4-4mlir/lib/Conversion/ArithToEmitC/ArithToEmitC.cpp
+4-0mlir/test/Conversion/ArithToEmitC/arith-to-emitc.mlir
+22-43 files

LLVM/project c52a343clang/test/Frontend optimization-remark-target-features-arm.c optimization-remark-target-features-aarch64.c, llvm/lib/CodeGen/AsmPrinter AsmPrinter.cpp

[AsmPrinter] add optimisation remark for target-features (#222074)

In clang we have `--print-enabled-extensions` which will print the
AArch64 extensions enabled for a given TU. However, sometimes it is
useful to be able to print out the actual subtarget features for each
function, for debugging/testing purposes. Add an optimisation remark for
that.
DeltaFile
+45-0llvm/test/CodeGen/AArch64/optimization-remark-target-features.ll
+30-0clang/test/Frontend/optimization-remark-target-features-aarch64.c
+30-0llvm/test/CodeGen/ARM/optimization-remark-target-features.ll
+19-0clang/test/Frontend/optimization-remark-target-features-arm.c
+17-0llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+141-05 files