Progress:
Changes

Changes from Git (git http://labmaster3.local/git/llvm-project.git)

Summary

  1. [ELF] Fix out-of-bounds write in memset(&Out::first, ...) (details)
  2. [ELF] Simplify OutputSection::sectionIndex assignment. NFC (details)
  3. [ELF] Replace one make_unique from r316378 with a stack object. NFC (details)
  4. [Driver] Support PowerPC SPE musl dynamic linker name ld-musl-powerpc-sf.so.1 (details)
  5. [ELF] Inline InputSection::getOffset into callers and remove it. NFC (details)
  6. [ELF] Remove unneeded getOutputSectionVA. NFC (details)
  7. Compilation Database: Point Bazel users to a solution (details)
  8. [ELF] Simplify/remove LinkerScript::output and advance. NFC (details)
  9. [mlir][python] Normalize asm-printing IR behavior. (details)
  10. [llvm] Use range-based for loops (NFC) (details)
  11. test: add a lit configuration for Windows subdirectory (details)
  12. [ELF][test] --oformat binary: Check that SIZEOF_HEADERS==0 (details)
  13. [ELF] Support --oformat= beside Separate --oformat (details)
  14. [AIX] Disable empty.ll test using unsupported split dwarf (details)
  15. [ELF] Simplify/remove LinkerScript::switchTo. NFC (details)
  16. [ELF] Simplify some ctx->outSec with sec. NFC (details)
  17. [ELF] Decrease InputSectionBase::entsize to uint32_t (details)
  18. [analyzer][doc] Add user documenation for taint analysis (details)
  19. [ELF] Speed up/simplify removeUnusedSyntheticSections. NFC (details)
  20. [ELF] Avoid std::stable_partition which may allocate memory. NFC (details)
  21. [flang] Return true in IsSymplyContiguous for allocatables (details)
  22. [CodeGen][SVE] Use whilelo instruction when lowering @llvm.get.active.lane.mask (details)
  23. Fix cppcoreguidelines-virtual-base-class-destructor in macros (details)
  24. [libtooling][clang-tidy] Fix crashing on rendering invalid SourceRanges (details)
  25. [clang-tidy] Fix crashing altera-struct-pack-align on invalid RecordDecls (details)
  26. [clang-tidy] Ignore narrowing conversions in case of bitfields (details)
  27. [fir] Add base for runtime builder unittests (details)
  28. [LV] Move code from widenInstruction to VPWidenRecipe. (NFC) (details)
  29. [fir] Add fir transformational intrinsic builder (details)
  30. [fir] Add assignment runtime API builder (details)
  31. [analyzer][NFC] Refactor AnalysisConsumer::getModeForDecl() (details)
Commit d060cc1f9808dd5de524334fd695404a96e3175f by i
[ELF] Fix out-of-bounds write in memset(&Out::first, ...)

Fix r285764: there is no guarantee that Out::first is placed before other
static data members of `struct Out`. After `bufferStart` was introduced, this
out-of-bounds write is destined in many compilers. It is likely benign, though.

And move `Out::elfHeader->size` assignment beside `Out::elfHeader->sectionIndex`
The file was modifiedlld/ELF/OutputSections.cpp
The file was modifiedlld/ELF/OutputSections.h
The file was modifiedlld/ELF/Writer.cpp
The file was modifiedlld/ELF/Driver.cpp
Commit 25c7ec4fc622b73f02840daf2ebaf4a5dabb9e1a by i
[ELF] Simplify OutputSection::sectionIndex assignment. NFC

And improve comments.
The file was modifiedlld/ELF/Writer.cpp
Commit 7ea662e2dda021bfc4c68354a5fe359748dd4ce4 by i
[ELF] Replace one make_unique from r316378 with a stack object. NFC
The file was modifiedlld/ELF/LinkerScript.cpp
Commit b3163c1cdde09467382984e5879aa9701b7036d3 by i
[Driver] Support PowerPC SPE musl dynamic linker name ld-musl-powerpc-sf.so.1

Musl treats PowerPC SPE as a soft-float target (as the PowerPC SPE ABI
is soft-float compatible).

Reviewed By: jhibbits, MaskRay

Differential Revision: https://reviews.llvm.org/D105869
The file was modifiedclang/lib/Driver/ToolChains/Linux.cpp
The file was modifiedclang/test/Driver/linux-ld.c
Commit 85e50c10807f8d3ddd4d092afc23e75b818d0462 by i
[ELF] Inline InputSection::getOffset into callers and remove it. NFC

This is an unneeded abstraction which may cause confusion:
SectionBase::getOffset has the same name but hard codes -1 as the size of OutputSection.
The file was modifiedlld/ELF/InputSection.cpp
The file was modifiedlld/ELF/InputSection.h
The file was modifiedlld/ELF/MapFile.cpp
Commit e80a0b353c31e2303c44141ab8b2ca63627ab5c2 by i
[ELF] Remove unneeded getOutputSectionVA. NFC

I attempted to remove it 1 or 2 year ago but kept it just to have a good
diagnostic in case the output section is nullptr (should be impossible).
It is long enough that we haven't seen such a case.
The file was modifiedlld/ELF/LinkerScript.cpp
Commit 5233ad17e77eb7b7697f2664dc5a588a30fe5eaf by zeratul976
Compilation Database: Point Bazel users to a solution

This doc lists ways of getting compilation databases out of some popular build systems for use with clangd and other tooling.

We built such a way for Bazel and just released it after a bunch of requests on GitHub. Thought I should propose that we add a link to help people find it and use clang tooling.

(This is my first revision submitted via LLVM Phabricator, so if I've messed something up, I'd really appreciate your help and patience. Asking for a review from Sam McCall, because I've had a great time working with him elsewhere on GitHub before and because I saw him in the Git history for this file.)

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D114213
The file was modifiedclang/docs/JSONCompilationDatabase.rst
Commit 1164c4b37583eca98866853ed22149f1a1b55a3d by i
[ELF] Simplify/remove LinkerScript::output and advance. NFC
The file was modifiedlld/ELF/LinkerScript.h
The file was modifiedlld/ELF/LinkerScript.cpp
Commit ace1d0ad3dc43e28715cbe2f3e0a5a76578bda9f by stellaraccident
[mlir][python] Normalize asm-printing IR behavior.

While working on an integration, I found a lot of inconsistencies on IR printing and verification. It turns out that we were:
  * Only doing "soft fail" verification on IR printing of Operation, not of a Module.
  * Failed verification was interacting badly with binary=True IR printing (causing a TypeError trying to pass an `str` to a `bytes` based handle).
  * For systematic integrations, it is often desirable to control verification yourself so that you can explicitly handle errors.

This patch:
  * Trues up the "soft fail" semantics by having `Module.__str__` delegate to `Operation.__str__` vs having a shortcut implementation.
  * Fixes soft fail in the presence of binary=True (and adds an additional happy path test case to make sure the binary functionality works).
  * Adds an `assume_verified` boolean flag to the `print`/`get_asm` methods which disables internal verification, presupposing that the caller has taken care of it.

It turns out that we had a number of tests which were generating illegal IR but it wasn't being caught because they were doing a print on the `Module` vs operation. All except two were trivially fixed:
  * linalg/ops.py : Had two tests for direct constructing a Matmul incorrectly. Fixing them made them just like the next two tests so just deleted (no need to test the verifier only at this level).
  * linalg/opdsl/emit_structured_generic.py : Hand coded conv and pooling tests appear to be using illegal shaped inputs/outputs, causing a verification failure. I just used the `assume_verified=` flag to restore the original behavior and left a TODO. Will get someone who owns that to fix it properly in a followup (would also be nice to break this file up into multiple test modules as it is hard to tell exactly what is failing).

Notes to downstreams:
  * If, like some of our tests, you get verification failures after this patch, it is likely that your IR was always invalid and you will need to fix the root cause. To temporarily revert to prior (broken) behavior, replace calls like `print(module)` with `print(module.operation.get_asm(assume_verified=True))`.

Differential Revision: https://reviews.llvm.org/D114680
The file was modifiedmlir/test/python/dialects/linalg/ops.py
The file was modifiedmlir/test/python/dialects/builtin.py
The file was modifiedmlir/test/python/ir/module.py
The file was modifiedmlir/test/python/dialects/std.py
The file was modifiedmlir/test/python/dialects/linalg/opdsl/emit_structured_generic.py
The file was modifiedmlir/lib/Bindings/Python/IRCore.cpp
The file was modifiedmlir/test/python/ir/operation.py
The file was modifiedmlir/test/python/dialects/shape.py
The file was modifiedmlir/lib/Bindings/Python/IRModule.h
Commit fd7d40640d26cd7834a1d85023ed9da8aef2a3a7 by kazu
[llvm] Use range-based for loops (NFC)
The file was modifiedllvm/lib/CodeGen/BranchFolding.cpp
The file was modifiedllvm/lib/TableGen/TGLexer.cpp
The file was modifiedllvm/lib/CodeGen/GlobalMerge.cpp
The file was modifiedllvm/lib/CodeGen/CriticalAntiDepBreaker.cpp
The file was modifiedllvm/lib/CodeGen/MachineVerifier.cpp
The file was modifiedllvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
The file was modifiedllvm/lib/Target/AMDGPU/R600MachineScheduler.cpp
The file was modifiedllvm/lib/Target/Hexagon/HexagonISelLowering.cpp
The file was modifiedllvm/lib/ExecutionEngine/ExecutionEngine.cpp
The file was modifiedllvm/lib/Target/Hexagon/HexagonFrameLowering.cpp
The file was modifiedllvm/lib/CodeGen/LatencyPriorityQueue.cpp
The file was modifiedllvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp
The file was modifiedllvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
The file was modifiedllvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
The file was modifiedllvm/lib/CodeGen/MachinePipeliner.cpp
The file was modifiedllvm/lib/Transforms/Scalar/Reassociate.cpp
Commit 6488bd1d51715501632778e3c9a1d4eedfac2998 by Saleem Abdulrasool
test: add a lit configuration for Windows subdirectory

This adds a local configuration to the Windows subdirectory to filter
out the tests on non-Windows platforms using the lit filtering.
The file was addedlldb/test/Shell/Process/Windows/lit.local.cfg
Commit b5f1fa3e5c1503137c63d5eab1bd213dea706041 by i
[ELF][test] --oformat binary: Check that SIZEOF_HEADERS==0
The file was modifiedlld/test/ELF/oformat-binary.s
Commit 11291326cd983288117b52e955e7936548373c89 by i
[ELF] Support --oformat= beside Separate --oformat

Both GNU ld's manpage and ours use --oformat= as the canonical form.
It's odd that we do not support it...
The file was modifiedlld/ELF/Options.td
The file was modifiedlld/test/ELF/oformat-binary.s
Commit 01eb91fa86a0c65cbaac75336769d188f35443ec by Jake.Egan
[AIX] Disable empty.ll test using unsupported split dwarf

This test uses split-dwarf feature, which is not currently supported on AIX. Set this test to `UNSUPPORTED` on AIX for now.

Reviewed By: shchenz

Differential Revision: https://reviews.llvm.org/D114567
The file was modifiedllvm/test/DebugInfo/Generic/empty.ll
Commit 89c0f4553ea62cef172a4924c21b40afdc744f11 by i
[ELF] Simplify/remove LinkerScript::switchTo. NFC
The file was modifiedlld/ELF/LinkerScript.h
The file was modifiedlld/ELF/LinkerScript.cpp
Commit e652f3f04a253d1c6bc3e16f15115ff3e8401dc0 by i
[ELF] Simplify some ctx->outSec with sec. NFC
The file was modifiedlld/ELF/LinkerScript.cpp
Commit 286c11165e24a7904328804ba10c332277d18b45 by i
[ELF] Decrease InputSectionBase::entsize to uint32_t

While here, change the sh_addralign argument to uint32_t (InputSection ctor's
argument and the member are uint32_t); add constexpr.
The file was modifiedlld/ELF/InputSection.h
Commit 4aac00a71db31121d70b140d7367e7f9d9992f66 by endre.fulop
[analyzer][doc] Add user documenation for taint analysis

Checker alpha.security.taint.TaintPropagation now has user documentation for
taint analysis with an example showing external YAML configuration format.
The format of the taint configuration file is now documented under the user
documentation of Clang SA.

Differential Revision: https://reviews.llvm.org/D113251
The file was modifiedclang/docs/analyzer/checkers.rst
The file was addedclang/docs/analyzer/user-docs/TaintAnalysisConfiguration.rst
The file was modifiedclang/docs/analyzer/user-docs.rst
Commit 99a2d940dd77a9c3699c71024b38baee98df8292 by i
[ELF] Speed up/simplify removeUnusedSyntheticSections. NFC

Make one change: when the OutputSection is nullptr (due to /DISCARD/ or garbage
collected BssSection (replaceCommonSymbols)), discard the SyntheticSection as well.
The file was modifiedlld/ELF/Writer.cpp
Commit 4709bacf18b41bf80b3a0fc1c9f16be60fedae8b by i
[ELF] Avoid std::stable_partition which may allocate memory. NFC
The file was modifiedlld/ELF/Writer.cpp
Commit 9d1938fd1441935313ac0e44e39069bee8171a86 by jperier
[flang] Return true in IsSymplyContiguous for allocatables

The current code was relying on the fact that allocatables are deferred
shape and that isAssumedShape() should therefore return true for them.

This is not true, because the current parsing/semantic analysis always
builds a semantics::ArraySpec for `x(:)` that returns true to both
isDeferredShape()/isAssumedShape(), whether x is allocatable/pointer or
not.

It proved tricky to change this behavior, so this is a simple fix for
IsSymplyContiguous where it currently matters, but we most likely want
to investigate more and fix the isDeferredShape()/isAssumedShape() in
a second time.

Differential Revision: https://reviews.llvm.org/D114599
The file was modifiedflang/lib/Evaluate/check-expression.cpp
The file was modifiedflang/test/Evaluate/folding09.f90
Commit a31f4bdfe8211ecb38741c4fd570baf0d6e16f76 by david.sherwood
[CodeGen][SVE] Use whilelo instruction when lowering @llvm.get.active.lane.mask

In most common cases the @llvm.get.active.lane.mask intrinsic maps directly
to the SVE whilelo instruction, which already takes overflow into account.
However, currently in SelectionDAGBuilder::visitIntrinsicCall we always lower
this immediately to a generic sequence of instructions that explicitly
take overflow into account. This makes it very difficult to then later
transform back into a single whilelo instruction. Therefore, this patch
introduces a new TLI function called shouldExpandGetActiveLaneMask that asks if
we should lower/expand this to a sequence of generic ISD nodes, or instead
just leave it as an intrinsic for the target to lower.

You can see the significant improvement in code quality for some of the
tests in this file:

  CodeGen/AArch64/active_lane_mask.ll

Differential Revision: https://reviews.llvm.org/D114542
The file was modifiedllvm/test/CodeGen/AArch64/active_lane_mask.ll
The file was modifiedllvm/include/llvm/CodeGen/TargetLowering.h
The file was modifiedllvm/lib/Target/AArch64/AArch64ISelLowering.cpp
The file was modifiedllvm/lib/Target/AArch64/AArch64ISelLowering.h
The file was modifiedllvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Commit 0685e83534ef8917f277b394da2927cabff8129f by balazs.benics
Fix cppcoreguidelines-virtual-base-class-destructor in macros

The `cppcoreguidelines-virtual-base-class-destructor` checker crashed on
this example:

  #define DECLARE(CLASS) \
  class CLASS {          \
  protected:             \
    virtual ~CLASS();    \
  }
  DECLARE(Foo); // no-crash

The checker will hit the following assertion:

  clang-tidy: llvm/include/llvm/ADT/Optional.h:196: T &llvm::optional_detail::OptionalStorage<clang::Token, true>::getValue() & [T = clang::Token]: Assertion `hasVal' failed."

It turns out, `Lexer::findNextToken()` returned `llvm::None` within the
`getVirtualKeywordRange()` function when the `VirtualEndLoc`
SourceLocation represents a macro expansion.
To prevent this from happening, I decided to propagate the `llvm::None`
further up and only create the removal of `virtual` if the
`getVirtualKeywordRange()` succeeds.

I considered an alternative fix for this issue:
I could have checked the `Destructor.getLocation().isMacroID()` before
doing any Fixit calculation inside the `check()` function.
In contrast to this approach my patch will preserve the diagnostics and
drop the fixits only if it would have crashed.

Reviewed By: whisperity

Differential Revision: https://reviews.llvm.org/D113558
The file was modifiedclang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
The file was modifiedclang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
Commit 0540485436c4dd225e6a40e6db1240f096d145d3 by balazs.benics
[libtooling][clang-tidy] Fix crashing on rendering invalid SourceRanges

Invalid SourceRanges can occur generally if the code does not compile,
thus we expect clang error diagnostics.
Unlike `clang`, `clang-tidy` did not swallow invalid source ranges, but
tried to highlight them, and blow various assertions.

The following two examples produce invalid source ranges, but this is
not a complete list:

  void test(x); // error: unknown type name 'x'
  struct Foo {
    member; // error: C++ requires a type specifier for all declarations
  };

Thanks @whisperity helping me fix this.

Reviewed-By: xazax.hun

Differential Revision: https://reviews.llvm.org/D114254
The file was modifiedclang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
The file was modifiedclang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
The file was modifiedclang-tools-extra/test/clang-tidy/infrastructure/export-diagnostics.cpp
Commit e1d0673aeeece138d4865385a24a86f6954dff72 by balazs.benics
[clang-tidy] Fix crashing altera-struct-pack-align on invalid RecordDecls

Reviewed-By: martong

Differential Revision: https://reviews.llvm.org/D114256
The file was addedclang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align-invalid-decl-no-crash.cpp
The file was modifiedclang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
Commit a8120a771143c15480b508c19a14c0c85a36378c by balazs.benics
[clang-tidy] Ignore narrowing conversions in case of bitfields

Bitfields are special. Due to integral promotion [conv.prom/5] bitfield
member access expressions are frequently wrapped by an implicit cast to
`int` if that type can represent all the values of the bitfield.

Consider these examples:
  struct SmallBitfield { unsigned int id : 4; };
  x.id & 1;             (case-1)
  x.id & 1u;            (case-2)
  x.id << 1u;           (case-3)
  (unsigned)x.id << 1;  (case-4)

Due to the promotion rules, we would get a warning for case-1. It's
debatable how useful this is, but the user at least has a convenient way
of //fixing// it by adding the `u` unsigned-suffix to the literal as
demonstrated by case-2. However, this won't work for shift operators like
the one in case-3. In case of a normal binary operator, both operands
contribute to the result type. However, the type of the shift expression is
the promoted type of the left operand. One could still suppress this
superfluous warning by explicitly casting the bitfield member access as
case-4 demonstrates, but why? The compiler already knew that the value from
the member access should safely fit into an `int`, why do we have this
warning in the first place? So, hereby we suppress this specific scenario,
when a bitfield's value is implicitly cast to int (likely due to integral
promotion).

Note that the bitshift operation might invoke unspecified/undefined
behavior, but that's another topic, this checker is about detecting
conversion-related defects.

Example AST for `x.id << 1`:
  BinaryOperator 'int' '<<'
  |-ImplicitCastExpr 'int' <IntegralCast>
  | `-ImplicitCastExpr 'unsigned int' <LValueToRValue>
  |   `-MemberExpr 'unsigned int' lvalue bitfield .id
  |     `-DeclRefExpr 'SmallBitfield' lvalue ParmVar 'x' 'SmallBitfield'
  `-IntegerLiteral 'int' 1

Reviewed By: courbet

Differential Revision: https://reviews.llvm.org/D114105
The file was addedclang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-bitfields.cpp
The file was modifiedclang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
Commit 1b3cd35ade5daea163ac444324415d68af2513a7 by clementval
[fir] Add base for runtime builder unittests

This patch adds the common base shared by builder runtime
unittests. It extracted from D114460 to make it easier to base other patches
on it.

Reviewed By: kiranchandramohan, rovka

Differential Revision: https://reviews.llvm.org/D114557
The file was addedflang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h
The file was addedflang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
Commit fd71159f6468988d9865a39c243695f823f4b6d7 by flo
[LV] Move code from widenInstruction to VPWidenRecipe. (NFC)

The code in widenInstruction has already been transitioned to
only rely on information provided by VPWidenRecipe directly.

Moving the code directly to VPWidenRecipe::execute completes
the transition for the recipe.

It provides the following advantages:

1. Less indirection, easier to see what's going on.
2. Removes accesses to fields of ILV.

2) in particular ensures that no dependencies on
fields in ILV for vector code generation are re-introduced.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D114322
The file was modifiedllvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Commit 18452d1f12479ff5e1b437ef7efc9538e505c437 by clementval
[fir] Add fir transformational intrinsic builder

This patch adds the builder to generate transformational
intrinsic runtime API calls.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: rovka

Differential Revision: https://reviews.llvm.org/D114470

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: mleair <leairmark@gmail.com>
Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
Co-authored-by: Peter Steinfeld <psteinfeld@nvidia.com>
The file was modifiedflang/unittests/Optimizer/CMakeLists.txt
The file was addedflang/include/flang/Optimizer/Builder/Runtime/Transformational.h
The file was modifiedflang/lib/Optimizer/Builder/CMakeLists.txt
The file was addedflang/unittests/Optimizer/Builder/Runtime/TransformationalTest.cpp
The file was addedflang/lib/Optimizer/Builder/Runtime/Transformational.cpp
Commit 51e2c8c9bf96f19a3160a7da36be26943318a2cb by clementval
[fir] Add assignment runtime API builder

This patch adds the builder that generate assignment runtime API calls.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: rovka, awarzynski

Differential Revision: https://reviews.llvm.org/D114475

Co-authored-by: Jean Perier <jperier@nvidia.com>
The file was addedflang/include/flang/Optimizer/Builder/Runtime/Assign.h
The file was modifiedflang/lib/Optimizer/Builder/CMakeLists.txt
The file was addedflang/lib/Optimizer/Builder/Runtime/Assign.cpp
The file was addedflang/unittests/Optimizer/Builder/Runtime/AssignTest.cpp
The file was modifiedflang/unittests/Optimizer/CMakeLists.txt
Commit af37d4b6fee8990d5b029796681b59e0d0390c28 by balazs.benics
[analyzer][NFC] Refactor AnalysisConsumer::getModeForDecl()

I just read this part of the code, and I found the nested ifs less
readable.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D114441
The file was modifiedclang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp