Progress:
Changes

Summary

  1. [Attributor] Generalize GEP construction (details)
  2. [Loads] Use more powerful constant folding API (details)
  3. [libc++] Fix tests after aee49255074f (details)
  4. [llvm]Inclusive language: replace master with main (details)
  5. [lldb] Pass the target triple when determining the DWARF version (details)
  6. [TargetLowering] Simplify the interface of expandABS. NFC (details)
  7. [DebugInfo][InstrRef] Add unit tests for transfer-function building (details)
  8. [indvars] Use fact loop must exit to canonicalize to unsigned conditions (details)
  9. [DAG] narrowExtractedVectorLoad - EXTRACT_SUBVECTOR indices are always constant (details)
  10. [InstCombine] Various tests for truncating saturates and related patterns. (details)
  11. [flang] Fix bogus folding error for ISHFT(x, negative) (details)
  12. [LegalizeTypes] Only expand CTLZ/CTTZ/CTPOP during type promotion if the new type is legal. (details)
  13. [flang] Emit unformatted headers & footers even with RECL= (details)
  14. [DebugInfo][Instr] Track subregisters across stack spills/restores (details)
  15. [flang] Enforce rest of semantic constraint C919 (details)
  16. [libunwind] Fix path to libunwind for per-target-runtime-dir builds (details)
  17. [Dexter] Add DexFinishTest command to conditionally early-exit a test program (details)
  18. [ConstantFolding] Drop misleading comment (NFC) (details)
  19. Support: Add Expected<T>::moveInto() to avoid extra names (details)
Commit 5bb7562962de711959401db5a1eb7ad0ae8bc10b by nikita.ppv
[Attributor] Generalize GEP construction

Make use of the getGEPIndicesForOffset() helper for creating GEPs.
This handles arrays as well, uses correct GEP index types and
reduces code duplication.

Differential Revision: https://reviews.llvm.org/D112263
The file was modifiedllvm/test/Transforms/Attributor/ArgumentPromotion/fp80.ll
The file was modifiedllvm/lib/Transforms/IPO/AttributorAttributes.cpp
The file was modifiedllvm/test/Transforms/Attributor/ArgumentPromotion/byval-2.ll
The file was modifiedllvm/test/Transforms/Attributor/IPConstantProp/2009-09-24-byval-ptr.ll
The file was modifiedllvm/test/Transforms/Attributor/ArgumentPromotion/byval.ll
The file was modifiedllvm/test/Transforms/Attributor/ArgumentPromotion/tail.ll
The file was modifiedllvm/test/Transforms/Attributor/ArgumentPromotion/array.ll
The file was modifiedllvm/test/Transforms/Attributor/ArgumentPromotion/attrs.ll
Commit 3a10fe2d893f3c112663d117a4802aacde3b378a by nikita.ppv
[Loads] Use more powerful constant folding API

This follows up on D111023 by exporting the generic "load value
from constant at given offset as given type" and using it in the
store to load forwarding code. We now need to make sure that the
load size is smaller than the store size, previously this was
implicitly ensured by ConstantFoldLoadThroughBitcast().

Differential Revision: https://reviews.llvm.org/D112260
The file was modifiedllvm/include/llvm/Analysis/ConstantFolding.h
The file was modifiedllvm/test/Transforms/InstCombine/load-store-forward.ll
The file was modifiedllvm/lib/Analysis/Loads.cpp
The file was modifiedllvm/lib/Analysis/ConstantFolding.cpp
Commit 7ea5409e42c8d8f901c8278568f40770abe3e25e by Louis Dionne
[libc++] Fix tests after aee49255074f
The file was addedlibcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.verify.cpp
The file was modifiedlibcxx/test/std/concepts/concepts.lang/concept.default.init/default_initializable.verify.cpp
The file was addedlibcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.verify.cpp
The file was removedlibcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.runtime.fail.cpp
The file was removedlibcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.runtime.fail.cpp
Commit 950f22a5e13cb71fa39417a6a774a09764f94b6c by quinn.pham
[llvm]Inclusive language: replace master with main

[NFC] This patch fixes a url in a testcase due to the renaming of the branch.
The file was modifiedllvm/test/Transforms/SLPVectorizer/AArch64/tsc-s352.ll
Commit 0f12cf7ebaaf9f2a52be3baef7d25562a5ac15cb by Jonas Devlieghere
[lldb] Pass the target triple when determining the DWARF version

When targeting iOS, the default dwarf version is 2 and not 4. Currently,
the test suite does not pick up on that because it invokes the test
compiler without a target triple. This patch fixes that and now
correctly skips tests that have a dwarf version specified in a skipIf
decorator.

rdar://84530477

Differential revision: https://reviews.llvm.org/D112325
The file was modifiedlldb/packages/Python/lldbsuite/test/lldbtest.py
The file was modifiedlldb/packages/Python/lldbsuite/test/builders/builder.py
The file was modifiedlldb/packages/Python/lldbsuite/test/builders/darwin.py
Commit 04c184bba7d7f3827dd12cdbdd734f8aabb99e86 by craig.topper
[TargetLowering] Simplify the interface of expandABS. NFC

Instead of returning a bool to indicate success and a separate
SDValue, return the SDValue and have the callers check if it is
null.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D112331
The file was modifiedllvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
The file was modifiedllvm/include/llvm/CodeGen/TargetLowering.h
The file was modifiedllvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
The file was modifiedllvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
The file was modifiedllvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
The file was modifiedllvm/lib/Target/ARM/ARMISelLowering.cpp
Commit d9eebe3cd7832b69471b27e68f0ee6f1374ed759 by jeremy.morse
[DebugInfo][InstrRef] Add unit tests for transfer-function building

This patch adds some unit tests for the machine-location transfer-function
building parts of InstrRefBasedLDV: i.e., test that if we feed some MIR
into the transfer-function building code, does it create the correct
transfer function.

There are a number of minor defects that get corrected in the process:
* The unit test was selecting the x86 (i.e. 32 bit) backend rather than
   x86_64's 64 bit backend,
* COPY instructions weren't actually having their subregister values
   correctly represented in the transfer function. Subregisters were being
   defined by the COPY, rather than taking the value in the source register.
* SP aliases were at risk of being clobbered, if an SP subregister was
   clobbered.

Differential Revision: https://reviews.llvm.org/D112006
The file was modifiedllvm/unittests/CodeGen/InstrRefLDVTest.cpp
The file was modifiedllvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
The file was modifiedllvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
Commit 412eb07edd4e83afeb1e727e91213e2cbd771f29 by listmail
[indvars] Use fact loop must exit to canonicalize to unsigned conditions

The logic in this patch is that if we find a comparison which would be unsigned except for when the loop is infinite, and we can prove that an infinite loop must be ill defined, we can still make the predicate unsigned.

The eventual goal (combined with a follow on patch) is to use the fact the loop exits to remove the zext (see tests) entirely.

A couple of points worth noting:
* We loose the ability to prove the loop unreachable by committing to the must exit interpretation. If instead, we later proved that rhs was definitely outside the range required for finiteness, we could have killed the loop entirely. (We don't currently implement this transform, but could in theory, do so.)
* simplifyAndExtend has a very limited list of users it walks. In particular, in the examples is stops at the zext and never visits the icmp. (Because we can't fold the zext to an addrec yet in SCEV.) Being willing to visit when we haven't simplified regresses multiple tests (seemingly because of less optimal results when computing trip counts).  D112170 explores fixing that, but - at least so far - appears to be too expensive compile time wise.

Differential Revision: https://reviews.llvm.org/D111836
The file was modifiedllvm/test/Transforms/IndVarSimplify/finite-exit-comparisons.ll
The file was modifiedllvm/include/llvm/Analysis/ScalarEvolution.h
The file was modifiedllvm/lib/Transforms/Scalar/IndVarSimplify.cpp
Commit a5f56342b01765e33abbae97e087f93041a39353 by llvm-dev
[DAG] narrowExtractedVectorLoad - EXTRACT_SUBVECTOR indices are always constant

EXTRACT_SUBVECTOR indices are always constant, we don't need to check for ConstantSDNode, we should just use getConstantOperandVal which will assert for the constant.
The file was modifiedllvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Commit d4da71282f6e30686e3324633436d82cd6059132 by david.green
[InstCombine] Various tests for truncating saturates and related patterns.
The file was addedllvm/test/Transforms/InstCombine/icmp-topbitssame.ll
The file was addedllvm/test/Transforms/InstCombine/xor-ashr.ll
The file was modifiedllvm/test/Transforms/InstCombine/truncating-saturate.ll
Commit d5074c7166647ea1abd78f5bb7fd876cbf0bb7d1 by pklausler
[flang] Fix bogus folding error for ISHFT(x, negative)

Negative shift counts are of course valid for ISHFT when
shifting to the right.  This patch decouples the folding of
ISHFT from that of SHIFTA/L/R and adds tests.

Differential Revision: https://reviews.llvm.org/D112244
The file was modifiedflang/test/Evaluate/folding19.f90
The file was modifiedflang/lib/Evaluate/fold-integer.cpp
The file was addedflang/test/Evaluate/fold-ishft.f90
Commit 93139a3c32660bc29ac91dea616aa2501f37c8cc by craig.topper
[LegalizeTypes] Only expand CTLZ/CTTZ/CTPOP during type promotion if the new type is legal.

We might be promoting a large non-power of 2 type and the new type
may need to be split. Once we split it we may have a ctlz/cttz/ctpop
instruction for the split type.

I'm also concerned that we may create large shifts with shift amounts
that are too small.
The file was modifiedllvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
Commit b03628d986d47e41187278acd2e2b66dd3dc03ae by pklausler
[flang] Emit unformatted headers & footers even with RECL=

The runtime library was emitting unformatted record headers and
footers when an external unit had no fixed RECL=.  This is wrong
for sequential files, which should have headers & footers even
with RECL.  Change to omit headers & footers from unformatted
I/O only for direct access files.

Differential Revision: https://reviews.llvm.org/D112243
The file was modifiedflang/runtime/io-api.cpp
The file was modifiedflang/runtime/unit.cpp
Commit e7084ceab31223a0d983996d61c24486032b537b by jeremy.morse
[DebugInfo][Instr] Track subregisters across stack spills/restores

Sometimes we generate code that writes to a subregister, then spills /
restores a super-register to the stack, for example:

    $eax = MOV32ri 0
    MOV64mr $rsp, 1, $noreg, 16, $noreg, $rax
    $rcx = MOV64rm $rsp, 1, $noreg, 8, $noreg

This patch takes a different approach: it adds another index to
MLocTracker that identifies a size/offset within a stack slot. A location
on the stack is then a pari of {FrameIndex, SlotNum}. Spilling and
restoring now involves pairing up the src/dest register numbers, and the
dest/src stack position to be transferred to/from. Location coverage
improves as a result, compile-time performance decreases, alas.

One limitation is that if a PHI occurs inside a stack slot:

    DBG_PHI %stack.0, 1

We don't know how large the resulting value is, and so might have
difficulty picking which value to use. DBG_PHI might need to be augmented
in the future with such a size.

Unit tests added ensure that spills and restores correctly transfer to
positions in the Location => Value map, and that different register classes
written to the stack will correctly clobber all other positions in the
stack slot.

Differential Revision: https://reviews.llvm.org/D112133
The file was modifiedllvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_subreg_substitutions.mir
The file was modifiedllvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
The file was addedllvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_stackslot_subregs.mir
The file was modifiedllvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
The file was modifiedllvm/unittests/CodeGen/InstrRefLDVTest.cpp
Commit f2360e1156d086ac5ac58d7f29449adf9e75d716 by pklausler
[flang] Enforce rest of semantic constraint C919

A reference to an allocatable or pointer component must be applied
to a scalar base object.  (This is the second part of constraint C919;
the first part is already checked.)

Differential Revision: https://reviews.llvm.org/D112241
The file was modifiedflang/test/Semantics/deallocate01.f90
The file was modifiedflang/include/flang/Semantics/expression.h
The file was modifiedflang/lib/Semantics/expression.cpp
Commit e6f39c8b4891242c0d0d8e7a78041614d9bcdefc by Louis Dionne
[libunwind] Fix path to libunwind for per-target-runtime-dir builds

We recently introduced a from-scratch config to run the libunwind tests.
However, that config was always looking for libunwind in <install>/lib,
and never in <install>/<target>/lib, which is necessary for tests to
work when the per-target-runtime-dir configuration is enabled.

This commit fixes that. I believe this is what caused the CI failures we
saw after 5a8ad80b6fa5 and caused it to be reverted.

Differential Revision: https://reviews.llvm.org/D112322
The file was modifiedlibunwind/test/configs/llvm-libunwind-static.cfg.in
The file was modifiedlibunwind/test/configs/llvm-libunwind-shared.cfg.in
Commit 6cf69179170e6a2aeb201643204b1bc4011b3d82 by stephen.tozer
[Dexter] Add DexFinishTest command to conditionally early-exit a test program

This patch adds a command, DexFinishTest, that allows a Dexter test to
be conditionally finished at a given breakpoint. This command has the
same set of arguments as DexLimitSteps, except that it does not allow a
line range (from_line, to_line), only a single line (on_line).

Reviewed By: Orlando

Differential Revision: https://reviews.llvm.org/D111988
The file was modifiedcross-project-tests/debuginfo-tests/dexter/Commands.md
The file was modifiedcross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ConditionalController.py
The file was addedcross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/limit_steps_hit_count.cpp
The file was addedcross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/limit_steps_conditional.cpp
The file was addedcross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/limit_steps_simple.cpp
The file was addedcross-project-tests/debuginfo-tests/dexter/dex/command/commands/DexFinishTest.py
The file was addedcross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/limit_steps_conditional_hit_count.cpp
The file was addedcross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/default_simple.cpp
The file was addedcross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/default_conditional.cpp
The file was modifiedcross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py
The file was modifiedcross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/DefaultController.py
The file was addedcross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/default_hit_count.cpp
The file was addedcross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/default_conditional_hit_count.cpp
Commit 4d692daa3a6ab876171063eb22be21b94df829e7 by nikita.ppv
[ConstantFolding] Drop misleading comment (NFC)

As pointed out by Philip, this part of the comment is misleading,
as it describes undef rather than poison behavior. Just mentioning
poison should be sufficient.
The file was modifiedllvm/include/llvm/Analysis/ConstantFolding.h
Commit 27181cad0d4e48eac822aaccf52b612f29eeff73 by Duncan P. N. Exon Smith
Support: Add Expected<T>::moveInto() to avoid extra names

Expected<T>::moveInto() takes as an out parameter any `OtherT&` that's
assignable from `T&&`. It moves any stored value before returning
takeError().

Since moveInto() consumes both the Error and the value, it's only
anticipated that we'd use call it on temporaries/rvalues, with naming
the Expected first likely to be an anti-pattern of sorts (either you
want to deal with both at the same time, or you don't). As such,
starting it out as `&&`-qualified... but it'd probably be fine to drop
that if there's a good use case for lvalues that appears.

There are two common patterns that moveInto() cleans up:
```
  // If the variable is new:
  Expected<std::unique_ptr<int>> ExpectedP = makePointer();
  if (!ExpectedP)
    return ExpectedP.takeError();
  std::unique_ptr<int> P = std::move(*ExpectedP);

  // If the target variable already exists:
  if (Expected<T> ExpectedP = makePointer())
    P = std::move(*ExpectedP);
  else
    return ExpectedP.takeError();
```
moveInto() takes less typing and avoids needing to name (or leak into
the scope) an extra variable.
```
  // If the variable is new:
  std::unique_ptr<int> P;
  if (Error E = makePointer().moveInto(P))
    return E;

  // If the target variable already exists:
  if (Error E = makePointer().moveInto(P))
    return E;
```

It also seems useful for unit tests, to log errors (but continue) when
there's an unexpected failure. E.g.:
```
  // Crash on error, or undefined in non-asserts builds.
  std::unique_ptr<MemoryBuffer> MB = cantFail(makeMemoryBuffer());

  // Avoid crashing on error without moveInto() :(.
  Expected<std::unique_ptr<MemoryBuffer>>
      ExpectedMB = makeMemoryBuffer();
  ASSERT_THAT_ERROR(ExpectedMB.takeError(), Succeeded());
  std::unique_ptr<MemoryBuffer> MB = std::move(ExpectedMB);

  // Avoid crashing on error with moveInto() :).
  std::unique_ptr<MemoryBuffer> MB;
  ASSERT_THAT_ERROR(makeMemoryBuffer().moveInto(MB), Succeeded());
```

Differential Revision: https://reviews.llvm.org/D112278
The file was modifiedllvm/include/llvm/Support/Error.h
The file was modifiedllvm/docs/ProgrammersManual.rst
The file was modifiedllvm/unittests/Support/ErrorTest.cpp