SuccessChanges

Summary

  1. lldb-cmake job: Temporarily disable LLVM_ENABLE_MODULES (details)
Commit e2ed346edb77255059f41d931a1edab3ac6b11f3 by Vedant Kumar
lldb-cmake job: Temporarily disable LLVM_ENABLE_MODULES

See https://reviews.llvm.org/D75091 for the rationale and discussion, we
believe a recent clang change is breaking the stage2 lldb modules build.

rdar://59740397
The file was modifiedzorg/jenkins/monorepo_build.py (diff)

Summary

  1. [PhaseOrdering] add tests for missed CSE; NFC (details)
  2. [libcxx] Fix building for windows after 54fa9ecd3088508 (details)
  3. Add 'l' constraint to goto label reference (details)
  4. [NFC][SCEV] Piping to pass TTI into SCEVExpander::isHighCostExpansionHelper() (details)
  5. [NFC][SCEV] Piping to pass new SCEVCheapExpansionBudget option into SCEVExpander::isHighCostExpansionHelper() (details)
  6. [NFC][SCEV] SCEVExpander::isHighCostExpansionHelper(): check that we processed expression first (details)
  7. [SCEV] SCEVExpander::isHighCostExpansion(): assert if TTI is not provided (details)
  8. [SCEV] SCEVExpander::isHighCostExpansionHelper(): begin cost modelling - model cast cost (details)
  9. [SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model UDiv by power-of-two as LShr (details)
  10. [NFC][IndVarSimplify] Adjust value names in IndVarSimplify/exit_value_test2.ll (details)
  11. [SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model plain UDiv (details)
  12. [SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model add/mul (details)
  13. [SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model polynomial recurrence (details)
  14. [SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model min/max (PR44668) (details)
  15. [SCEV] rewriteLoopExitValues(): even if have hard uses, still rewrite if cheap (PR44668) (details)
  16. [SCEV][IndVars] Always provide insertion point to the SCEVExpander::isHighCostExpansion() (details)
  17. Use "nop" to avoid size warnings. (details)
  18. Check args passed to __builtin_frame_address and __builtin_return_address. (details)
  19. [X86] Add test to show incorrect ordering of flt.rounds intrinsic relative to calls to fesetround. (details)
  20. [LIBOMPTARGET]Fix PR44933: fix crash because of the too early deinitialization of libomptarget. (details)
  21. [ObjC][ARC] Don't move a retain call living outside a loop into the loop (details)
  22. [libTooling] Add function to determine associated text of a declaration. (details)
Commit 922558be9ecb24f51fbe879bf6e55d6aad9f4619 by spatel
[PhaseOrdering] add tests for missed CSE; NFC

Also add a RUN line for the new pass manager.
The file was modifiedllvm/test/Transforms/PhaseOrdering/X86/addsub.ll
Commit e3add3e5a192ec7f73922a4278f52d335d1f9be5 by martin
[libcxx] Fix building for windows after 54fa9ecd3088508

Move the implementation of __libcpp_thread_poll_with_backoff
and __libcpp_timed_backoff_policy::operator() out of the
_LIBCPP_HAS_THREAD_API_PTHREAD block. None of the code in these
methods is pthreads specific.

Also add "inline _LIBCPP_INLINE_VISIBILITY" to
__libcpp_timed_backoff_policy::operator(), to avoid errors due to
multiple definitions of the operator. Contrary to
__libcpp_thread_poll_with_backoff (which is a template function),
this is a normal non-templated method.

Differential Revision: https://reviews.llvm.org/D75102
The file was modifiedlibcxx/include/__threading_support
Commit e11f9fb4508534d31b09d2ba6cd22428ccc75f65 by isanbard
Add 'l' constraint to goto label reference

A goto label uses the 'l' constraint, skipping it can cause unexpected
warnings.
The file was modifiedclang/test/Analysis/uninit-asm-goto.cpp
Commit 0789f280483e315d8bcb5e7005e04e7118983b21 by lebedev.ri
[NFC][SCEV] Piping to pass TTI into SCEVExpander::isHighCostExpansionHelper()

Summary:
Future patches will make use of TTI to perform cost-model-driven `SCEVExpander::isHighCostExpansionHelper()`
This is a fully NFC patch to make things reviewable.

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: hiraditya, zzheng, javed.absar, dmgreen, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73704
The file was modifiedllvm/include/llvm/Analysis/ScalarEvolutionExpander.h
The file was modifiedllvm/lib/Transforms/Utils/SimplifyIndVar.cpp
The file was modifiedllvm/include/llvm/Transforms/Utils/LoopUtils.h
The file was modifiedllvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp
The file was modifiedllvm/lib/Analysis/ScalarEvolutionExpander.cpp
The file was modifiedllvm/lib/Target/ARM/MVETailPredication.cpp
The file was modifiedllvm/lib/Transforms/Utils/LoopUnroll.cpp
The file was modifiedllvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
The file was modifiedllvm/include/llvm/Transforms/Utils/SimplifyIndVar.h
The file was modifiedllvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
The file was modifiedllvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
The file was modifiedllvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
The file was modifiedllvm/include/llvm/Transforms/Utils/UnrollLoop.h
The file was modifiedllvm/lib/Transforms/Scalar/IndVarSimplify.cpp
The file was modifiedllvm/lib/Transforms/Utils/LoopUtils.cpp
Commit b99c91a0872f4b7b7e482c40818bbdda4c967bd5 by lebedev.ri
[NFC][SCEV] Piping to pass new SCEVCheapExpansionBudget option into SCEVExpander::isHighCostExpansionHelper()

Summary:
In future patches`SCEVExpander::isHighCostExpansionHelper()` will respect the budget allocated by performing TTI cost modelling.
This is a fully NFC patch to make things reviewable.

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: hiraditya, zzheng, javed.absar, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73705
The file was modifiedllvm/lib/Analysis/ScalarEvolutionExpander.cpp
The file was modifiedllvm/include/llvm/Analysis/ScalarEvolutionExpander.h
The file was modifiedllvm/lib/Transforms/Utils/SimplifyIndVar.cpp
The file was modifiedllvm/lib/Transforms/Scalar/IndVarSimplify.cpp
The file was modifiedllvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
The file was modifiedllvm/lib/Transforms/Utils/LoopUtils.cpp
Commit 1622f3e074cb72feadd6f9d32f21d2030d3bdc47 by lebedev.ri
[NFC][SCEV] SCEVExpander::isHighCostExpansionHelper(): check that we processed expression first

Summary:
As far as i can tell this is still NFC.
Initially in rL146438 it was added at the top of the function,
later rL238507 dethroned it, and rL244474 did it again.

I'm not sure if we have already checked the cost of this expansion, we should be doing that again.

Reviewers: reames, mkazantsev, wmi, sanjoy, atrick, igor-laevsky

Reviewed By: mkazantsev

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73706
The file was modifiedllvm/lib/Analysis/ScalarEvolutionExpander.cpp
Commit 2d8275d72e1602a1869e6286b0ffbf9034ab102b by lebedev.ri
[SCEV] SCEVExpander::isHighCostExpansion(): assert if TTI is not provided

Summary:
Currently, as per `check-llvm`, we never call `SCEVExpander::isHighCostExpansion()` with null TTI,
so this appears to be a safe restriction.

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: javed.absar, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73712
The file was modifiedllvm/include/llvm/Analysis/ScalarEvolutionExpander.h
The file was modifiedllvm/lib/Analysis/ScalarEvolutionExpander.cpp
Commit f90973f48645d1d1799d7bdb81cd6873e3a8ab71 by lebedev.ri
[SCEV] SCEVExpander::isHighCostExpansionHelper(): begin cost modelling - model cast cost

Summary:
This is not a NFC, although it does not change any of the existing tests.
I'm not really sure if we should have specific tests for the cost modelling itself.

This is the first patch that actually makes `SCEVExpander::isHighCostExpansionHelper()`
account for the cost of the SCEV expression, and consider the budget available,
by modelling cast expressions.

I believe the logic itself is "pretty obviously correct" - from budget,
we need to subtract the cost of the cast expression from inner type `Op->getType()`
to the `S->getType()` type, and recurse into the expression we are casting.

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: xbolva00, hiraditya, javed.absar, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73716
The file was modifiedllvm/lib/Analysis/ScalarEvolutionExpander.cpp
The file was modifiedllvm/include/llvm/Analysis/ScalarEvolutionExpander.h
Commit b8793f0dabc974aec74ce09362d8790d77c6acba by lebedev.ri
[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model UDiv by power-of-two as LShr

Summary:
Like with casts, we need to subtract the cost of `lshr` instruction
from budget, and recurse into LHS operand.
Seems "pretty obviously correct" to me?

To be noted, there is a number of other shortcuts we //could// cost-model:
* `... + (-1 * ...)` -> `... - ...` <-  likely very frequent case
* `x - (rem x, power-of-2)`, which is currently `(x udiv power-of-2) * power-of-2` -> `x & -log2(power-of-2)`
* `rem x, power-of-2`, which is currently `x - ((x udiv power-of-2) * power-of-2)` -> `x & log2(power-of-2)-1`
* `... * power-of-2` -> `... << log2(power-of-2)` <- likely not very beneficial

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73718
The file was modifiedllvm/lib/Analysis/ScalarEvolutionExpander.cpp
Commit b8abdf9a176116271ed121ebd9c6b2194930e5e7 by lebedev.ri
[NFC][IndVarSimplify] Adjust value names in IndVarSimplify/exit_value_test2.ll

%tmp prefix confuses auto-update scripts
The file was modifiedllvm/test/Transforms/IndVarSimplify/exit_value_test2.ll
Commit cc29600b908ba3aefb41e53398922319841fdb37 by lebedev.ri
[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model plain UDiv

Summary:
If we don't believe this UDiv is actually a LShr in disguise, things are much worse.
First, we try to see if this UDiv actually originates from user code,
by looking for `S + 1`, and if found considering this UDiv to be free.
But otherwise, we always considered this UDiv to be high-cost.

However that is no longer the case with TTI-driven cost model:
our default budget is 4, which matches the default cost of UDiv,
so now we allow a single UDiv to not be counted as high-cost.

While that is the case, it is evident this is actually a regression
due to the fact that cost-modelling is incomplete - we did not account
for the `add`, `mul` costs yet. That is being addressed in D73728.

Cost-modelling for UDiv also seems pretty straight-forward:
subtract cost of the UDiv itself, and recurse into both the LHS and RHS.

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73722
The file was modifiedllvm/lib/Analysis/ScalarEvolutionExpander.cpp
The file was modifiedllvm/test/Transforms/IndVarSimplify/exit_value_test2.ll
Commit 756af2f88bda16a70df200283f833227f336822a by lebedev.ri
[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model add/mul

Summary:
While this resolves the regression from D73722 in `llvm/test/Transforms/IndVarSimplify/exit_value_test2.ll`,
this now regresses `llvm/test/Transforms/IndVarSimplify/elim-extend.ll` `@nestedIV` test,
we no longer can perform that expansion within default budget of `4`, but require budget of `6`.
That regression is being addressed by D73777.

The basic idea here is simple.
```
Op0,  Op1, Op2 ...
|     |    |
\--+--/    |
    |       |
    \---+---/
```
I.e. given N operands, we will have N-1 operations,
so we have to add cost of an add (mul) for **every** Op processed,
**except** the first one, plus we need to recurse into *every* Op.

I'm guessing there's already canonicalization that ensures we won't
have `1` operand in `scMulExpr`, and no `0` in `scAddExpr`/`scMulExpr`.

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73728
The file was modifiedllvm/lib/Analysis/ScalarEvolutionExpander.cpp
The file was modifiedllvm/test/Transforms/IndVarSimplify/elim-extend.ll
The file was modifiedllvm/test/Transforms/IndVarSimplify/exit_value_test2.ll
Commit 0f3c9b54e60b384728c0c24518b8f2645719275e by lebedev.ri
[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model polynomial recurrence

Summary:
So, i wouldn't call this *obviously* correct,
but i think i got it right this time :)

Roughly, we have
```
Op0*x^0 + Op1*x^1 + Op2*x^2 ...
```
where `Op_{n} * x^{n}` is called term, and `n` the degree of term.

Due to the way they are stored internally in `SCEVAddRecExpr`,
i believe we can have `Op_{n}` to be `0`, so we should not charge for those.

I think it is most straight-forward to count the cost in 4 steps:
1. First, count it the same way we counted `scAddExpr`, but be sure to skip terms with zero constants.
   Much like with `add` expr we will have one less addition than number of terms.
2. Each non-constant term (term degree >= 1) requires a multiplication between the `Op_{n}` and `x^{n}`.
   But again, only charge for it if it is required - `Op_{n}` must not be 0 (no term) or 1 (no multiplication needed),
   and obviously don't charge constant terms (`x^0 == 1`).
3. We must charge for all the `x^0`..`x^{poly_degree}` themselves.
   Since `x^{poly_degree}` is `x * x * ...  * x`, i.e. `poly_degree` `x`'es multiplied,
   for final `poly_degree` term we again require `poly_degree-1` multiplications.
   Note that all the `x^{0}`..`x^{poly_degree-1}` will be computed for the free along the way there.
4. And finally, the operands themselves.

Here, much like with add/mul exprs, we really don't look for preexisting instructions..

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: hiraditya, javed.absar, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73741
The file was modifiedllvm/lib/Analysis/ScalarEvolutionExpander.cpp
Commit d6f47aeb5198b142072d8ce2bbf2fdd30d116db0 by lebedev.ri
[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model min/max (PR44668)

Summary:
Previosly we simply always said that `SCEVMinMaxExpr` is too costly to expand.
But this isn't really true, it expands into just a comparison+swap pair.
And again much like with add/mul, there will be one less such pair
than the number of operands. And we need to count the cost of operands themselves.

This does change a number of testcases, and as far as i can tell,
all of these changes are improvements, in the sense that
we fixed up more latches to do the [in]equality comparison.

This concludes cost-modelling changes, no other SCEV expressions exist as of now.

This is a part of addressing [[ https://bugs.llvm.org/show_bug.cgi?id=44668 | PR44668 ]].

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: hiraditya, javed.absar, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73744
The file was modifiedllvm/lib/Analysis/ScalarEvolutionExpander.cpp
The file was modifiedllvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll
The file was modifiedllvm/test/Transforms/IndVarSimplify/eliminate-comparison.ll
The file was modifiedllvm/test/Transforms/IndVarSimplify/elim-extend.ll
The file was modifiedllvm/test/Transforms/IndVarSimplify/lftr-reuse.ll
The file was modifiedllvm/test/Transforms/IndVarSimplify/lftr-multi-exit.ll
The file was modifiedllvm/test/Transforms/IndVarSimplify/eliminate-trunc.ll
The file was modifiedllvm/test/Transforms/IndVarSimplify/iv-widen.ll
The file was modifiedllvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll
The file was modifiedllvm/test/Transforms/IndVarSimplify/full_widening.ll
The file was modifiedllvm/test/Transforms/LoopVectorize/X86/float-induction-x86.ll
Commit 44edc6fd2c63b7db43e13cc8caf1fee79bebdb5f by lebedev.ri
[SCEV] rewriteLoopExitValues(): even if have hard uses, still rewrite if cheap (PR44668)

Summary:
Replacing uses of IV outside of the loop is likely generally useful,
but `rewriteLoopExitValues()` is cautious, and if it isn't told to always
perform the replacement, and there are hard uses of IV in loop,
it doesn't replace.

In [[ https://bugs.llvm.org/show_bug.cgi?id=44668 | PR44668 ]],
that prevents `-indvars` from replacing uses of induction variable
after the loop, which might be one of the optimization failures
preventing that code from being vectorized.

Instead, now that the cost model is fixed, i believe we should be
a little bit more optimistic, and also perform replacement
if we believe it is within our budget.

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=44668 | PR44668 ]].

Reviewers: reames, mkazantsev, asbirlea, fhahn, skatkov

Reviewed By: mkazantsev

Subscribers: nikic, hiraditya, zzheng, javed.absar, dmgreen, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73501
The file was modifiedllvm/test/Transforms/IndVarSimplify/pr28705.ll
The file was removedllvm/test/Transforms/IndVarSimplify/dont-recompute.ll
The file was modifiedllvm/lib/Transforms/Utils/LoopUtils.cpp
The file was addedllvm/test/Transforms/IndVarSimplify/do-recompute-if-cheap.ll
The file was modifiedllvm/test/Transforms/IndVarSimplify/pr39673.ll
The file was modifiedllvm/test/Transforms/IndVarSimplify/elim-extend.ll
The file was modifiedllvm/test/Transforms/IndVarSimplify/lrev-existing-umin.ll
Commit 400ceda425ab392096ff2800acad41a4322974d2 by lebedev.ri
[SCEV][IndVars] Always provide insertion point to the SCEVExpander::isHighCostExpansion()

Summary: This addresses the `llvm/test/Transforms/IndVarSimplify/elim-extend.ll` `@nestedIV` regression from D73728

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73777
The file was modifiedllvm/lib/Transforms/Scalar/IndVarSimplify.cpp
The file was modifiedllvm/lib/Analysis/ScalarEvolutionExpander.cpp
The file was modifiedllvm/test/Transforms/IndVarSimplify/elim-extend.ll
The file was modifiedllvm/include/llvm/Analysis/ScalarEvolutionExpander.h
Commit 6d0d1a63f2a6c120f206a83e7c1ddae9fa5a569a by isanbard
Use "nop" to avoid size warnings.
The file was modifiedclang/test/Analysis/uninit-asm-goto.cpp
Commit 6201f6601dec03e44424ad2d5cc04a9766f194b1 by zoecarver
Check args passed to __builtin_frame_address and __builtin_return_address.

Verifies that an argument passed to __builtin_frame_address or __builtin_return_address is within the range [0, 0xFFFF]

Differential revision: https://reviews.llvm.org/D66839

Re-committed after fixed: c93112dc4f745b0455addb54bfe1c2f79b827c6d
The file was modifiedclang/lib/Sema/SemaChecking.cpp
The file was modifiedclang/test/Sema/builtin-stackaddress.c
Commit c5ce6d8b561a5b2790a56803df24f800df7a76a8 by craig.topper
[X86] Add test to show incorrect ordering of flt.rounds intrinsic relative to calls to fesetround.

We don't order flt.rounds intrinsics relative to side effecting
operations in SelectionDAG. And we CSE multiple calls because of
this.
The file was modifiedllvm/test/CodeGen/X86/flt-rounds.ll
Commit 63cef621f954eb87c494021725f4eeac89132d16 by a.bataev
[LIBOMPTARGET]Fix PR44933: fix crash because of the too early deinitialization of libomptarget.

Summary:
Instead of using global variables with unpredicted time of
deinitialization, use dynamically allocated variables with functions
explicitly marked as global constructor/destructor and priority. This
allows to prevent the crash because of the incorrect order of dynamic
libraries deinitialization.

Reviewers: grokos, hfinkel

Subscribers: caomhin, kkwli0, openmp-commits

Tags: #openmp

Differential Revision: https://reviews.llvm.org/D74837
The file was modifiedopenmp/libomptarget/src/rtl.h
The file was modifiedopenmp/libomptarget/src/device.cpp
The file was addedopenmp/libomptarget/test/offloading/dynamic_module_load.c
The file was modifiedopenmp/libomptarget/src/rtl.cpp
The file was modifiedopenmp/libomptarget/src/interface.cpp
The file was modifiedopenmp/libomptarget/src/api.cpp
The file was modifiedopenmp/libomptarget/src/omptarget.cpp
Commit 430512ed7d7b5e1052fb3b671d8e54fc3afcf490 by Akira
[ObjC][ARC] Don't move a retain call living outside a loop into the loop
body

We started seeing cases where ARC optimizer would move retain calls into
loop bodies, causing imbalance in the number of retain and release
calls, after changes were made to delete inert ARC calls since the inert
calls that used to block code motion are gone.

Fix the bug by setting the CFG hazard flag when visiting a loop header.

rdar://problem/56908836
The file was modifiedllvm/test/Transforms/ObjCARC/cfg-hazards.ll
The file was modifiedllvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
Commit 9c54f6154f748e707ad2385ddf6d66e812890c6a by yitzhakm
[libTooling] Add function to determine associated text of a declaration.

Summary:
This patch adds `getAssociatedRange` which, for a given decl, computes preceding
and trailing text that would conceptually be associated with the decl by the
reader. This includes comments, whitespace, and separators like ';'.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72153
The file was modifiedclang/unittests/Tooling/SourceCodeTest.cpp
The file was modifiedclang/lib/Tooling/Transformer/SourceCode.cpp
The file was modifiedclang/include/clang/Tooling/Transformer/SourceCode.h