UnstableChanges

Summary

  1. [llvm-link] Fix for an assertion when linking global with appending linkage (details)
  2. [RISCV][PrologEpilogInserter] "Float" emergency spill slots to avoid making them immediately unreachable from the stack pointer (details)
  3. [Support] TrigramIndex::insert - pass std::String argument by const reference. NFCI. (details)
  4. [InlineFunction] Use llvm.experimental.noalias.scope.decl for noalias arguments. (details)
  5. [LTO] Store target attributes as vector of strings (NFC). (details)
  6. [LSR] Add test for PR46943 (NFC) (details)
  7. [Clang] Move assembler into a separate file (details)
  8. [gn build] Port 2325157c0568 (details)
  9. [SimplifyCFG] Change 'LoopHeaders' to be ArrayRef<WeakVH>, not a naked set, thus avoiding dangling pointers (details)
  10. Revert "[Clang] Move assembler into a separate file" (details)
  11. [gn build] Port 0057cc5a215e (details)
  12. [lldb/Lua] add initial Lua typemaps (details)
  13. [lldb/Lua] add 'Lua' before naming versions (details)
  14. [AVR] Optimize 8-bit logic left/right shifts (details)
  15. [Local] Treat calls that may not return as being alive. (details)
  16. [SLP] add reduction test with mixed fast-math-flags; NFC (details)
  17. [SLP] fix fast-math-flag propagation on FP reductions (details)
  18. [AVR] Optimize 16-bit comparison with constant (details)
  19. [ASan] Fix broken Windows build due to 596d534ac3524052df210be8d3c01a33b2260a42. (details)
  20. [libc++] Implements concept destructible (details)
  21. [InstCombine] Set MadeIRChange in replaceInstUsesWith. (details)
Commit 267a57a64572cffbb74599878bdcc9f3b678ffa3 by serguei.n.dmitriev
[llvm-link] Fix for an assertion when linking global with appending linkage

This patch fixes llvm-link assertion when linking external variable
declaration with a definition with appending linkage.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D95126
The file was addedllvm/test/Linker/appending-global-err5.ll
The file was addedllvm/test/Linker/appending-global-err4.ll
The file was addedllvm/test/Linker/Inputs/appending-global.ll
The file was addedllvm/test/Linker/appending-global-err2.ll
The file was modifiedllvm/lib/Linker/LinkModules.cpp
The file was modifiedllvm/lib/Linker/IRMover.cpp
The file was addedllvm/test/Linker/appending-global-err1.ll
The file was addedllvm/test/Linker/appending-global-proto.ll
The file was addedllvm/test/Linker/appending-global-err3.ll
Commit d4ce062340064c3f73b8f6136c7350a5abe83cac by roger.ferrer
[RISCV][PrologEpilogInserter] "Float" emergency spill slots to avoid making them immediately unreachable from the stack pointer

In RISC-V there is a single addressing mode of the form imm(reg) where
imm is a signed integer of 12-bit with a range of [-2048..2047] bytes
from reg.

The test MultiSource/UnitTests/C++11/frame_layout of the LLVM test-suite
exercises several scenarios with the stack, including function calls
where the stack will need to be realigned to to a local variable having
a large alignment of 4096 bytes.

In situations of large stacks, the RISC-V backend (in
RISCVFrameLowering) reserves an extra emergency spill slot which can be
used (if no free register is found) by the register scavenger after the
frame indexes have been eliminated. PrologEpilogInserter already takes
care of keeping the emergency spill slots as close as possible to the
stack pointer or frame pointer (depending on what the function will
use). However there is a final alignment step to honour the maximum
alignment of the stack that, when using the stack pointer to access the
emergency spill slots, has the side effect of setting them farther from
the stack pointer.

In the case of the frame_layout testcase, the net result is that we do
have an emergency spill slot but it is so far from the stack pointer
(more than 2048 bytes due to the extra alignment of a variable to 4096
bytes) that it becomes unreachable via any immediate offset.

During elimination of the frame index, many (regular) offsets of the
stack may be immediately unreachable already. Their address needs to be
computed using a register. A virtual register is created and later
RegisterScavenger should be able to find an unused (physical) register.
However if no register is available, RegisterScavenger will pick a
physical register and spill it onto an emergency stack slot, while we
compute the offset (restoring the chosen register after all this). This
assumes that the emergency stack slot is easily reachable (this is,
without requiring another register!).

This is the assumption we seem to break when we perform the extra
alignment in PrologEpilogInserter.

We can "float" the emergency spill slots by increasing (in absolute
value) their offsets from the incoming stack pointer. This way the
emergency spill slots will remain close to the stack pointer (once the
function has allocated storage for the stack, including the needed
realignment). The new size computed in PrologEpilogInserter is padding
so it should be OK to move the emergency spill slots there. Also because
we're increasing the alignment, the new location should stay aligned for
the purpose of the emergency spill slots.

Note that this change also impacts other backends as shown by the tests.
Changes are minor adjustments to the emergency stack slot offset.

Differential Revision: https://reviews.llvm.org/D89239
The file was modifiedllvm/test/CodeGen/Thumb/emergency-spill-slot.ll
The file was addedllvm/test/CodeGen/RISCV/out-of-reach-emergency-slot.mir
The file was modifiedllvm/test/CodeGen/AArch64/framelayout-scavengingslot.mir
The file was modifiedllvm/test/CodeGen/AArch64/framelayout-sve-scavengingslot.mir
The file was modifiedllvm/lib/CodeGen/PrologEpilogInserter.cpp
The file was modifiedllvm/test/CodeGen/AArch64/swiftself-scavenger.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/pei-scavenge-vgpr-spill.mir
Commit 344afa853fcfcc085cb5c957b4a07c7ea013bb1b by llvm-dev
[Support] TrigramIndex::insert - pass std::String argument by const reference. NFCI.

Avoid string copies and fix clang-tidy warning.
The file was modifiedllvm/lib/Support/TrigramIndex.cpp
The file was modifiedllvm/include/llvm/Support/TrigramIndex.h
Commit 2b9a834c43cb1f93d33958c14b695896bb4e9c1e by jeroen.dobbelaere
[InlineFunction] Use llvm.experimental.noalias.scope.decl for noalias arguments.

Insert a llvm.experimental.noalias.scope.decl intrinsic that identifies where a noalias argument was inlined.

This patch includes some refactorings from D90104.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D93040
The file was modifiedllvm/test/Transforms/PhaseOrdering/instcombine-sroa-inttoptr.ll
The file was modifiedllvm/lib/Transforms/Utils/InlineFunction.cpp
The file was modifiedllvm/test/Transforms/Coroutines/coro-retcon.ll
The file was modifiedllvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
The file was modifiedllvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
The file was modifiedclang/test/CodeGen/aarch64-ls64.c
The file was modifiedllvm/test/Transforms/Coroutines/ArgAddr.ll
The file was modifiedllvm/test/Transforms/Inline/noalias2.ll
The file was modifiedllvm/test/Transforms/Inline/noalias-calls.ll
The file was modifiedllvm/test/Transforms/Inline/launder.invariant.group.ll
The file was modifiedllvm/test/Transforms/Inline/noalias.ll
The file was modifiedllvm/test/Transforms/PhaseOrdering/pr39282.ll
The file was modifiedllvm/test/Transforms/Coroutines/ex2.ll
The file was modifiedllvm/test/Transforms/Inline/noalias-cs.ll
The file was modifiedllvm/test/Transforms/Coroutines/ex3.ll
The file was modifiedllvm/test/Transforms/Coroutines/ex4.ll
The file was modifiedllvm/test/Transforms/Coroutines/coro-retcon-value.ll
The file was addedllvm/test/Transforms/Inline/noalias-calls2.ll
The file was modifiedllvm/test/Transforms/Inline/noalias-calls-always.ll
Commit 08dbcc14e254396cd5765994cab97274003611bb by flo
[LTO] Store target attributes as vector of strings (NFC).

The target features are obtained as a list of features/attributes.
Instead of storing them in a single string, store the vector. This
matches lto::Config's behavior and simplifies the transition to
lto::backend().

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D95224
The file was modifiedllvm/lib/LTO/LTOCodeGenerator.cpp
The file was modifiedllvm/tools/lto/lto.cpp
The file was modifiedllvm/tools/llvm-lto/llvm-lto.cpp
The file was modifiedllvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
Commit a49a3a3ed568244b12d6f553240485696e084f4a by nikita.ppv
[LSR] Add test for PR46943 (NFC)

LSR should be dropping nowrap flags when adding new postinc users.
The file was addedllvm/test/Transforms/LoopStrengthReduce/X86/pr46943.ll
Commit 2325157c0568ffd16f3318ad54f947e4e2109ef6 by aykevanlaethem
[Clang] Move assembler into a separate file

This change adds an AssemblerInvocation class, similar to the
CompilerInvocation class. It can be used to invoke cc1as directly.

The project I'm working on wants to compile Clang and use it as a static
library. For that to work, there must be a way to invoke the assembler
programmatically, using the same arguments as you would otherwise pass
to cc1as.

Differential Revision: https://reviews.llvm.org/D63852
The file was modifiedclang/tools/driver/cc1as_main.cpp
The file was modifiedclang/lib/Frontend/CMakeLists.txt
The file was addedclang/include/clang/Frontend/AssemblerInvocation.h
The file was addedclang/lib/Frontend/AssemblerInvocation.cpp
Commit dbf87da739ba8ce4a3abc1f893045006a62eecbf by llvmgnsyncbot
[gn build] Port 2325157c0568
The file was modifiedllvm/utils/gn/secondary/clang/lib/Frontend/BUILD.gn
Commit 022da61f6b30626708e5b4c1c009afb453d12ebe by lebedev.ri
[SimplifyCFG] Change 'LoopHeaders' to be ArrayRef<WeakVH>, not a naked set, thus avoiding dangling pointers

If i change it to AssertingVH instead, a number of existing tests fail,
which means we don't consistently remove from the set when deleting blocks,
which means newly-created blocks may happen to appear in that set
if they happen to occupy the same memory chunk as did some block
that was in the set originally.

There are many places where we delete blocks,
and while we could probably consistently delete from LoopHeaders
when deleting a block in transforms located in SimplifyCFG.cpp itself,
transforms located elsewhere (Local.cpp/BasicBlockUtils.cpp) also may
delete blocks, and it doesn't seem good to teach them to deal with it.

Since we at most only ever delete from LoopHeaders,
let's just delegate to WeakVH to do that automatically.

But to be honest, personally, i'm not sure that the idea
behind LoopHeaders is sound.
The file was modifiedllvm/include/llvm/Transforms/Utils/Local.h
The file was modifiedllvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
The file was modifiedllvm/lib/Transforms/Utils/SimplifyCFG.cpp
Commit 0057cc5a215e5a26cfbd7e1707b55bf05fa9b6bf by aykevanlaethem
Revert "[Clang] Move assembler into a separate file"

This reverts commit 2325157c0568ffd16f3318ad54f947e4e2109ef6.

Unfortunately this commit produces linker errors on some builds:
http://lab.llvm.org:8011/#/builders/57/builds/3704
http://lab.llvm.org:8011/#/builders/112/builds/3216
http://lab.llvm.org:8011/#/builders/121/builds/3900
The file was removedclang/lib/Frontend/AssemblerInvocation.cpp
The file was modifiedclang/tools/driver/cc1as_main.cpp
The file was modifiedclang/lib/Frontend/CMakeLists.txt
The file was removedclang/include/clang/Frontend/AssemblerInvocation.h
Commit d5c4de40c679f07c575db1fb5c5893cb93b3d30e by llvmgnsyncbot
[gn build] Port 0057cc5a215e
The file was modifiedllvm/utils/gn/secondary/clang/lib/Frontend/BUILD.gn
Commit 5997e8987f681c54c266ab2d422528de9235b25f by pctammela
[lldb/Lua] add initial Lua typemaps

This patch adds the integer handling typemaps and the typemap for
string returning functions.

The integer handling typemaps overrides SWIG's own typemaps to distinct
the handling of integers from floating point.

The typemap for string returning functions is a port of Python's
typemap.

Differential Revision: https://reviews.llvm.org/D94937
The file was modifiedlldb/bindings/lua/lua-typemaps.swig
Commit 2bbc762b8ff843cab89230c0a5feeb801c21c376 by pctammela
[lldb/Lua] add 'Lua' before naming versions

NFC
The file was modifiedlldb/bindings/lua/lua-typemaps.swig
Commit 25531a1d9657897e648d93f776a3abb70e9816ef by powerman1st
[AVR] Optimize 8-bit logic left/right shifts

Reviewed By: dylanmckay

Differential Revision: https://reviews.llvm.org/D89047
The file was modifiedllvm/lib/Target/AVR/AVRISelLowering.h
The file was modifiedllvm/test/CodeGen/AVR/shift.ll
The file was modifiedllvm/test/CodeGen/AVR/cttz.ll
The file was modifiedllvm/test/CodeGen/AVR/ctlz.ll
The file was modifiedllvm/lib/Target/AVR/AVRInstrInfo.td
The file was modifiedllvm/test/CodeGen/AVR/ctpop.ll
The file was modifiedllvm/lib/Target/AVR/AVRISelLowering.cpp
Commit 292077072ec1279d89d21873fe900061e55ef936 by flo
[Local] Treat calls that may not return as being alive.

With the addition of the `willreturn` attribute, functions that may
not return (e.g. due to an infinite loop) are well defined, if they are
not marked as `willreturn`.

This patch updates `wouldInstructionBeTriviallyDead` to not consider
calls that may not return as dead.

This patch still provides an escape hatch for intrinsics, which are
still assumed as willreturn unconditionally. It will be removed once
all intrinsics definitions have been reviewed and updated.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D94106
The file was modifiedllvm/test/Transforms/InstCombine/nothrow.ll
The file was modifiedllvm/test/Transforms/Attributor/nonnull.ll
The file was modifiedllvm/test/Transforms/InstCombine/constant-fold-libfunc.ll
The file was modifiedllvm/test/Transforms/Attributor/readattrs.ll
The file was modifiedllvm/include/llvm/IR/InstrTypes.h
The file was modifiedllvm/test/Transforms/Attributor/range.ll
The file was modifiedllvm/test/Transforms/NewGVN/eliminate-callsite-inline.ll
The file was modifiedllvm/test/Transforms/DeadStoreElimination/MemDepAnalysis/simple.ll
The file was modifiedllvm/test/Transforms/CodeGenPrepare/X86/delete-assume-dead-code.ll
The file was modifiedllvm/test/Transforms/Coroutines/coro-split-00.ll
The file was modifiedllvm/test/Transforms/Attributor/norecurse.ll
The file was modifiedllvm/test/Transforms/InstSimplify/returned.ll
The file was modifiedllvm/test/Transforms/InstSimplify/ConstProp/rint.ll
The file was modifiedllvm/test/Transforms/Attributor/ArgumentPromotion/fp80.ll
The file was modifiedllvm/test/Transforms/Attributor/nocapture-2.ll
The file was modifiedllvm/test/Transforms/Coroutines/coro-split-hidden.ll
The file was modifiedllvm/test/Transforms/DeadStoreElimination/MemDepAnalysis/DeleteThrowableInst.ll
The file was modifiedllvm/test/Transforms/MemCpyOpt/memcpy.ll
The file was modifiedllvm/test/Transforms/Reassociate/erase_inst_made_change.ll
The file was modifiedllvm/test/Transforms/Attributor/nocapture-1.ll
The file was modifiedllvm/test/Feature/OperandBundles/early-cse.ll
The file was modifiedllvm/test/Transforms/InstSimplify/remove-dead-call.ll
The file was modifiedllvm/lib/Transforms/Utils/Local.cpp
The file was modifiedllvm/test/Transforms/BDCE/basic.ll
The file was modifiedllvm/test/Transforms/Attributor/align.ll
The file was modifiedllvm/test/Transforms/Coroutines/no-suspend.ll
The file was modifiedllvm/test/Transforms/DeadStoreElimination/MSSA/simple.ll
The file was modifiedllvm/test/Transforms/Inline/dead-calls-willreturn.ll
The file was modifiedllvm/test/Transforms/OpenMP/parallel_deletion.ll
Commit 39e1e53a7c162652c6c138d1bcf50d2766fe9561 by spatel
[SLP] add reduction test with mixed fast-math-flags; NFC
The file was modifiedllvm/test/Transforms/SLPVectorizer/X86/horizontal.ll
Commit a6f02212764a76935ec5fb704fe86a1a76f65745 by spatel
[SLP] fix fast-math-flag propagation on FP reductions

As shown in the test diffs, we could miscompile by
propagating flags that did not exist in the original
code.

The flags required for fmin/fmax reductions will be
fixed in a follow-up patch.
The file was modifiedllvm/test/Transforms/SLPVectorizer/X86/horizontal.ll
The file was modifiedllvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Commit 1eb8c5cd35ed0f3e06ea77a93824901f680ca1ed by powerman1st
[AVR] Optimize 16-bit comparison with constant

Reviewed By: dylanmckay

Differential Revision: https://reviews.llvm.org/D93976
The file was modifiedllvm/lib/Target/AVR/AVRISelLowering.h
The file was modifiedllvm/lib/Target/AVR/AVRISelLowering.cpp
The file was modifiedllvm/test/CodeGen/AVR/cmp.ll
Commit 757b93bb7b384038a8dec35433f78f5c7c2ef8b0 by Dan Liew
[ASan] Fix broken Windows build due to 596d534ac3524052df210be8d3c01a33b2260a42.

In that change I forgot to update the call to
`AsanThread::ThreadStart()` in `asan_win.cpp`.
The file was modifiedcompiler-rt/lib/asan/asan_win.cpp
Commit a8e06361ddba6a25fb0c27596aaa03c5423d1868 by koraq
[libc++] Implements concept destructible

Implements parts of:
- P0898R3 Standard Library Concepts
- P1754 Rename concepts to standard_case for C++20, while we still can

Reviewed By: ldionne, miscco, #libc

Differential Revision: https://reviews.llvm.org/D91004
The file was addedlibcxx/test/std/concepts/concept.destructible/destructible.compile.pass.cpp
The file was modifiedlibcxx/docs/Cxx2aStatusPaperStatus.csv
The file was modifiedlibcxx/include/concepts
Commit d60b74c28a076062259ba8a8b80a9bdd802c7497 by flo
[InstCombine] Set MadeIRChange in replaceInstUsesWith.

Some utilities used by InstCombine, like SimplifyLibCalls, may add new
instructions and replace the uses of a call, but return nullptr because
the inserted call produces multiple results.

Previously, the replaced library calls would get removed by
InstCombine's deleter, but after
292077072ec1279d89d21873fe900061e55ef936 this may not happen, if the
willreturn attribute is missing.

As a work-around, update replaceInstUsesWith to set MadeIRChange, if it
replaces any uses. This catches the cases where it is used as replacer
by utilities used by InstCombine and seems useful in general; updating
uses will modify the IR.

This fixes an expensive-check failure when replacing
@__sinpif/@__cospifi with @__sincospif_sret.
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineInternal.h