LLVM/project c053903clang-tools-extra/clang-tidy/cppcoreguidelines AvoidNonConstGlobalVariablesCheck.cpp AvoidNonConstGlobalVariablesCheck.h, clang-tools-extra/docs ReleaseNotes.rst

[clang-tidy] Adds `IgnoreMacros` option to cppcoreguidelines-avoid-non-const-global-variables (#198183)

Adds `IgnoreMacros` option to
[cppcoreguidelines-avoid-non-const-global-variables](https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.html)
DeltaFile
+28-0clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-non-const-global-variables-macros.cpp
+14-4clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
+5-0clang-tools-extra/docs/ReleaseNotes.rst
+5-0clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst
+1-0clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.h
+53-45 files

LLVM/project 118bcb3

[NFC] Reland "[llvm-ir2vec] Place IR2Vec Python bindings in the tools/llvm-ir2vec/Bindings build directory (#194301)" (#198752)
DeltaFile
+0-00 files

LLVM/project dd1649blibc/src/__support/macros optimization.h, libc/test/UnitTest FPMatcher.h

[libc][NFC] Make LIBC_MATH safer and some minor improvements for floating point exception tests. (#199392)

- Wrap LIBC_MATH usages inside parentheses
- Skip clearing exceptions when not needed.
- Skip FE_INEXACT when testing FE_UNDERFLOW / FE_OVERFLOW for basic ops.
DeltaFile
+58-28libc/test/UnitTest/FPMatcher.h
+26-36libc/test/src/math/smoke/SubTest.h
+26-36libc/test/src/math/smoke/MulTest.h
+24-32libc/test/src/math/smoke/DivTest.h
+21-26libc/test/src/math/smoke/AddTest.h
+5-5libc/src/__support/macros/optimization.h
+160-1635 files not shown
+167-17011 files

LLVM/project 0ee8a37llvm/lib/Target/X86 X86ISelLowering.cpp, llvm/test/CodeGen/X86 ldexp-avx512.ll fold-int-pow2-with-fmul-or-fdiv.ll

[X86] LowerFLDEXP: convert widened int exponent to FP before SCALEF (#199263)

For vector ldexp cases that LowerFLDEXP implements by widening to a
512-bit SCALEF operation, the code widened both X and Exp but passed
the widened integer exponent directly to SCALEF, which interprets
its inputs as IEEE-754 floats.

Convert the widened integer exponent to FP and pass that to SCALEF.

Reproducer (clang -O2 -mavx512f repro.c -o repro && ./repro):

```
  #include <stdio.h>
  typedef float v4f __attribute__((vector_size(16)));
  typedef int v4i __attribute__((vector_size(16)));

  __attribute__((noinline))
  v4f ldexp_v4(v4f x, v4i e) {
    return __builtin_elementwise_ldexp(x, e);

    [22 lines not shown]
DeltaFile
+30-17llvm/test/CodeGen/X86/ldexp-avx512.ll
+11-3llvm/lib/Target/X86/X86ISelLowering.cpp
+2-0llvm/test/CodeGen/X86/fold-int-pow2-with-fmul-or-fdiv.ll
+43-203 files

LLVM/project 7e2d09dclang/test/Headers __clang_hip_math.hip, llvm/test/Analysis/CostModel/X86 reduce-smax.ll reduce-smin.ll

Merge branch 'main' into users/spavloff/snan
DeltaFile
+647-736clang/test/Headers/__clang_hip_math.hip
+591-509llvm/test/FileCheck/dump-input/annotations.txt
+607-0llvm/test/CodeGen/RISCV/GlobalISel/irtranslator/fixed-vectors-calling-conv.ll
+150-150llvm/test/Analysis/CostModel/X86/reduce-smax.ll
+150-150llvm/test/Analysis/CostModel/X86/reduce-smin.ll
+150-150llvm/test/Analysis/CostModel/X86/reduce-umax.ll
+2,295-1,695337 files not shown
+7,379-4,198343 files

LLVM/project 78cbf39compiler-rt/lib/builtins atomic.c, compiler-rt/test/builtins/Unit atomic_test.c

[compiler-rt] Use `size_t` rather than `int` for first argument to `__atomic_load_c` et al. (#197519)

I noticed this discrepancy in emscripten when trying to test 128 bit
atomics under wasm64:
https://github.com/emscripten-core/emscripten/pull/26937

The LLVM CodeGen appears to use `size_t` in this position when it
generates calls to these functions.

This doesn't effect other platforms I imagine because they don't require
signature checking at the linker level.

This doesn't effect wasm32 where size_t and int are the same size.
DeltaFile
+6-6compiler-rt/test/builtins/Unit/atomic_test.c
+5-4compiler-rt/lib/builtins/atomic.c
+11-102 files

LLVM/project c06755ebolt/lib/Profile DataAggregator.cpp

pj

Created using spr 1.3.4
DeltaFile
+2-2bolt/lib/Profile/DataAggregator.cpp
+2-21 files

LLVM/project b9a1e89bolt/lib/Profile DataAggregator.cpp

pj

Created using spr 1.3.4
DeltaFile
+7-2bolt/lib/Profile/DataAggregator.cpp
+7-21 files

LLVM/project 02f7369libcxx/include __verbose_trap

[libc++] Remove AppleClang woraround for __builtin_verbose_trap (#199171)

We've dropped support for AppleClang versions with a different
`__builtin_verbose_trap`, so we can remove the workaround.
DeltaFile
+1-8libcxx/include/__verbose_trap
+1-81 files

LLVM/project fd45c0bllvm/utils/lit/tests/unit Util.py

Revert "[AIX] Remove unsupported AIX native echo option -n (llvm#199079)" (#199277)

This reverts commit 593eb2066293c8636786c98cb696c533da9b97ca.
The patch is being reverted as the code changes and the commit message
and description do not match and point to a previous implementation

Co-authored-by: himadhith <himadhith.v at ibm.com>
DeltaFile
+2-2llvm/utils/lit/tests/unit/Util.py
+2-21 files

LLVM/project 38146ceclang/docs LanguageExtensions.rst, clang/lib/CodeGen CodeGenModule.cpp CodeGenModule.h

[PowerPC][AIX] Add -mloadtime-comment-vars support to preserve variables
in the final object file.
DeltaFile
+168-74llvm/lib/Transforms/Utils/LowerCommentStringPass.cpp
+77-0clang/lib/CodeGen/CodeGenModule.cpp
+67-0clang/docs/LanguageExtensions.rst
+37-0clang/test/CodeGen/loadtime-comment-vars.c
+34-0llvm/test/Transforms/LowerCommentString/loadtime-comment-vars.ll
+8-0clang/lib/CodeGen/CodeGenModule.h
+391-743 files not shown
+406-749 files

LLVM/project 268182aclang/docs LanguageExtensions.rst, clang/lib/CodeGen CodeGenModule.cpp CodeGenModule.h

[PowerPC][AIX] Add -mloadtime-comment-vars support to preserve variables
in the final object file.
DeltaFile
+155-74llvm/lib/Transforms/Utils/LowerCommentStringPass.cpp
+77-0clang/lib/CodeGen/CodeGenModule.cpp
+67-0clang/docs/LanguageExtensions.rst
+37-0clang/test/CodeGen/loadtime-comment-vars.c
+34-0llvm/test/Transforms/LowerCommentString/loadtime-comment-vars.ll
+8-0clang/lib/CodeGen/CodeGenModule.h
+378-743 files not shown
+393-749 files

LLVM/project a31b969clang/docs LanguageExtensions.rst, clang/lib/CodeGen CodeGenModule.cpp CodeGenModule.h

[PowerPC][AIX] Add -mloadtime-comment-vars support to preserve variables
in the final object file.
DeltaFile
+154-74llvm/lib/Transforms/Utils/LowerCommentStringPass.cpp
+77-0clang/lib/CodeGen/CodeGenModule.cpp
+67-0clang/docs/LanguageExtensions.rst
+37-0clang/test/CodeGen/loadtime-comment-vars.c
+34-0llvm/test/Transforms/LowerCommentString/loadtime-comment-vars.ll
+8-0clang/lib/CodeGen/CodeGenModule.h
+377-743 files not shown
+392-749 files

LLVM/project 22d9a5dllvm/utils/lit/lit TestRunner.py cl_arguments.py, llvm/utils/lit/tests fn-selection.py

Add --fn flag to llvm-lit to inject select-function pass into opt pipelines

Translates --fn=fn0,fn1 into -passes='select-function<fn=fn0;fn=fn1>,...'
by rewriting -passes= arguments in RUN lines after substitution.
Handles both single and double quoted pass pipelines.
DeltaFile
+23-0llvm/utils/lit/tests/fn-selection.py
+19-0llvm/utils/lit/lit/TestRunner.py
+17-0llvm/utils/lit/lit/cl_arguments.py
+7-0llvm/utils/lit/tests/Inputs/fn-selection/lit.cfg
+2-0llvm/utils/lit/lit/LitConfig.py
+2-0llvm/utils/lit/tests/Inputs/fn-selection/sample.ll
+70-01 files not shown
+71-07 files

LLVM/project 9e0c7f4llvm/include/llvm/Transforms/IPO SelectFunction.h, llvm/lib/Passes PassBuilder.cpp

Add select-function pass to keep only specified functions and their dependencies

Chains InternalizePass, GlobalDCEPass, and StripDeadPrototypesPass to
remove everything not transitively reachable from the selected functions.
Supports multiple roots via select-function<fn=foo;fn=bar>.
DeltaFile
+57-0llvm/test/Transforms/SelectFunction/multi-select.ll
+52-0llvm/include/llvm/Transforms/IPO/SelectFunction.h
+48-0llvm/lib/Transforms/IPO/SelectFunction.cpp
+36-0llvm/test/Transforms/SelectFunction/basic.ll
+35-0llvm/test/Transforms/SelectFunction/diamond.ll
+23-0llvm/lib/Passes/PassBuilder.cpp
+251-04 files not shown
+289-010 files

LLVM/project 5727dadoffload/test lit.cfg

[offload] Fix --libomptarget-nvptx-bc-path in tests

PR #198622, which landed as 3383f0d6fe01, causes 272 `libomptarget ::
nvptx64-nvidia-cuda` test fails on my system with:

```
clang: error: bitcode library '/home/jdenny/llvm/build/\./lib/x86_64-unknown-linux-gnu/nvptx64-nvidia-cuda' does not exist
```

This patch fixes that.
DeltaFile
+1-1offload/test/lit.cfg
+1-11 files

LLVM/project f95ccballvm/lib/Target/RISCV RISCVRegisterInfo.cpp, llvm/test/CodeGen/RISCV fixed-x27-crash.ll

[RISCV] Reserve all sub-registers of user reserved GPRs (#199302)

When a GPR is reserved by the user (e.g., via  `-mattr=+reserve-x27`)
or marked as constant, only the top-level register was being marked
reserved in `RISCVRegisterInfo::getReservedRegs`. Its sub-registers
(`X27_W` and `X27_H`) remained unreserved.

This broke `LiveIntervals` when register pressure tracking was enabled
by #115445. Because the sub-registers were not reserved, the register
unit was considered non-reserved, causing `LiveIntervals` to track its
liveness and crash in the Machine Verifier due to the reserved
register missing from basic block live-in lists.

Instead, we should ensure that reserving a register also reserves all
of its sub-registers, so that the register unit is correctly
identified as reserved and ignored by `LiveIntervals`.

Fixes #176227
DeltaFile
+16-0llvm/test/CodeGen/RISCV/fixed-x27-crash.ll
+8-4llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
+24-42 files

LLVM/project 8b56d41llvm/lib/Transforms/Vectorize LoopVectorize.cpp

[VPlan] Create casts before ComputeReductionResult (NFC). (#199372)

This ensures ComputeReductionResult is created with operands that have
their correct types set at construction.
DeltaFile
+30-34llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+30-341 files

LLVM/project 5ccea57llvm/utils/gn/secondary/clang/lib/CodeGen BUILD.gn, llvm/utils/gn/secondary/lldb/source/Target BUILD.gn

[gn build] Port commits (#199375)

170d37d861b0
1b0e603087b6
9997b11c6469
DeltaFile
+1-0llvm/utils/gn/secondary/llvm/lib/TargetParser/BUILD.gn
+1-0llvm/utils/gn/secondary/lldb/source/Utility/BUILD.gn
+0-1llvm/utils/gn/secondary/lldb/source/Target/BUILD.gn
+1-0llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn
+3-14 files

LLVM/project 7bf2d97clang/docs LanguageExtensions.rst, clang/lib/CodeGen CodeGenModule.cpp CodeGenModule.h

[PowerPC][AIX] Add -mloadtime-comment-vars support to preserve variables
in the final object file.
DeltaFile
+154-74llvm/lib/Transforms/Utils/LowerCommentStringPass.cpp
+77-0clang/lib/CodeGen/CodeGenModule.cpp
+67-0clang/docs/LanguageExtensions.rst
+37-0clang/test/CodeGen/loadtime-comment-vars.c
+34-0llvm/test/Transforms/LowerCommentString/loadtime-comment-vars.ll
+8-0clang/lib/CodeGen/CodeGenModule.h
+377-743 files not shown
+392-749 files

LLVM/project 5c6af83llvm/lib/Transforms/Vectorize LoopVectorizationLegality.cpp, llvm/test/Transforms/LoopVectorize optsize.ll

[LV] Don't add stride SCEV predicates when runtime checks are disabled. (#199370)

Don't pass symbolic strides to getPtrStride if SCEV runtime checks are
not allowed (e.g. because optimizing for size). This prevents
getPtrStride from adding additional SCEV checks for symbolic strides.
DeltaFile
+30-20llvm/test/Transforms/LoopVectorize/optsize.ll
+5-3llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+35-232 files

LLVM/project 0344e9fllvm/lib/Transforms/Vectorize LoopVectorize.cpp VPlan.h

[VPlan] Thread types through VPHeaderPHIRecipe and VPDerivedIVRecipe (NFC) (#195894)

Update VPHeaderPHIRecipe and VPDerivedIVRecipe to set the scalar types
for their defined values.

This requires updating addReductionResultComputation to construct the
new chain for AnyOf reductions up-front.

Depends on https://github.com/llvm/llvm-project/pull/195891

PR: https://github.com/llvm/llvm-project/pull/195894
DeltaFile
+37-20llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+21-14llvm/lib/Transforms/Vectorize/VPlan.h
+1-12llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
+11-0llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
+2-2llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+72-485 files

LLVM/project a992929llvm/lib/Transforms/Utils LowerCommentStringPass.cpp

Apply changes from code browser

Apply changes from code browser
DeltaFile
+53-24llvm/lib/Transforms/Utils/LowerCommentStringPass.cpp
+53-241 files

LLVM/project aaf3e32clang/include/clang/Options Options.td, clang/lib/CodeGen CodeGenModule.cpp CodeGenModule.h

[PowerPC][AIX] Add -mloadtime-comment-vars support
DeltaFile
+88-54llvm/lib/Transforms/Utils/LowerCommentStringPass.cpp
+78-0clang/lib/CodeGen/CodeGenModule.cpp
+28-0clang/test/CodeGen/loadtime-comment-vars.c
+26-0llvm/test/Transforms/LowerCommentString/loadtime-comment-vars.ll
+8-0clang/lib/CodeGen/CodeGenModule.h
+7-0clang/include/clang/Options/Options.td
+235-542 files not shown
+243-548 files

LLVM/project 47e6290llvm/lib/Transforms/Utils SimplifyLibCalls.cpp, llvm/test/Transforms/InstCombine fmod.ll

[SimplifyLibCalls] Don't set nnan on synthesized frem in optimizeFMod (#199284)

LibCallSimplifier can fold a libcall to fmod to an frem instruction if
the fmod call doesn't set errno.

fmod(x, y) sets errno if x == +/-Inf or y == 0.  The old code assumed
that this was also a sufficient condition to prove that the result is
not NaN, and so unconditionally set the nnan fmf on the new frem
instruction.  That's not sound; e.g. fmod(x, NaN) == frem(x, NaN) ==
NaN.

We don't actually have to worry about propagating the `nnan` flag;
B.CreateFRemFMF does it for us automagically.

This bug was found by a large run of Opus 4.7 looking for bugs in LLVM.
DeltaFile
+19-5llvm/test/Transforms/InstCombine/fmod.ll
+7-12llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+26-172 files

LLVM/project 6d3bc00llvm/lib/Transforms/Utils SimplifyLibCalls.cpp, llvm/test/Transforms/InstCombine fdim.ll

[SimplifyLibCalls] Fix optimizeFdim for Inf-Inf cases (#199306)

fdim(x,y) is defined as

    NaN if x or y is NaN, otherwise
    (x > y) ? x - y : +0

optimizeFdim computed fdim(x,y) as max(x-y, +0).  This is not correct
when x == y == +/-Inf; the result should be 0, but this optimization
returns NaN.

I was surprised by this bug because there's even a testcase checking the
incorrect behavior.  But returning 0 matches the description in C99 and
POSIX, where, just to be extra clear, the spelling of the piecewise
function is

    NaN if either input is NaN
    x - y if x > y
    +0    if x <= y

    [4 lines not shown]
DeltaFile
+9-1llvm/test/Transforms/InstCombine/fdim.ll
+4-4llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+13-52 files

LLVM/project 9d533e9clang/tools/libclang CIndex.cpp

[clang] Fix crash in getCursorRawComments. (#199328)

Fix a regression introduced in PR #198452 where querying raw comments on
invalid cursors caused a segmentation fault due to unconditional
ASTContext lookup. Adding an early exit for unsupported cursor kinds at
the top of getCursorRawComment safely avoids resolving the context on
invalid cursors with null translation units.
DeltaFile
+2-0clang/tools/libclang/CIndex.cpp
+2-01 files

LLVM/project 37a2205llvm/lib/Transforms/Vectorize LoopVectorize.cpp, llvm/test/Transforms/LoopVectorize/X86/CostModel masked-interleaved-store-i16.ll

[LV] Determine NumPredStores before computing widening costs. (#199341)

Determine NumPredStores before computing widening costs, so we
consistently apply large predicated store cost to all stores, matching
the VPlan cost model. In practice that should not impact vectorization
decisions, as the huge cost for any predicated store other than the
first already effectively disables vectorization.
DeltaFile
+10-7llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+4-4llvm/test/Transforms/LoopVectorize/X86/CostModel/masked-interleaved-store-i16.ll
+14-112 files

LLVM/project 494c9d9clang/docs LanguageExtensions.rst, llvm/lib/Analysis ModuleSummaryAnalysis.cpp

[Analysis][AIX] Add !implicit.ref globals as ThinLTO summary ref edges to support pragma comment(copyright) LTO interaction

Teach ModuleSummaryAnalysis to include globals referenced via
!implicit.ref metadata as explicit reference edges in the ThinLTO
module summary via a new helper findImplicitRefEdges.
DeltaFile
+89-0llvm/test/LTO/PowerPC/pragma-comment-copyright-thinlto.ll
+52-34llvm/test/LTO/PowerPC/pragma-comment-copyright-lto.ll
+39-0llvm/test/Analysis/ModuleSummaryAnalysis/implicit-ref-edges.ll
+32-0clang/docs/LanguageExtensions.rst
+24-0llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+236-345 files

LLVM/project c089860llvm/test/LTO/PowerPC pragma-comment-copyright-lto.ll

[LTO] [Test] Add full lto test llvm/test/LTO/PowerPC/pragma-comment-copyright-lto.ll.
DeltaFile
+67-0llvm/test/LTO/PowerPC/pragma-comment-copyright-lto.ll
+67-01 files