platform/upstream/llvm.git
3 years agoRevert "[LV] Unconditionally branch from middle to scalar preheader if the scalar...
Philip Reames [Mon, 17 May 2021 23:49:32 +0000 (16:49 -0700)]
Revert "[LV] Unconditionally branch from middle to scalar preheader if the scalar loop must execute"

This reverts commit c23ce54b36b1a52eb280ea1d59802b56d6dd9800.  I apparently missed some newly added non-x86 tests.

3 years ago[LV] Unconditionally branch from middle to scalar preheader if the scalar loop must...
Philip Reames [Mon, 17 May 2021 23:08:19 +0000 (16:08 -0700)]
[LV] Unconditionally branch from middle to scalar preheader if the scalar loop must execute

This is a resubmit of 3e5ce4 (which was reverted by 7fe41ac).  The original commit caused a PPC build bot failure we never really got to the bottom of.  I can't reproduce the issue, and the bot owner was non-responsive.  In the meantime, we stumbled across an issue which seems possibly related, and worked around a latent bug in 80e8025.  My best guess is that the original patch exposed that latent issue at higher frequency, but it really is just a guess.

Original commit message follows...

If we know that the scalar epilogue is required to run, modify the CFG to end the middle block with an unconditional branch to scalar preheader. This is instead of a conditional branch to either the preheader or the exit block.

The motivation to do this is to support multiple exit blocks. Specifically, the current structure forces us to identify immediate dominators and *which* exit block to branch from in the middle terminator. For the multiple exit case - where we know require scalar will hold - these questions are ill formed.

This is the last change needed to support multiple exit loops, but since the diffs are already large enough, I'm going to land this, and then enable separately. You can think of this as being NFCIish prep work, but the changes are a bit too involved for me to feel comfortable tagging the review that way.

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

3 years ago[RISCV][test] Add new tests of or/xor in the zbs extension
Ben Shi [Mon, 17 May 2021 23:10:17 +0000 (07:10 +0800)]
[RISCV][test] Add new tests of or/xor in the zbs extension

Reviewed By: craig.topper

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

3 years ago[clang][AVR] Redefine [u]int16_t to be compatible with avr-gcc
Ben Shi [Mon, 17 May 2021 23:06:12 +0000 (07:06 +0800)]
[clang][AVR] Redefine [u]int16_t to be compatible with avr-gcc

Reviewed By: efriedma

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

3 years agoRevert "Reset the wakeup timeout when we re-enter the continue wait."
Jim Ingham [Mon, 17 May 2021 22:31:54 +0000 (15:31 -0700)]
Revert "Reset the wakeup timeout when we re-enter the continue wait."

This reverts commit bd5751f3d249ec0798060bd98c07272174c52af0.
This patch series is causing us to every so often miss switching
the state from eStateRunning to eStateStopped when we get the stop
packet from the debug server.

Reverting till I can figure out how that could be happening.

3 years ago[ADT] Add new type traits for type pack indexes
Scott Linder [Wed, 14 Apr 2021 17:25:11 +0000 (17:25 +0000)]
[ADT] Add new type traits for type pack indexes

Similar versions of these already exist, this effectively just just
factors them out into STLExtras. I plan to use these in future patches.

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

3 years ago[ADT] Factor out in_place_t and expose in Optional ctor
Scott Linder [Mon, 5 Apr 2021 22:59:09 +0000 (22:59 +0000)]
[ADT] Factor out in_place_t and expose in Optional ctor

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

3 years ago[AArch64][SVE] Implement extractelement of i1 vectors.
Eli Friedman [Mon, 14 Sep 2020 23:13:37 +0000 (16:13 -0700)]
[AArch64][SVE] Implement extractelement of i1 vectors.

The implementation just extends the vector to a larger element type, and
extracts from that.  Not fancy, but generates reasonable code.

There was discussion in the review of doing the promotion in
target-independent code, but I'm sticking with this to avoid making
LegalizeDAG infrastructure more complicated.

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

3 years agoDo actual DCE in LoopUnroll (try 3)
Philip Reames [Mon, 17 May 2021 21:10:00 +0000 (14:10 -0700)]
Do actual DCE in LoopUnroll (try 3)

Recommitting after fixing a bug found post commit.  Amusingly, try 1 had been correct, and by reverting to incorporate last minute review feedback, I introduce the bug.  Oops.  :)

The problem was that recursively deleting an instruction can delete instructions beyond the current iterator (via a dead phi), thus invalidating iteration.  Test case added in LoopUnroll/dce.ll to cover this case.

LoopUnroll does a limited DCE pass after unrolling, but if you have a chain of dead instructions, it only deletes the last one. Improve the code to recursively delete all trivially dead instructions.

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

3 years ago[test] Free triple in PassBuilderBindingsTest
Arthur Eubanks [Mon, 17 May 2021 20:56:49 +0000 (13:56 -0700)]
[test] Free triple in PassBuilderBindingsTest

3 years ago[WebAssembly] Nullify DBG_VALUE_LISTs in DebugValueManager
Heejin Ahn [Sun, 16 May 2021 10:17:16 +0000 (03:17 -0700)]
[WebAssembly] Nullify DBG_VALUE_LISTs in DebugValueManager

WebAssemblyDebugValueManager class currently does not handle
DBG_VALUE_LIST instructions correctly for two reasons, which are
explained in https://bugs.llvm.org/show_bug.cgi?id=50361.

This effectively nullifies DBG_VALUE_LISTs in
WebAssemblyDebugValueManager so that the info will appear as "optimized
out" in debuggers but still be at least correct in the meantime.

Reviewed By: dschuff, jmorse

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

3 years ago[mlir][NFC] Remove stale `createLowerAffinePass` declaration
River Riddle [Mon, 17 May 2021 20:25:00 +0000 (13:25 -0700)]
[mlir][NFC] Remove stale `createLowerAffinePass` declaration

This pass isn't defined in the Transforms/ library anymore.

3 years ago[Driver][test] Don't assume integrated-as
Jinsong Ji [Mon, 17 May 2021 19:57:30 +0000 (19:57 +0000)]
[Driver][test] Don't assume integrated-as

The tests of fdebug-compilation-dir and -ffile-compilation-dir for `-x
assembler` are assuming integrated-as.
If the platform set the no-itegrated-as by default (eg: AIX for now), then this test will
fail.

Add the -integrated-as to aviod relying on the platform defaults.

Reviewed By: thakis

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

3 years ago[clang CodeGen] Don't crash on large atomic function parameter.
Eli Friedman [Thu, 6 May 2021 19:27:01 +0000 (12:27 -0700)]
[clang CodeGen] Don't crash on large atomic function parameter.

I wouldn't recommend writing code like the testcase; a function
parameter isn't atomic, so using an atomic type doesn't really make
sense.  But it's valid, so clang shouldn't crash on it.

The code was assuming hasAggregateEvaluationKind(Ty) implies Ty is a
RecordType, which isn't true.  Just use isRecordType() instead.

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

3 years ago[lld][MinGW] Introduce aliases for -Bdynamic and -Bstatic
Markus Böck [Mon, 17 May 2021 20:12:22 +0000 (22:12 +0200)]
[lld][MinGW] Introduce aliases for -Bdynamic and -Bstatic

Besides -Bdynamic and -Bstatic, ld documents additional aliases for both of these options. Instead of -Bstatic, one may write -dn, -non_shared or -static. Instead of -Bdynamic one may write -dy or -call_shared. Source: https://sourceware.org/binutils/docs-2.36/ld/Options.html

This patch adds those aliases to the MinGW driver of lld for the sake of ld compatibility.

Encountered this case while compiling a static Qt 6.1 distribution and got build failures as -static was passed directly to the linker, instead of through the compiler driver.

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

3 years ago[lldb] Document ctrl-f for completing show-autosuggestion
Dave Lee [Sat, 15 May 2021 01:11:29 +0000 (18:11 -0700)]
[lldb] Document ctrl-f for completing show-autosuggestion

Document how to complete command line suggestions provided by `show-autosuggestion`.

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

3 years agoRevert "X86: support Swift Async context"
Mitch Phillips [Mon, 17 May 2021 19:36:37 +0000 (12:36 -0700)]
Revert "X86: support Swift Async context"

This reverts commit 747e5cfb9f5d944b47fe014925b0d5dc2fda74d7.

Reason: New frame layout broke the sanitizer unwinder. Not clear why,
but seems like some of the changes aren't always guarded by Swyft
checks. See
https://reviews.llvm.org/rG747e5cfb9f5d944b47fe014925b0d5dc2fda74d7 for
more information.

3 years ago[NFC][scudo] Clang-format tests
Vitaly Buka [Mon, 17 May 2021 19:24:06 +0000 (12:24 -0700)]
[NFC][scudo] Clang-format tests

3 years agoRevert "[Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable"
Arthur Eubanks [Mon, 17 May 2021 19:16:10 +0000 (12:16 -0700)]
Revert "[Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable"

This reverts commit 14dfb3831c425c7f22540a2160424224008c257e.

More false positives, see D100581.

3 years ago[gn build] Port 0c557db61711
LLVM GN Syncbot [Mon, 17 May 2021 18:56:03 +0000 (18:56 +0000)]
[gn build] Port 0c557db61711

3 years ago[InstCombine] fold fnegs around select
Sanjay Patel [Mon, 17 May 2021 18:27:32 +0000 (14:27 -0400)]
[InstCombine] fold fnegs around select

This is one of the folds requested in:
https://llvm.org/PR39480

https://alive2.llvm.org/ce/z/NczU3V

Note - this uses the normal FMF propagation logic
(flags transfer from the final value to new/intermediate ops).
It's not clear if this matches what Alive2 implements,
so we may want to adjust one or the other.

3 years ago[InstCombine] add tests for fneg-of-select; NFC
Sanjay Patel [Mon, 17 May 2021 16:41:57 +0000 (12:41 -0400)]
[InstCombine] add tests for fneg-of-select; NFC

3 years ago[AArch64] Support customizing stack protector guard
Nick Desaulniers [Mon, 17 May 2021 18:41:24 +0000 (11:41 -0700)]
[AArch64] Support customizing stack protector guard

Follow up to D88631 but for aarch64; the Linux kernel uses the command
line flags:

1. -mstack-protector-guard=sysreg
2. -mstack-protector-guard-reg=sp_el0
3. -mstack-protector-guard-offset=0

to use the system register sp_el0 for the stack canary, enabling the
kernel to have a unique stack canary per task (like a thread, but not
limited to userspace as the kernel can preempt itself).

Address pr/47341 for aarch64.

Fixes: https://github.com/ClangBuiltLinux/linux/issues/289
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed By: xiangzhangllvm, DavidSpickett, dmgreen

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

3 years agogn build: Only build the hwasan runtime in aliasing mode on x86.
Peter Collingbourne [Mon, 17 May 2021 18:44:06 +0000 (11:44 -0700)]
gn build: Only build the hwasan runtime in aliasing mode on x86.

The LAM mode is currently untested by check-hwasan, so we only need
to build the runtime in aliasing mode. Because LAM mode will always
need to be conditional (because only certain hardware will support
it) we can always just disable the LAM lit tests if it ever starts
being tested.

3 years agoAdd type function for ConstShape op.
Jacques Pienaar [Mon, 17 May 2021 18:47:19 +0000 (11:47 -0700)]
Add type function for ConstShape op.

- Enables inferring return type for ConstShape, takes into account valid return types;
- The compatible return type function could be reused, leaving that for next use refactoring;

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

3 years ago[NewPM] Add C bindings for new pass manager
Mats Larsen [Mon, 17 May 2021 18:03:47 +0000 (11:03 -0700)]
[NewPM] Add C bindings for new pass manager

This patch contains the bare minimum to run the new Pass Manager from the LLVM-C APIs. It does not feature PGOOptions, PassPlugins or Debugify in its current state. Bugzilla: PR48499

Reviewed By: aeubanks

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

3 years ago[mlir][sparse] replace experimental flag with inplace attribute
Aart Bik [Sat, 15 May 2021 04:02:31 +0000 (21:02 -0700)]
[mlir][sparse] replace experimental flag with inplace attribute

The experimental flag for "inplace" bufferization in the sparse
compiler can be replaced with the new inplace attribute. This gives
a uniform way of expressing the more efficient way of bufferization.

Reviewed By: bixia

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

3 years ago[lld/mac] Honor REFERENCED_DYAMICALLY, set it on __mh_execute_header
Nico Weber [Mon, 17 May 2021 13:15:39 +0000 (09:15 -0400)]
[lld/mac] Honor REFERENCED_DYAMICALLY, set it on __mh_execute_header

Has the effect that `__mh_execute_header` stays in the symbol table of
outputs even after running `strip` on the output. I don't know if that's
important for anything -- my motivation for the patch is just is to make
the output more similar to ld64.

(Corresponds to symbolTableInAndNeverStrip in ld64.)

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

3 years agoMerge with mainline.
Chris Lattner [Mon, 17 May 2021 16:51:45 +0000 (09:51 -0700)]
Merge with mainline.

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

3 years ago[analyzer] Engine: fix crash with SEH __leave keyword
Abbas Sabra [Mon, 17 May 2021 18:10:26 +0000 (20:10 +0200)]
[analyzer] Engine: fix crash with SEH __leave keyword

MSVC has a `try-except` statement.
This statement could containt a `__leave` keyword, which is similar to
`goto` to the end of the try block. The semantic of this keyword is not
implemented.

We should at least parse such code without crashing.

https://docs.microsoft.com/en-us/cpp/cpp/try-except-statement?view=msvc-160

Patch By: AbbasSabra!

Reviewed By: steakhal

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

3 years ago[Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable
Michael Benfield [Mon, 17 May 2021 17:50:25 +0000 (10:50 -0700)]
[Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

These are intended to mimic warnings available in gcc.

Reviewed By: aeubanks

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

3 years agoRevert "[NewPM] Add C bindings for new pass manager"
Nico Weber [Mon, 17 May 2021 17:59:12 +0000 (13:59 -0400)]
Revert "[NewPM] Add C bindings for new pass manager"

This reverts commit cd220a06782c3da13a53de2fdf10d928eef6460c.
Doesn't build.

3 years agoReset the wakeup timeout when we re-enter the continue wait.
Jim Ingham [Sat, 15 May 2021 21:59:14 +0000 (14:59 -0700)]
Reset the wakeup timeout when we re-enter the continue wait.

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

3 years ago[NewPM] Add C bindings for new pass manager
Mats Larsen [Mon, 17 May 2021 17:47:45 +0000 (10:47 -0700)]
[NewPM] Add C bindings for new pass manager

This patch contains the bare minimum to run the new Pass Manager from the LLVM-C APIs. It does not feature PGOOptions, PassPlugins or Debugify in its current state. Bugzilla: PR48499

Reviewed By: aeubanks

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

3 years ago[LLDB] Switch from using member_clang_type.GetByteSize() to member_type->GetByteSize...
Shafik Yaghmour [Mon, 17 May 2021 17:34:16 +0000 (10:34 -0700)]
[LLDB] Switch from using member_clang_type.GetByteSize() to member_type->GetByteSize() in ParseSingleMember

We have a bug in which using member_clang_type.GetByteSize() triggers record
layout and during this process since the record was not yet complete we ended
up reaching a record that had not been layed out yet.
Using member_type->GetByteSize() avoids this situation since it relies on size
from DWARF and will not trigger record layout.

For reference: rdar://77293040

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

3 years ago[LoopIdiom] 'logical right-shift until zero' ('count active bits') "on steroids"...
Roman Lebedev [Mon, 17 May 2021 17:15:17 +0000 (20:15 +0300)]
[LoopIdiom] 'logical right-shift until zero' ('count active bits') "on steroids" idiom recognition.

I think i've added exhaustive test coverage, and i have verified that alive2 is happy with all the tests,
so in principle i'm fine with landing this without review, but just in case..

This adds support for the "count active bits" pattern, i.e.:
```
int countActiveBits(unsigned val) {
    int cnt = 0;
    for( ; (val >> cnt) != 0; ++cnt)
        ;
    return cnt;
}
```
but a somewhat more general one, since that is what i need:
```
int countActiveBits(unsigned val, int start, int off) {
    int cnt;
    for (cnt = start; val >> (cnt + off); cnt++)
        ;
    return cnt;
}
```

I've followed in footstep of 'left-shift until bittest' idiom (D91038),
in the sense that iff the `ctlz` intrinsic is cheap, we'll transform,
regardless of all other factors.

This can have a shocking effect on certain benchmarks:
```
raw.pixls.us-unique/Olympus/XZ-1$ /repositories/googlebenchmark/tools/compare.py -a benchmarks ~/rawspeed/build-{old,new}/src/utilities/rsbench/rsbench --benchmark_counters_tabular=true --benchmark_min_time=0.00000001 --benchmark_repetitions=128 p1319978.orf
RUNNING: /home/lebedevri/rawspeed/build-old/src/utilities/rsbench/rsbench --benchmark_counters_tabular=true --benchmark_min_time=0.00000001 --benchmark_repetitions=128 p1319978.orf --benchmark_display_aggregates_only=true --benchmark_out=/tmp/tmp49_28zcm
2021-05-09T01:06:05+03:00
Running /home/lebedevri/rawspeed/build-old/src/utilities/rsbench/rsbench
Run on (32 X 3600.24 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x16)
  L1 Instruction 32 KiB (x16)
  L2 Unified 512 KiB (x16)
  L3 Unified 32768 KiB (x2)
Load Average: 5.26, 6.29, 3.49
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Benchmark                                                      Time             CPU   Iterations  CPUTime,s CPUTime/WallTime     Pixels Pixels/CPUTime Pixels/WallTime Raws/CPUTime Raws/WallTime WallTime,s
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
p1319978.orf/threads:32/process_time/real_time_mean          145 ms          145 ms          128   0.145319         0.999981   10.1568M       69.8949M        69.8936M      6.88159       6.88146   0.145322
p1319978.orf/threads:32/process_time/real_time_median        145 ms          145 ms          128   0.145317         0.999986   10.1568M       69.8941M        69.8931M      6.88151       6.88141   0.145319
p1319978.orf/threads:32/process_time/real_time_stddev      0.766 ms        0.766 ms          128   766.586u         15.1302u          0       354.167k        354.098k    0.0348699     0.0348631   766.469u
RUNNING: /home/lebedevri/rawspeed/build-new/src/utilities/rsbench/rsbench --benchmark_counters_tabular=true --benchmark_min_time=0.00000001 --benchmark_repetitions=128 p1319978.orf --benchmark_display_aggregates_only=true --benchmark_out=/tmp/tmpwb9sw2x0
2021-05-09T01:06:24+03:00
Running /home/lebedevri/rawspeed/build-new/src/utilities/rsbench/rsbench
Run on (32 X 3599.95 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x16)
  L1 Instruction 32 KiB (x16)
  L2 Unified 512 KiB (x16)
  L3 Unified 32768 KiB (x2)
Load Average: 4.05, 5.95, 3.43
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Benchmark                                                      Time             CPU   Iterations  CPUTime,s CPUTime/WallTime     Pixels Pixels/CPUTime Pixels/WallTime Raws/CPUTime Raws/WallTime WallTime,s
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
p1319978.orf/threads:32/process_time/real_time_mean         99.8 ms         99.8 ms          128  0.0997758         0.999972   10.1568M       101.797M        101.794M      10.0225       10.0222  0.0997786
p1319978.orf/threads:32/process_time/real_time_median       99.7 ms         99.7 ms          128  0.0997165         0.999985   10.1568M       101.857M        101.854M      10.0284       10.0281  0.0997195
p1319978.orf/threads:32/process_time/real_time_stddev      0.224 ms        0.224 ms          128   224.166u          34.345u          0        226.81k        227.231k    0.0223309     0.0223723   224.586u
Comparing /home/lebedevri/rawspeed/build-old/src/utilities/rsbench/rsbench to /home/lebedevri/rawspeed/build-new/src/utilities/rsbench/rsbench
Benchmark                                                               Time             CPU      Time Old      Time New       CPU Old       CPU New
----------------------------------------------------------------------------------------------------------------------------------------------------
p1319978.orf/threads:32/process_time/real_time_pvalue                 0.0000          0.0000      U Test, Repetitions: 128 vs 128
p1319978.orf/threads:32/process_time/real_time_mean                  -0.3134         -0.3134           145           100           145           100
p1319978.orf/threads:32/process_time/real_time_median                -0.3138         -0.3138           145           100           145           100
p1319978.orf/threads:32/process_time/real_time_stddev                -0.7073         -0.7078             1             0             1             0

```

Reviewed By: craig.topper, zhuhan0

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

3 years ago[HWASan] Don't build alias mode on non-x86.
Matt Morehouse [Mon, 17 May 2021 17:22:40 +0000 (10:22 -0700)]
[HWASan] Don't build alias mode on non-x86.

Alias mode is not expected work on non-x86, so don't build it there.
Should fix the aarch64 bot.

3 years agoMake `mlir::OpState::operator bool` explicit
Mehdi Amini [Mon, 17 May 2021 17:11:41 +0000 (17:11 +0000)]
Make `mlir::OpState::operator bool` explicit

This change makes the conversion of an mlir::OpState to bool `explicit`. Idiomatic boolean uses continue to work as before, but questionable implicit uses (e.g. accumulating over a range of OpStates to count "true" states) become ill-formed. This makes the class interface a lilttle less error-prone.

I tested this change on our internal (fairly large) codebase, and only one fix was needed, which was ultimately an improvement of the affected code.

Reviewed By: rriddle, mehdi_amini

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

3 years ago[HIP] Fix spack detection
Yaxun (Sam) Liu [Sat, 15 May 2021 14:57:29 +0000 (10:57 -0400)]
[HIP] Fix spack detection

Missing or duplicate spack package should not cause error, since
users may only installed llvm/clang package, or users may installed
duplicate HIP package but will use environment variable or compiler
option to choose HIP path.

The message about missing or duplicate spack package is informational,
therefore should be emitted only when -v is specified.

Reviewed by: Artem Belevich

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

3 years ago[mlir][tosa] Fix tosa.avg_pool2d lowering to normalize correctly
Rob Suderman [Mon, 17 May 2021 17:00:09 +0000 (10:00 -0700)]
[mlir][tosa] Fix tosa.avg_pool2d lowering to normalize correctly

Initial version of pooling assumed normalization was accross all elements
equally. TOSA actually requires the noramalization is perform by how
many elements were summed (edges are not artifically dimmer). Updated
the lowering to reflect this change with corresponding tests.

Reviewed By: NatashaKnk

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

3 years ago[Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX redux.sync instructions
Steffen Larsen [Mon, 17 May 2021 16:23:44 +0000 (09:23 -0700)]
[Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX redux.sync instructions

Adds NVPTX builtins and intrinsics for the CUDA PTX `redux.sync` instructions
for `sm_80` architecture or newer.

PTX ISA description of `redux.sync`:
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-redux-sync

Authored-by: Steffen Larsen <steffen.larsen@codeplay.com>
Differential Revision: https://reviews.llvm.org/D100124

3 years ago[Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX cp.async instructions
Stuart Adams [Mon, 17 May 2021 16:28:20 +0000 (09:28 -0700)]
[Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX cp.async instructions

Adds NVPTX builtins and intrinsics for the CUDA PTX `cp.async` instructions for
`sm_80` architecture or newer.

PTX ISA description of `cp.async`:
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-asynchronous-copy
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-cp-async-mbarrier-arrive

Authored-by: Stuart Adams <stuart.adams@codeplay.com>
Co-Authored-by: Alexander Johnston <alexander@codeplay.com>
Differential Revision: https://reviews.llvm.org/D100394

3 years ago[llvm][doc] fix header for read/write_register intrinsics in LangRef
Alex Zinenko [Mon, 17 May 2021 16:37:00 +0000 (18:37 +0200)]
[llvm][doc] fix header for read/write_register intrinsics in LangRef

Mutli-line headers are not allowed in RST, reformat the header to be a
single wide line.

3 years ago[HWASan] Build separate LAM runtime on x86_64.
Matt Morehouse [Fri, 14 May 2021 16:52:47 +0000 (09:52 -0700)]
[HWASan] Build separate LAM runtime on x86_64.

Since we have both aliasing mode and Intel LAM on x86_64, we need to
choose the mode at either run time or compile time.  This patch
implements the plumbing to build both and choose between them at
compile time.

Reviewed By: vitalybuka, eugenis

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

3 years ago[OpenMP] Fixed Bug 49356
Shilei Tian [Mon, 17 May 2021 16:14:34 +0000 (12:14 -0400)]
[OpenMP] Fixed Bug 49356

Bug 49356 (https://bugs.llvm.org/show_bug.cgi?id=49356) reports crash in
the test case `tasking/bug_taskwait_detach.cpp`, which is caused by the wrong
function declaration. `gtid` in `__kmpc_omp_task` should be `kmp_int32`.

Reviewed By: AndreyChurbanov

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

3 years ago[LoopUnroll] Add multi-exit test which does not exit through latch.
Florian Hahn [Mon, 17 May 2021 15:31:12 +0000 (16:31 +0100)]
[LoopUnroll] Add multi-exit test which does not exit through latch.

This patch adds a new test for loop-unrolling with multiple exiting
blocks, where the latch does not exit, but the header does. This can
happen when the loop has not been rotated, e.g. due to minsize.

Inspired by the following end-to-end test, using -Oz
https://godbolt.org/z/fP6sna8qK

    bool foo(int *ptr, int limit) {
        #pragma clang loop unroll(full)
        for (unsigned int i = 0; i < 4; i++) {
            if (ptr[i] > limit)
            return false;
            ptr[i]++;
        }
        return true;
    }

3 years ago[AMDGPU] Set unused dst_sel to '?' in the encoding
Stanislav Mekhanoshin [Fri, 14 May 2021 20:04:49 +0000 (13:04 -0700)]
[AMDGPU] Set unused dst_sel to '?' in the encoding

This is to allow disasm with any bits in the unused fields.

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

3 years ago[AIX] Implement AIX special bitfield related alignment rules
Xiangling Liao [Mon, 17 May 2021 14:58:11 +0000 (10:58 -0400)]
[AIX] Implement AIX special bitfield related alignment rules

1.[bool, char, short] bitfields have the same alignment as unsigned int
2.Adjust alignment on typedef field decls/honor align attribute
3.Fix alignment for scoped enum class
4.Long long bitfield has 4bytes alignment and StorageUnitSize under 32 bit
  compile mode

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

3 years ago[mlir][openacc] Translate ExitDataop to LLVM IR
Valentin Clement [Mon, 17 May 2021 15:11:28 +0000 (11:11 -0400)]
[mlir][openacc] Translate ExitDataop to LLVM IR

Translate ExitDataOp with delete and copyout operands to runtime call.
This is done in a similar way as D101504.

Reviewed By: kiranchandramohan

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

3 years ago[x86] update fma test with deprecated intrinsics; NFC
Sanjay Patel [Mon, 17 May 2021 14:39:33 +0000 (10:39 -0400)]
[x86] update fma test with deprecated intrinsics; NFC

All of the CHECK lines should be identical to before,
but without any of the x86-specific calls that were
replaced with generic FMA long ago.

The file still has value because it shows a miscompile
as demonstrated in D90901, but we probably need to
add tests with FMF to make that explicit without
losing coverage.

3 years ago[X86] Don't dereference a dyn_cast<> - use a cast<> instead. NFCI.
Simon Pilgrim [Mon, 17 May 2021 14:57:00 +0000 (15:57 +0100)]
[X86] Don't dereference a dyn_cast<> - use a cast<> instead. NFCI.

dyn_cast<> can return null if the cast fails, by using cast<> we assert that the cast is correct helping to avoid a potential null dereference.

3 years ago[clang] In DependencyCollector on Windows, ignore case and separators when discarding...
Sylvain Audi [Wed, 12 May 2021 13:56:52 +0000 (09:56 -0400)]
[clang] In DependencyCollector on Windows, ignore case and separators when discarding duplicate dependency file paths.

This patch removes duplicates also encountered in the output of clang-scan-deps when one same header file is encountered with different casing and/or different separators ('/' vs '\').

The case of separators can appear when the same file is included externally by
 `#include <folder/file.h>`

whereas a file from the same folder does
 `#include "file.h"`

Under Windows, clang computes the paths using '/' from the include directive, the `\` from the -I options, and the concatenations use the native `\`, leading to internal paths containing a mix of both separators.

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

3 years ago[AMDGPU] Tweak VOP3_INTERP16 profile
Jay Foad [Fri, 14 May 2021 12:38:47 +0000 (13:38 +0100)]
[AMDGPU] Tweak VOP3_INTERP16 profile

Set the output register class based on the output type, instead of
hard-coding VGPR_32. I think this is more correct. It doesn't make any
difference at the moment because we use the same class for 16- and
32-bit results, but it might in future if we make more use of true
16-bit register classes.

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

3 years ago[RISCV][NFC] Correct alignment in scatter/gather tests
Fraser Cormack [Mon, 17 May 2021 14:10:54 +0000 (15:10 +0100)]
[RISCV][NFC] Correct alignment in scatter/gather tests

This lays the groundwork for changes to alignment in D102493 to be more
apparent.

3 years ago[APInt][NFC] Fix typo vlalue->value
Andy Yankovsky [Mon, 17 May 2021 13:11:19 +0000 (15:11 +0200)]
[APInt][NFC] Fix typo vlalue->value

Reviewed By: fhahn

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

3 years ago[clang-tidy] Fix altera-struct-pack-align crash for struct fields with incomplete...
Georgy Komarov [Sun, 16 May 2021 05:27:46 +0000 (08:27 +0300)]
[clang-tidy] Fix altera-struct-pack-align crash for struct fields with incomplete type

We can only use ASTContext::getTypeInfo for complete types.

This fixes bugzilla issue 50313.

Reviewed By: aaron.ballman

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

3 years ago[mlir] Improve TransferOp verifier: broadcasts are in_bounds
Matthias Springer [Mon, 17 May 2021 13:26:48 +0000 (22:26 +0900)]
[mlir] Improve TransferOp verifier: broadcasts are in_bounds

Broadcast dimensions of vector transfer ops are always in-bounds. This is consistent with the fact that the starting position of a transfer is always in-bounds.

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

3 years ago[mlir] fix misformatted documentation for memref convention
Alex Zinenko [Mon, 17 May 2021 13:33:20 +0000 (15:33 +0200)]
[mlir] fix misformatted documentation for memref convention

The code-block ending marker was missing.

3 years agoSilence "Undefined or garbage value returned to caller" static analysis warning....
Simon Pilgrim [Mon, 17 May 2021 13:08:27 +0000 (14:08 +0100)]
Silence "Undefined or garbage value returned to caller" static analysis warning. NFCI.

3 years ago[AArch64] Lower bitreverse in ISel
Irina Dobrescu [Mon, 17 May 2021 11:59:03 +0000 (12:59 +0100)]
[AArch64] Lower bitreverse in ISel

Adding lowering support for bitreverse.

Previously, lowering bitreverse would expand it into a series of other instructions. This patch makes it so this produces a single rbit instruction instead.

Reviewed By: dmgreen

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

3 years ago[DebugInfo] Fix DWARF expressions for __block vars that are not on the heap
Raphael Isemann [Mon, 17 May 2021 12:02:48 +0000 (14:02 +0200)]
[DebugInfo] Fix DWARF expressions for __block vars that are not on the heap

`__block` variables used to be always stored on the head instead of stack.
D51564 allowed `__block` variables to the stored on the stack like normal
variablesif they not captured by any escaping block, but the debug-info
generation code wasn't made aware of it so we still unconditionally emit DWARF
expressions pointing to the heap.

This patch makes CGDebugInfo use the `EscapingByref` introduced in D51564 that
tracks whether the `__block` variable is actually on the heap. If it's stored on
the stack instead we just use the debug info we would generate for normal
variables instead.

Reviewed By: ahatanak, aprantl

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

3 years ago[mlir][memref] Mark memref.buffer_cast as NoSideEffect
Stephan Herhut [Mon, 17 May 2021 12:01:13 +0000 (14:01 +0200)]
[mlir][memref] Mark memref.buffer_cast as NoSideEffect

This brings it in line with the bultin unrealized_conversion_cast,
which memref.buffer_cast is a specialized version of.

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

3 years agoPut back the trailing commas on TYPED_TEST_SUITE
Benjamin Kramer [Mon, 17 May 2021 12:12:11 +0000 (14:12 +0200)]
Put back the trailing commas on TYPED_TEST_SUITE

This avoids a -pedantic warning:
warning: ISO C++11 requires at least one argument for the "..." in a variadic macro

See also https://github.com/google/googletest/issues/2271

3 years ago[InstCombine] isFreeToInvert(): constant expressions aren't free to invert (PR50370)
Roman Lebedev [Mon, 17 May 2021 11:53:53 +0000 (14:53 +0300)]
[InstCombine] isFreeToInvert(): constant expressions aren't free to invert (PR50370)

This fixes https://bugs.llvm.org/show_bug.cgi?id=50370,
which reports a yet another endless combine loop,
this one regressed from 554b1bced325a8d860ad00bd59020d66d01c95f8,
which fixed yet another endless combine loop (PR50308)

This code had fallen into the very typical pitfall of forgetting
that constant expressions exist, and they aren't free to invert,
because the `not` won't be absorbed by the "constant",
but will remain a (constant) expression...

3 years ago[X86] Regenerate cmov.ll tests
Simon Pilgrim [Mon, 17 May 2021 11:47:54 +0000 (12:47 +0100)]
[X86] Regenerate cmov.ll tests

3 years ago[debuginfo-tests] Fix environment variable used to specify LLDB
James Henderson [Thu, 6 May 2021 08:44:36 +0000 (09:44 +0100)]
[debuginfo-tests] Fix environment variable used to specify LLDB

Currently, if the user specifies the environment variable 'CLANG', tests
will attempt to use the value as a path to the clang executable.
Previously, lldb could also be specified via the CLANG environment
variable, but this was almost certainly a bug, because that meant both
clang and lldb would have the same path. This patch changes the
environment variable for lldb to 'LLDB'.

Reviewed by: thopre, teemperor

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

3 years agoRevert "[mlir] Add folder for complex.ReOp and complex.ImOp."
Adrian Kuegel [Mon, 17 May 2021 11:48:54 +0000 (13:48 +0200)]
Revert "[mlir] Add folder for complex.ReOp and complex.ImOp."

This reverts commit 6b49834d652ba70fc24eaea1c37330639d697de5.

Some tests fail.

3 years agoClean up uses of gmock Invoke in an attempt to make it work with GCC 6.2. NFCI.
Benjamin Kramer [Mon, 17 May 2021 11:48:09 +0000 (13:48 +0200)]
Clean up uses of gmock Invoke in an attempt to make it work with GCC 6.2. NFCI.

3 years ago[OpenCL] Fix reinterpret_cast of vectors
Ole Strohm [Mon, 17 May 2021 11:02:54 +0000 (12:02 +0100)]
[OpenCL] Fix reinterpret_cast of vectors

Fixes issues with vectors in reinterpret_cast in C++ for OpenCL
and adds tests to make sure they both pass without errors and
generate the correct code.

Fixes: PR47977

Reviewed By: Anastasia

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

3 years ago[PowerPC] Add patterns for vselect of v1i128
Nemanja Ivanovic [Mon, 17 May 2021 11:36:36 +0000 (06:36 -0500)]
[PowerPC] Add patterns for vselect of v1i128

These patterns are missing even though the underlying instruction
doesn't really care about the type. Added these patterns to resolve
https://bugs.llvm.org/show_bug.cgi?id=50084

3 years ago[mlir] Add folder for complex.ReOp and complex.ImOp.
Adrian Kuegel [Mon, 17 May 2021 11:21:24 +0000 (13:21 +0200)]
[mlir] Add folder for complex.ReOp and complex.ImOp.

Now that complex constants are supported, we can also fold.

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

3 years agoRevert "[clang][deps] Support inferred modules"
Jan Svoboda [Mon, 17 May 2021 11:23:05 +0000 (13:23 +0200)]
Revert "[clang][deps] Support inferred modules"

This reverts commit 1d9e8e13

Something is off with handling Windows paths: http://45.33.8.238/win/38908/step_7.txt
Most likely introduced in https://reviews.llvm.org/D102491

3 years ago[Test] Auto-generate checks in a test (prepring to update)
Max Kazantsev [Mon, 17 May 2021 11:25:59 +0000 (18:25 +0700)]
[Test] Auto-generate checks in a test (prepring to update)

3 years ago[OpenCL] Drop pragma handling for extension types/decls.
Anastasia Stulova [Mon, 17 May 2021 10:58:32 +0000 (11:58 +0100)]
[OpenCL] Drop pragma handling for extension types/decls.

Drop non-conformant extension pragma implementation as
it does not properly disable anything and therefore
enabling non-disabled logic has no meaning.

This simplifies clang code and user interface to the extension
functionality. With this patch extension pragma 'begin'/'end'
and 'enable'/'disable' are only accepted for backward
compatibility and no longer have any default behavior.

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

3 years ago[PowerPC] Do not emit dssall on AIX
Nemanja Ivanovic [Mon, 17 May 2021 11:05:36 +0000 (06:05 -0500)]
[PowerPC] Do not emit dssall on AIX

This instruction is a nop on all server cores (certainly on all
cores that AIX supports) so it is fine to emit a nop instead of it.
In fact, that is exactly what XL emits. So we emit a nop on AIX
and we leave the codegen as is on other platforms since there may
indeed be cores out there for which this actually does some prefetching.

3 years ago[clang][deps] Specify Python 3 in shebang
Jan Svoboda [Mon, 17 May 2021 11:02:25 +0000 (13:02 +0200)]
[clang][deps] Specify Python 3 in shebang

Some build bots don't like plain `python` in the shebang: https://lab.llvm.org/buildbot/#/builders/139/builds/4147.

3 years ago[gn build] reformat all gn files
Nico Weber [Mon, 17 May 2021 10:59:43 +0000 (06:59 -0400)]
[gn build] reformat all gn files

$ git ls-files '*.gn' '*.gni' | xargs llvm/utils/gn/gn.py format

3 years ago[gn build] Add build file for msan runtime
Nico Weber [Sat, 15 May 2021 03:07:09 +0000 (23:07 -0400)]
[gn build] Add build file for msan runtime

Works for the examples on
https://clang.llvm.org/docs/MemorySanitizer.html

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

3 years agoX86: support Swift Async context
Tim Northover [Tue, 12 Jan 2021 13:12:40 +0000 (13:12 +0000)]
X86: support Swift Async context

This adds support to the X86 backend for the newly committed swiftasync
function parameter. If such a (pointer) parameter is present it gets stored
into an augmented frame record (populated in IR, but generally containing
enhanced backtrace for coroutines using lots of tail calls back and forth).

The context frame is identical to AArch64 (primarily so that unwinders etc
don't get extra complexity). Specfically, the new frame record is [AsyncCtx,
%rbp, ReturnAddr], and its presence is signalled by bit 60 of the stored %rbp
being set to 1. %rbp still points to the frame pointer in memory for backwards
compatibility (only partial on x86, but OTOH the weird AsyncCtx before the rest
of the record is because of x86).

3 years agoAArch64: mark x22 livein if it's an async context that gets stored.
Tim Northover [Mon, 17 May 2021 10:34:16 +0000 (11:34 +0100)]
AArch64: mark x22 livein if it's an async context that gets stored.

This fixes a crash with expensive checks enabled (the verifier was not happy).

3 years ago[clangd][QueryDriver] Dont check for existence of driver
Kadir Cetinkaya [Thu, 13 May 2021 18:56:04 +0000 (20:56 +0200)]
[clangd][QueryDriver] Dont check for existence of driver

Execute implementations already checks for permissions and existence
and returns relevant errors as necessary, so instead of printing our own errors,
we just print theirs.

This also fixes a case in windows where the driver might be missing the `.exe`
suffix. Previously, clangd would reject such a driver because sys::fs::exists is
strict, whereas the underlying Execute implementation would check with `.exe`
suffix too.

Fixes https://github.com/clangd/clangd/issues/93

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

3 years ago[Test] Fix test to make the transform for which is was added legal
Max Kazantsev [Mon, 17 May 2021 10:13:49 +0000 (17:13 +0700)]
[Test] Fix test to make the transform for which is was added legal

%limit in these tests is supposed to be positive.

3 years agoAdd `mlirModuleFromOperation` to C API
Adam Paszke [Mon, 17 May 2021 10:14:02 +0000 (10:14 +0000)]
Add `mlirModuleFromOperation` to C API

At the moment `MlirModule`s can be converted to `MlirOperation`s, but not
the other way around (at least not without going around the C API). This
makes it impossible to e.g. run passes over a `ModuleOp` created through
`mlirOperationCreate`.

Reviewed By: nicolasvasilache, mehdi_amini

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

3 years ago[TargetLowering] prepareUREMEqFold/prepareSREMEqFold - account for non legal shift...
Simon Pilgrim [Mon, 17 May 2021 10:03:12 +0000 (11:03 +0100)]
[TargetLowering] prepareUREMEqFold/prepareSREMEqFold - account for non legal shift types

Ensure we tell getShiftAmountTy that we're working with pre-legalized types to prevent cases where the (legalized) shift type can no longer handle the (non-legalized) type width.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34366

3 years agoRevert "tsan: mark sigwait as blocking"
Florian Hahn [Mon, 17 May 2021 09:57:59 +0000 (10:57 +0100)]
Revert "tsan: mark sigwait as blocking"

This reverts commit 5dad3d1ba9ad01152be21e94cfbbfb31659ea3e1.

The added test (signal_block2.cpp) does not terminate on some Darwin
configurations and is causing Green Dragon bots to fail. First
failure of the test started in
    http://green.lab.llvm.org/green/job/clang-stage1-RA/20767/

3 years agoIR/AArch64/X86: add "swifttailcc" calling convention.
Tim Northover [Thu, 19 Nov 2020 12:32:50 +0000 (12:32 +0000)]
IR/AArch64/X86: add "swifttailcc" calling convention.

Swift's new concurrency features are going to require guaranteed tail calls so
that they don't consume excessive amounts of stack space. This would normally
mean "tailcc", but there are also Swift-specific ABI desires that don't
naturally go along with "tailcc" so this adds another calling convention that's
the combination of "swiftcc" and "tailcc".

Support is added for AArch64 and X86 for now.

3 years ago[clang][deps] Support inferred modules
Michael Spencer [Mon, 17 May 2021 08:41:44 +0000 (10:41 +0200)]
[clang][deps] Support inferred modules

This patch adds support for inferred modules to the dependency scanner.

Effectively a cherry-pick of https://github.com/apple/llvm-project/pull/699 authored by @Bigcheese with libclang and other changes omitted.

Contains following changes:

1. [Clang][ScanDeps] Ignore __inferred_module.map dependency.
  * This shows up with inferred modules, but it doesn't exist on disk, so don't report it as a dependency.

2. [Clang][ScanDeps] Use the module map a module was inferred from for inferred modules.

Also includes a smoke test that uses clang-scan-deps output to perform an explicit build. There's no intention to duplicate whatever `test/Modules` contains, just to verify the produced command-line does "work" (with very loose definition of work).

Split from D100934.

Reviewed By: dexonsmith

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

3 years ago[WIP][mlir] Resolve memref dependency in canonicalize pass.
Julian Gross [Fri, 7 May 2021 10:38:12 +0000 (12:38 +0200)]
[WIP][mlir] Resolve memref dependency in canonicalize pass.

Splitting the memref dialect lead to an introduction of several dependencies
to avoid compilation issues. The canonicalize pass also depends on the
memref dialect, but it shouldn't. This patch resolves the dependencies
and the unintuitive includes are removed. However, the dependency moves
to the constructor of the std dialect.

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

3 years ago[mlir][linalg] Remove template parameter from loop lowering.
Tobias Gysi [Mon, 17 May 2021 08:50:15 +0000 (08:50 +0000)]
[mlir][linalg] Remove template parameter from loop lowering.

Replace the templated linalgLowerOpToLoops method by three specialized methods linalgOpToLoops, LinalgOpToParallelLoops, and linalgOpToAffineLoops.

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

3 years ago[AArch64] Lower fpto*i.sat intrinsics.
Jacob Bramley [Tue, 27 Apr 2021 09:12:11 +0000 (10:12 +0100)]
[AArch64] Lower fpto*i.sat intrinsics.

AArch64's fctv* instructions implement the saturating behaviour that the
fpto*i.sat intrinsics require, in cases where the destination width
matches the saturation width. Lowering them removes a lot of unnecessary
generated code.

Only scalar lowerings are supported for now.

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

3 years ago[lldb] Let dotest check for the `cassert` header instead of `algorithm` for libc...
Raphael Isemann [Mon, 17 May 2021 09:02:36 +0000 (11:02 +0200)]
[lldb] Let dotest check for the `cassert` header instead of `algorithm` for libc++ check

This is just a dotest check to see if we can compile a simple program that uses
libc++. Right now we are parsing the rather big `algorithm` header in the test
program, but the test really just checks whether we can find *any* libc++
headers and link against some libc++ SO. Using the much smaller `cassert` header
for checking whether we can find libc++ headers speeds up this check by a bit.

After some incredibly unscientific performance testing this saves a few seconds
when running the test suite on Linux (on macOS we hardcoded that libc++ is
always there, so this check won't be used there and we don't save any time).

Reviewed By: jankratochvil

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

3 years ago[clangd] Set FileSystem for tweaks in Check tool.
Utkarsh Saxena [Fri, 14 May 2021 18:22:09 +0000 (20:22 +0200)]
[clangd] Set FileSystem for tweaks in Check tool.

Tweaks like DefineOutline depend on FS to be set at `apply()` time.
After https://reviews.llvm.org/D93978, tweaks run from Check tool lost
access to FS. This makes the available to apply() once again.

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

3 years ago[lldb][NFC] Specify guidelines for API tests
Raphael Isemann [Mon, 17 May 2021 08:32:45 +0000 (10:32 +0200)]
[lldb][NFC] Specify guidelines for API tests

This patch specifies a few guidelines that our API tests should follow.

The motivations for this are twofold:

1. API tests have unexpected pitfalls that especially new contributors run into
when writing tests. To prevent the frustration of letting people figure those
pitfalls out by trial-and-error, let's just document them briefly in one place.

2. It prevents some arguing about what is the right way to write tests. I really
like to have fast and reliable API test suite, but I also don't want to be the
bogeyman that has to insist in every review that the test should be rewritten to
not launch a process for no good reason. It's much easier to just point to a
policy document.

I omitted some guidelines that I think could be controversial (e.g., the whole
"should assert message describe failure or success").

Reviewed By: shafik

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

3 years ago[clang][modules] Build inferred modules
Michael Spencer [Mon, 17 May 2021 07:40:29 +0000 (09:40 +0200)]
[clang][modules] Build inferred modules

This patch enables explicitly building inferred modules.

Effectively a cherry-pick of https://github.com/apple/llvm-project/pull/699 authored by @Bigcheese with libclang and dependency scanner changes omitted.

Contains the following changes:

1. [Clang] Fix the header paths in clang::Module for inferred modules.
  * The UmbrellaAsWritten and NameAsWritten fields in clang::Module are a lie for framework modules. For those they actually are the path to the header or umbrella relative to the clang::Module::Directory.
  * The exception to this case is for inferred modules. Here it actually is the name as written, because we print out the module and read it back in when implicitly building modules. This causes a problem when explicitly building an inferred module, as we skip the printing out step.
  * In order to fix this issue this patch adds a new field for the path we want to use in getInputBufferForModule. It also makes NameAsWritten actually be the name written in the module map file (or that would be, in the case of an inferred module).

2. [Clang] Allow explicitly building an inferred module.
  * Building the actual module still fails, but make sure it fails for the right reason.

Split from D100934.

Reviewed By: dexonsmith

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

3 years agoRevert "[NFC][LSAN] Limit the number of concurrent threads is the test"
Florian Hahn [Mon, 17 May 2021 08:29:49 +0000 (09:29 +0100)]
Revert "[NFC][LSAN] Limit the number of concurrent threads is the test"

This reverts commit 2a73b7bd8cf7620fc0e478ac838b07ee6649dd8a.

This appears to be causing the following failures on GreenDragon:
  LeakSanitizer-AddressSanitizer-x86_64 :: TestCases/many_threads_detach.cpp
  LeakSanitizer-Standalone-x86_64 :: TestCases/many_threads_detach.cpp

First failure:
    http://green.lab.llvm.org/green/job/clang-stage1-RA/20754/

Still failing in latest build:
    http://green.lab.llvm.org/green/job/clang-stage1-RA/20928/

3 years ago[DAGCombiner] Relax an assertion to an early return
Fraser Cormack [Thu, 13 May 2021 11:18:36 +0000 (12:18 +0100)]
[DAGCombiner] Relax an assertion to an early return

The select-of-constants transform was asserting that its constant vector
inputs did not implicitly truncate their input without that as an
explicit precondition to the function. This patch relaxes that assertion
into an early return to skip the optimization.

Reviewed By: RKSimon

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

3 years ago[libcxx] NFC. Add missed articles to _LIPCPP_ASSERT messages in <list>
Kristina Bessonova [Sat, 15 May 2021 11:15:56 +0000 (13:15 +0200)]
[libcxx] NFC. Add missed articles to _LIPCPP_ASSERT messages in <list>

3 years ago[dexter] Remove requirement for a condition in DexLimitSteps
OCHyams [Mon, 17 May 2021 08:07:46 +0000 (09:07 +0100)]
[dexter] Remove requirement for a condition in DexLimitSteps

Currently the DexLimitSteps command requires at least one condition. This patch
lets users elide the condition to specify that the breakpoint range should
always be activated when the leading line is stepped on. This patch also
updates the terminology used in the `ConditionalController` class from the
terms 'conditional' and 'unconditional' to 'leading' and 'trailing' when
referring to the breakpoints in the DexLimitSteps range because the leading
breakpoint can now be unconditional.

Reviewed By: chrisjackson

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

3 years ago[dexter] Remove unnecessary double check on conditional breakpoints
OCHyams [Mon, 17 May 2021 07:57:43 +0000 (08:57 +0100)]
[dexter] Remove unnecessary double check on conditional breakpoints

Remove the `ConditionalController._conditional_met` method. This was missed in
the recent ConditionalController refactor (D98699). We don't need to check that
the conditions for a conditional breakpoint have been met because
`DebuggerBase.get_triggered_breakpoint_ids` returns the set of ids for
breakpoints which have been triggered.

To get the "triggered breakpoints" from lldb we use `GetStopReasonDataCount`
and `GetStopReasonDataAtIndex`. It seems that these functions count all
breakpoints associated with the location which lldb has stopped at, regardless
of their condition. i.e. Even if we have two breakpoints at the same source
location that have mutually exclusive conditions, both will be found this way
when either condition is true. To get around this, we store a map of breakpoint
{id: condition} `_breakpoint_conditions` and evaluate the conditions of the
triggered breakpoints to filter the set down to those which are unconditional
or have a condition which evaluates to true.

Essentially we are just moving the condition double check from a general
debugger controller into the lldb specific wrapper. This tidy up will help make
upcoming patches simpler.

Reviewed By: chrisjackson

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

3 years ago[LLD][MinGW] Add --fatal-warnings and --no-fatal-warnings flags
Mateusz Mikuła [Mon, 17 May 2021 07:39:59 +0000 (10:39 +0300)]
[LLD][MinGW] Add --fatal-warnings and --no-fatal-warnings flags

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