1. [LoopFlatten] Add a loop-flattening pass (details)
  2. [gn build] Port d53b4bee0cc (details)
  3. [Archive] Don't throw away errors for malformed archive members (details)
  4. [SVE][CodeGen] Replace use of TypeSize operator< in GlobalMerge::doMerge (details)
  5. [AMDGPU] Tiny cleanup in isLegalFLATOffset. NFC. (details)
Commit d53b4bee0ccd408cfe6e592540858046244e74ce by sjoerd.meijer
[LoopFlatten] Add a loop-flattening pass

This is a simple pass that flattens nested loops.  The intention is to optimise
loop nests like this, which together access an array linearly:

  for (int i = 0; i < N; ++i)
    for (int j = 0; j < M; ++j)

into one loop:

  for (int i = 0; i < (N*M); ++i)

It can also flatten loops where the induction variables are not used in the
loop. This can help with codesize and runtime, especially on simple cpus
without advanced branch prediction.

This is only worth flattening if the induction variables are only used in an
expression like i*M+j. If they had any other uses, we would have to insert a
div/mod to reconstruct the original values, so this wouldn't be profitable.

This partially fixes PR40581 as this pass triggers on one of the two cases. I
will follow up on this to learn LoopFlatten a few more (small) tricks. Please
note that LoopFlatten is not yet enabled by default.

Patch by Oliver Stannard, with minor tweaks from Dave Green and myself.

Differential Revision:
The file was modifiedllvm/include/llvm/Transforms/Scalar.h
The file was modifiedllvm/lib/Transforms/IPO/PassManagerBuilder.cpp
The file was addedllvm/test/Transforms/LoopFlatten/loop-flatten-negative.ll
The file was modifiedllvm/lib/Passes/PassRegistry.def
The file was addedllvm/test/Transforms/LoopFlatten/loop-flatten.ll
The file was addedllvm/test/Transforms/LoopFlatten/pr40581.ll
The file was modifiedllvm/lib/Transforms/Scalar/CMakeLists.txt
The file was modifiedllvm/lib/Passes/PassBuilder.cpp
The file was addedllvm/include/llvm/Transforms/Scalar/LoopFlatten.h
The file was addedllvm/lib/Transforms/Scalar/LoopFlatten.cpp
The file was modifiedllvm/include/llvm/InitializePasses.h
The file was modifiedllvm/lib/Transforms/Scalar/Scalar.cpp
The file was modifiedllvm/include/llvm/LinkAllPasses.h
Commit 5101e7e8dd01719f9161e01e2f053c9797c247a8 by llvmgnsyncbot
[gn build] Port d53b4bee0cc
The file was modifiedllvm/utils/gn/secondary/llvm/lib/Transforms/Scalar/
Commit a20168d0307860047ad7c8a2074f98fc25b057c2 by james.henderson
[Archive] Don't throw away errors for malformed archive members

When adding an archive member with a problem, e.g. a new bitcode with an
old archiver, containing an unsupported attribute, or an ELF file with a
malformed symbol table, the archiver would throw away the error and
simply add the member to the archive without any symbol entries. This
meant that the resultant archive could be silently unusable when not
using --whole-archive, and result in unexpected undefined symbols.

This change fixes this issue by addressing two FIXMEs and only throwing
away not-an-object errors. However, this meant that some LLD tests which
didn't need symbol tables and were using invalid members deliberately to
test the linker's malformed input handling no longer worked, so this
patch also stops the archiver from looking for symbols in an object if
it doesn't require a symbol table, and updates the tests accordingly.

Differential Revision:

Reviewed by: grimar, rupprecht, MaskRay
The file was modifiedlld/test/ELF/invalid/invalid-file-class.test
The file was addedllvm/test/Object/archive-malformed-object.test
The file was modifiedllvm/lib/Object/SymbolicFile.cpp
The file was modifiedllvm/include/llvm/Object/SymbolicFile.h
The file was modifiedllvm/lib/Object/ArchiveWriter.cpp
The file was addedllvm/test/Object/archive-unknown-filetype.test
The file was modifiedlld/test/ELF/invalid/data-encoding.test
Commit 15474d769110139f9cc96d42434988d7aaa77634 by david.sherwood
[SVE][CodeGen] Replace use of TypeSize operator< in GlobalMerge::doMerge

We don't support global variables with scalable vector types so I've
changed the code to compare the fixed sizes instead.

Differential Revision:
The file was modifiedllvm/lib/CodeGen/GlobalMerge.cpp
Commit 866d9b03f2902c177533d7ce148339d47bf092e1 by jay.foad
[AMDGPU] Tiny cleanup in isLegalFLATOffset. NFC.
The file was modifiedllvm/lib/Target/AMDGPU/SIInstrInfo.cpp