platform/upstream/llvm.git
2 years ago[CodeGen] Limit building time in CodeGenPrepare for huge function
Xiang1 Zhang [Tue, 30 Aug 2022 05:58:35 +0000 (13:58 +0800)]
[CodeGen] Limit building time in CodeGenPrepare for huge function

Details:

Currently CodeGenPrepare is very time consuming in handling big functions.

Old Algorithm :
It iterate each BB in function, and go on handle very instructions in BB.
Due to some instruction optimizations may affect the BBs' dominate tree.
The old logic will re-iterate and try optimize for each BB.

Suppose we have a big function with 20000 BBs, If we handled the last BB
with fine tuning the dominate tree. We need totally re-iterate and try optimize
the 20000 BBs from the beginning.

The Complex is near N!

And we really encounter somes big tests (> 20000 BBs) that cost more than 30
mins in this pass. (Debug version compiler will cost 2 hours here)

What this patch do for huge function ?
It mainly changes the iteration way for optimization.

1 We do optimizeBlock for each BB (that is same with old way).
And, in the meaning time, If BB is changed/updated in the optimization, it will
be put into FreshBBs (try do optimizeBlock again).
The new created BB at previous iteration will also put into FreshBBs.

2 For the BBs which not updated at previous iteration, we directly skip it.
Strictly speaking, here may miss some opportunity, but the probability is very
small.

3 For Instructions in single BB, we do optimizeInst for each instruction.
If optimizeInst change the instruction dominator in this BB, rather than break
and go back to optimize the first BB (the old way), we directly iterate
instructions (to do optimizeInst) in this updated BB again (the new way).

What this patch do for small/normal (not huge) function ?
It is same with the Old Algorithm. (NFC)

Reviewed By: LuoYuanke

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

2 years ago[test] Fix typo in setting the wrong Context test field
Jordan Rupprecht [Wed, 7 Sep 2022 01:59:03 +0000 (18:59 -0700)]
[test] Fix typo in setting the wrong Context test field

This manifests as an msan error because we check the value of `es`, but it's actually uninitialized because we mistakenly set `ss` twice.

2 years ago[CUDA] Actually fix the test correctly this time
Joseph Huber [Wed, 7 Sep 2022 01:31:27 +0000 (20:31 -0500)]
[CUDA] Actually fix the test correctly this time

2 years ago[CUDA] Fix test failing when using the new driver
Joseph Huber [Wed, 7 Sep 2022 01:14:20 +0000 (20:14 -0500)]
[CUDA] Fix test failing when using the new driver

Summary:
Previously the new driver crashed when using `-fsyntax-only` which
required a work-around in one of the test files. This was not properly
updated when it was fixed for the new driver. This patch fixes the test
and also adjusts a missing boolean check.

2 years ago[Clang] Fix the new driver crashing when using '-fsyntax-only'
Joseph Huber [Thu, 1 Sep 2022 22:04:49 +0000 (17:04 -0500)]
[Clang] Fix the new driver crashing when using '-fsyntax-only'

The new driver currently crashses when attempting to use the
'-fsyntax-only' option. This is because the option causes all output to
be given the `TY_Nothing' type which should signal the end of the
pipeline. The new driver was not treating this correctly and attempting
to use empty input. This patch fixes the handling so we do not attempt
to continue when the input is nothing.

One concession is that we must now check when generating the arguments
for Clang if the input is of 'TY_Nothing'. This is because the new
driver will only create code if the device code is a dependency on the
host, creating the output without the dependency would require a
complete rewrite of the logic as we do not maintain any state between
calls to 'BuildOffloadingActions' so I believe this is the most
straightforward method.

Reviewed By: tra

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

2 years ago[mlir][tosa] Support non-batch dynamic dims for tosa.rescale to linalg
natashaknk [Wed, 7 Sep 2022 00:13:12 +0000 (17:13 -0700)]
[mlir][tosa] Support non-batch dynamic dims for tosa.rescale to linalg

Reviewed By: rsuderman

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

2 years agoEnforce module decl-use restrictions and private header restrictions in textual headers
Richard Smith [Wed, 7 Sep 2022 00:10:55 +0000 (17:10 -0700)]
Enforce module decl-use restrictions and private header restrictions in textual headers

Per the documentation, these restrictions were intended to apply to textual headers but previously this didn't work because we decided there was no requesting module when the `#include` was in a textual header.

A `-cc1` flag is provided to restore the old behavior for transitionary purposes.

Reviewed By: aaron.ballman

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

2 years ago[HWASan] Show memory rather than tag addresses in tag dump
Florian Mayer [Tue, 6 Sep 2022 22:18:28 +0000 (15:18 -0700)]
[HWASan] Show memory rather than tag addresses in tag dump

Reviewed By: eugenis

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

2 years ago[test] Remove PowerPC/aix-xcoff-exported-nondefault.ll
Fangrui Song [Tue, 6 Sep 2022 23:48:16 +0000 (16:48 -0700)]
[test] Remove PowerPC/aix-xcoff-exported-nondefault.ll

This is not asserted by IR verifier.

2 years ago[RISCV] Use llvm::none_of to replace a loop. NFC
Craig Topper [Tue, 6 Sep 2022 23:03:45 +0000 (16:03 -0700)]
[RISCV] Use llvm::none_of to replace a loop. NFC

2 years ago[SimpleLoopUnswitch] Skip non-trivial unswitching of cold functions
Ruobing Han [Sun, 4 Sep 2022 16:56:25 +0000 (12:56 -0400)]
[SimpleLoopUnswitch] Skip non-trivial unswitching of cold functions

In the current main branch, all cold loops will not be applied non-trivial unswitch. As reported in D129599, skipping these cold loops will incur regression in SPEC benchmark.
Thus, instead of skipping cold loops, now only skipping loops in cold functions.

Reviewed By: alexgatea, aeubanks

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

2 years ago[mlir] Flip default value of emitAccessorPrefix to kEmitAccessorPrefix_Prefixed
River Riddle [Fri, 2 Sep 2022 02:31:31 +0000 (19:31 -0700)]
[mlir] Flip default value of emitAccessorPrefix to kEmitAccessorPrefix_Prefixed

Most dialects have already flipped to prefixed, and the intention to switch
has been telegraphed for a while.

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

2 years ago[test][hwasan] Update test for D132622
Vitaly Buka [Tue, 6 Sep 2022 22:42:13 +0000 (15:42 -0700)]
[test][hwasan] Update test for D132622

2 years ago[pipelines] OptimizerEarlyEPCallbacks for ThinLTO prelink
Vitaly Buka [Tue, 6 Sep 2022 03:31:43 +0000 (20:31 -0700)]
[pipelines] OptimizerEarlyEPCallbacks for ThinLTO prelink

Similar to OptimizerLastEPCallbacks workaround
added D96320.

Probably NFC as-is, I don't see anything hooked with this callbacks yet,
but I we are looking to move sanitizers.

Reviewed By: aeubanks, MaskRay

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

2 years ago[mlir][tosa] Fix dynamic shape inference in conv2d
Anastasia Stulova [Tue, 6 Sep 2022 22:07:29 +0000 (15:07 -0700)]
[mlir][tosa] Fix dynamic shape inference in conv2d

The comment in the code correctly states the equation for the shape inference as follows:

```
H = ((IH+pad_top+pad_bottom-(dilation_y*(KH-1)+1))/stride_y)+1
```

However the final operation is generated as `-` instead of `+`. I believe `+`
is indeed correct. For example if we have an image with dimension 6 and kernel
of dimension 3 (assuming padding is 0 and stride and dilation are both 1) we
are expecting 4 elements in the output (computed for image elements `(0, 1, 2)
x kernel`, `(1, 2, 3) x kernel`, `(2, 3, 4) x kernel` and `(3, 4, 5) x kernel`.
However currently only 2 elements are produced in the output.

Reviewed By: NatashaKnk

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

2 years ago[mlir][tensor] Fix a typo in the example code for UnrankedTensorType
Peiming Liu [Tue, 6 Sep 2022 22:25:41 +0000 (22:25 +0000)]
[mlir][tensor] Fix a typo in the example code for UnrankedTensorType

The syntax for unrank tensor type is defined as  tensor-type ::= `tensor` `<` `*` `x` type `>`, the example code missed the `x` in between.

Reviewed By: aartbik

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

2 years ago[Verifier] Allow dllexport protected after D133267
Fangrui Song [Tue, 6 Sep 2022 22:28:29 +0000 (15:28 -0700)]
[Verifier] Allow dllexport protected after D133267

I have noticed that this combo makes sense (D133266) but rejected it for
simplicity. It turns out to be used by PlayStation, so let's allow it.

2 years ago[NFC][asan] Rename ModuleAddressSanitizerPass
Vitaly Buka [Tue, 6 Sep 2022 05:37:45 +0000 (22:37 -0700)]
[NFC][asan] Rename ModuleAddressSanitizerPass

2 years ago[msan] Convert Msan to ModulePass
Vitaly Buka [Tue, 6 Sep 2022 04:28:02 +0000 (21:28 -0700)]
[msan] Convert Msan to ModulePass

MemorySanitizerPass function pass violatied requirement 4 of function
pass to do not insert globals. Msan nees to insert globals for origin
tracking, and paramereters tracking.

https://llvm.org/docs/WritingAnLLVMPass.html#the-functionpass-class

Reviewed By: kstoimenov, fmayer

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

2 years ago[mlir:vscode] Add support for loading big bytecode files
River Riddle [Sat, 3 Sep 2022 01:52:43 +0000 (18:52 -0700)]
[mlir:vscode] Add support for loading big bytecode files

VSCode doesn't let our extension manage files >50mb. This commit
adds a proper diagnostic in this case, and also gives the user an option
to open as a temporary .mlir file instead.

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

2 years ago[ThinLTOBitcodeWriter] Mark pass as required
Arthur Eubanks [Tue, 6 Sep 2022 21:35:14 +0000 (14:35 -0700)]
[ThinLTOBitcodeWriter] Mark pass as required

Or else with -opt-bisect-limit we don't write ThinLTO bitcode.

Reviewed By: asbirlea

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

2 years ago[RISCV] Add '32bit' feature to rv32 only builtins.
Craig Topper [Tue, 6 Sep 2022 21:45:17 +0000 (14:45 -0700)]
[RISCV] Add '32bit' feature to rv32 only builtins.

The backend now has a 32bit feature as part of the recent mtune
patch. We can now use that make our rv32-only builtin error checking
work the same way as rv64-only errors.

Reviewed By: kito-cheng

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

2 years ago[mlir] Allow passing AsmState when printing Attributes and Types
River Riddle [Sat, 3 Sep 2022 04:23:47 +0000 (21:23 -0700)]
[mlir] Allow passing AsmState when printing Attributes and Types

This allows for extracting assembly information when printing an attribute
or type, such as the dialect resources referenced. This functionality is used in
a followup that adds resource support to the bytecode. This change also results
in a nice cleanup of AsmPrinter now that we don't need to awkwardly workaround
optional AsmStates.

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

2 years ago[mlir] Improve BitEnumAttr, update documentation
Krzysztof Drewniak [Tue, 6 Sep 2022 20:25:20 +0000 (20:25 +0000)]
[mlir] Improve BitEnumAttr, update documentation

- Add new operators to BitEnumAttr, mainly not (which only inverts
bits that can be valid bits for the attribute) and xor
- Add new bit enum utility functions: bitEnumClear(bits, bit) and
bitEnumSet(bits, bit, value=true) as they've come up in code I've been
writing that makes use of such enums
- Add rudimentary tests for the enum generator
- Update the OpDefinition documentation to make it contain a correct
example and to have it account for the changes mentioned above.

Reviewed By: antiagainst

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

2 years ago[CostModel][X86] getIntrinsicInstrCost - convert to CostKindTblEntry
Simon Pilgrim [Tue, 6 Sep 2022 21:05:27 +0000 (22:05 +0100)]
[CostModel][X86] getIntrinsicInstrCost - convert to CostKindTblEntry

Begin the refactoring to use CostKindTblEntry and return real latency/codesize/sizelatency costs instead of reusing the throughput numbers

This should allow us to merge getTypeBasedIntrinsicInstrCost into getIntrinsicInstrCost and remove all remaining references

2 years ago[mlir][sparse] Add lowering rules for sparse_tensor.storage Op
Peiming Liu [Tue, 6 Sep 2022 18:13:55 +0000 (18:13 +0000)]
[mlir][sparse] Add lowering rules for sparse_tensor.storage Op

Reviewed By: aartbik

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

2 years ago[LLVM][Support/ADT] Add assert for isPresent to dyn_cast.
bzcheeseman [Fri, 2 Sep 2022 17:23:43 +0000 (10:23 -0700)]
[LLVM][Support/ADT] Add assert for isPresent to dyn_cast.

This change adds an assert to dyn_cast that the value passed-in is present. In the past, this relied on the isa_impl assertion (which still works in many cases) but which we can tighten up for a better QoI.

The PointerUnion change is because it seems like (based on the call sites) the semantics of the member dyn_cast are actually dyn_cast_if_present.

Reviewed By: rriddle

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

2 years ago[HWASan] rename left/right to before/after.
Florian Mayer [Wed, 24 Aug 2022 23:40:26 +0000 (16:40 -0700)]
[HWASan] rename left/right to before/after.

left/right is a weird way to refer to address ordering.

Reviewed By: eugenis, vitalybuka

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

2 years agoFix the Clang sphinx build bot; NFC
Aaron Ballman [Tue, 6 Sep 2022 20:47:40 +0000 (16:47 -0400)]
Fix the Clang sphinx build bot; NFC

This should address the failure introduced in:
https://lab.llvm.org/buildbot/#/builders/92/builds/32377

2 years ago[AMDGPU/Metadata] Rename HSAMD::MetadataStreamer classes
raghavmedicherla [Tue, 6 Sep 2022 20:41:00 +0000 (16:41 -0400)]
[AMDGPU/Metadata] Rename HSAMD::MetadataStreamer classes

Renamed all HSAMD::MetadataStreamer classes to improve readability of the code.

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

2 years agoSupport: Add mapped_file_region::sync(), equivalent to msync
raghavmedicherla [Tue, 6 Sep 2022 18:45:25 +0000 (14:45 -0400)]
Support: Add mapped_file_region::sync(), equivalent to msync

Add mapped_file_region::sync(), equivalent to POSIX msync,
synchronizing written content to disk without unmapping the region.
Asserts if the mode is not mapped_file_region::readwrite.

Note that I don't have access to a Windows machine, so I can't
easily run those unit tests.

Change by dexonsmith

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

2 years ago[test][libcxx] Mark ubsan test as UNSUPPORTED
Vitaly Buka [Tue, 6 Sep 2022 20:42:57 +0000 (13:42 -0700)]
[test][libcxx] Mark ubsan test as UNSUPPORTED

It inconsistently fails on bots.

2 years ago[ASan] Fix libfuzzer test
Florian Mayer [Tue, 6 Sep 2022 20:37:35 +0000 (13:37 -0700)]
[ASan] Fix libfuzzer test

2 years ago[docs][RISCV] Document status of Zicpo(m,p,z) extensions
Philip Reames [Tue, 6 Sep 2022 20:35:39 +0000 (13:35 -0700)]
[docs][RISCV] Document status of Zicpo(m,p,z) extensions

Unless I missed something when checking, we only support these in assembly. Given that, documenting them is a good opportunity to define support levels which will be useful for other extensions as well.

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

2 years ago[AArch64] Increase AddedComplexity of BIC
Alexander Shaposhnikov [Tue, 6 Sep 2022 20:28:17 +0000 (20:28 +0000)]
[AArch64] Increase AddedComplexity of BIC

This diff adjusts AddedComplexity of BIC to bump its position
in the list of patterns to make LLVM pick it instead of MVN + AND.
MVN + AND requires 2 cycles, so does e.g. MOV + BIC, but the latter
outperforms the former if the instructions producing the operands of
BIC can be issued in parallel.

One may consider the following example:

ldur x15, [x0, #2] # 4 cycles
mvn x10, x15 # 1 cycle (depends on ldur)
and x9, x10, #0x8080808080808080

vs.

ldur x15, [x0, #2] # 4 cycles
mov x9, #0x8080808080808080 # 1 cycle (can be executed in parallel with ldur)
bic x9, x9, x15. # 1 cycle

Test plan: ninja check-all

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

2 years ago[Libomptarget][NFC] Clean up CUDA plugin and address warnings
Joseph Huber [Tue, 6 Sep 2022 20:25:32 +0000 (15:25 -0500)]
[Libomptarget][NFC] Clean up CUDA plugin and address warnings

2 years ago[CostModel][X86] Fix check prefixes on cttz cost kinds tests
Simon Pilgrim [Tue, 6 Sep 2022 20:27:46 +0000 (21:27 +0100)]
[CostModel][X86] Fix check prefixes on cttz cost kinds tests

Add missing SSE2 + BMI/NOBMI coverage

2 years ago[ASan] rename left/right to before/after.
Florian Mayer [Wed, 24 Aug 2022 21:30:14 +0000 (14:30 -0700)]
[ASan] rename left/right to before/after.

left/right is a weird way to refer to address ordering.

Reviewed By: eugenis, MaskRay

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

2 years agoFix another place were we suggest lldb.target in a Frame Recognizer.
Jim Ingham [Tue, 6 Sep 2022 20:24:21 +0000 (13:24 -0700)]
Fix another place were we suggest lldb.target in a Frame Recognizer.

2 years agoYou can't use lldb.target in a frame recognizer.
Jim Ingham [Tue, 6 Sep 2022 20:20:03 +0000 (13:20 -0700)]
You can't use lldb.target in a frame recognizer.

2 years ago[clang-tidy] Skip union-like classes in use-equals-default
Alexander Shaposhnikov [Tue, 6 Sep 2022 20:19:47 +0000 (20:19 +0000)]
[clang-tidy] Skip union-like classes in use-equals-default

Skip unions/union-like classes since in this case constructors
with empty bodies behave differently in comparison with regular
structs/classes.

Test plan: ninja check-clang-tools

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

2 years ago[tsan] Replace mem intrinsics with calls to interceptors
Vitaly Buka [Sun, 4 Sep 2022 05:24:33 +0000 (22:24 -0700)]
[tsan] Replace mem intrinsics with calls to interceptors

After https://reviews.llvm.org/rG463aa814182a23 tsan replaces llvm
intrinsics with calls to glibc functions. However this approach is
fragile, as slight changes in pipeline can return llvm intrinsics back.
In particular InstCombine can do that.

Msan/Asan already declare own version of these memory
functions for the similar purpose.

KCSAN, or anything that uses something else than compiler-rt, needs to
implement this callbacks.

Reviewed By: melver

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

2 years ago[tsan][go] Fix buildgo.sh when GOAMD64 undefined
Vitaly Buka [Tue, 6 Sep 2022 20:00:57 +0000 (13:00 -0700)]
[tsan][go] Fix buildgo.sh when GOAMD64 undefined

2 years ago[mlir] Fix DenseElementsAttr::mapValues(i1, splat).
Chenguang Wang [Tue, 6 Sep 2022 19:28:23 +0000 (21:28 +0200)]
[mlir] Fix DenseElementsAttr::mapValues(i1, splat).

Splat of bool is encoded as a byte with all-ones in it [1]. Without this
change, this piece of code:

    auto xs = builder.getI32TensorAttr({42, 42, 42, 42});
    auto xs2 = xs.mapValues(builder.getI1Type(), [](const llvm::APInt &x) {
      return x.isZero() ? llvm::APInt::getZero(1) : llvm::APInt::getAllOnes(1);
    });
    xs2.dump();

Prints:

    dense<[true, false, false, false]> : tensor<4xi1>

Because only the first bit is set. This applies to both
DenseIntElementsAttr::mapValues() and DenseFPElementsAttr::mapValues().

[1]: https://github.com/llvm/llvm-project/blob/e877b42e2c70813352c1963ea33e992f481d5cba/mlir/lib/IR/BuiltinAttributes.cpp#L984

Reviewed By: rriddle

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

2 years ago[docs] Add a RISC-V Usage page
Philip Reames [Tue, 6 Sep 2022 19:06:53 +0000 (12:06 -0700)]
[docs] Add a RISC-V Usage page

This follows the pattern set by e.g. SPIR-V, AMDGPU, and WebAssembly.

For the moment, this page is fairly minimal stub. I mostly want a place to record which extensions we support, and when that support is not complete, a central place to note that. I'm deliberately starting with a subset of extensions which are pretty straight forward with only one case needing a detail note.

I figure the partial support cases are going to need a bunch of discussion, and having each of them in their own review seemed worthwhile. Similarly, the experimental extensions probably fall into the same bucket of triggering a bunch of review discussion.

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

2 years ago[DOC][Clang] Update cxx_status.html after the 15 release and fix a broken link in...
Roy Jacobson [Tue, 6 Sep 2022 18:59:27 +0000 (21:59 +0300)]
[DOC][Clang] Update cxx_status.html after the 15 release and fix a broken link in release notes

2 years ago[OpenMP] Fix logic error when building offloading applications
Joseph Huber [Tue, 6 Sep 2022 18:56:24 +0000 (13:56 -0500)]
[OpenMP] Fix logic error when building offloading applications

Summary:
A previous patch removed support for the `-fopenmp-new-driver` and
accidentally used the `isHostOffloading` flag instead of
`isDeviceOffloading` which lead to some build errors when compiling for
the offloading device. This patch addresses that.

2 years ago[OpenMP] Remove use of removed '-f[no-]openmp-new-driver' flag
Joseph Huber [Tue, 6 Sep 2022 17:51:43 +0000 (12:51 -0500)]
[OpenMP] Remove use of removed '-f[no-]openmp-new-driver' flag

The changes in D130020 removed all support for the old method of
compiling OpenMP offloading programs. This means that
`-fopenmp-new-driver` has no effect and `-fno-openmp-new-driver` does
not work. This patch removes the use and documentation of this flag.
Note that the `--offload-new-driver` flag still exists for using the new
driver optionally with CUDA and HIP.

Reviewed By: tra

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

2 years ago[MC] Emit Stackmaps before debug info
Markus Böck [Tue, 6 Sep 2022 18:20:40 +0000 (20:20 +0200)]
[MC] Emit Stackmaps before debug info

This patch is essentially an alternative to https://reviews.llvm.org/D75836 and was mentioned by @lhames in a comment.

The gist of the issue is that Mach-O has restrictions on which kind of sections are allowed after debug info has been emitted, which is also properly asserted within LLVM. Problem is that stack maps are currently emitted as one of the last sections in each target-specific AsmPrinter so far, which would cause the assertion to trigger. The current approach of special casing for the `__LLVM_STACKMAPS` section is not viable either, as downstream users can overwrite the stackmap format using plugins, which may want to use different sections.

This patch fixes the issue by emitting the stack map earlier, right before debug info is emitted. The way this is implemented is by taking the choice when to emit the StackMap away from the target AsmPrinter and doing so in the base class. The only disadvantage of this approach is that the `StackMaps` member is now part of the base class, even for targets that do not support them. This is functionaly not a problem however, as emitting an empty `StackMaps` is a no-op.

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

2 years ago[OpenMP] Fix `omp_get_wtime` function being marked incorrectly as readonly
Joseph Huber [Tue, 6 Sep 2022 15:22:25 +0000 (10:22 -0500)]
[OpenMP] Fix `omp_get_wtime` function being marked incorrectly as readonly

OpenMP has a list of of optimistic attributes that can be attached to
known runtime functions to aid some analysis. The `omp_get_wtime`
function incorrectly used the `readonly` attribute. This is not correct
at the `omp_get_wtime` function changes values depending on some
external state. This is more correctly modeled with
`inaccessiblememonly` meaning that the value does not depend on anything
within the module, but can not be removes as it depends on external
state.

Fixes #57578

Reviewed By: tianshilei1992

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

2 years ago[ADT] Remove is_splat
Jakub Kuderski [Tue, 6 Sep 2022 17:48:47 +0000 (13:48 -0400)]
[ADT] Remove is_splat

`is_splat` is superseded by `all_equal` and marked as deprecated.
See the discussion thread for more details:
https://discourse.llvm.org/t/adt-is-splat-and-empty-ranges/64692

Reviewed By: dblaikie

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

2 years ago[lldb] Fix CommunicationKDP following D133251
Dave Lee [Tue, 6 Sep 2022 17:20:27 +0000 (10:20 -0700)]
[lldb] Fix CommunicationKDP following D133251

Add `m_bytes` and `m_bytes_mutex` to `CommunicationKDP`, following refactoring
in D133251.

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

2 years ago[mlir] Make bit enum operators constexpr
Krzysztof Drewniak [Thu, 1 Sep 2022 21:46:54 +0000 (21:46 +0000)]
[mlir] Make bit enum operators constexpr

This allows using the | operator on the values of enum attributes
in complie-time constants.

Reviewed By: antiagainst

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

2 years ago[mlir][spirv] Change vendor op mnemonics to `spv.VENDOR.name`
Jakub Kuderski [Tue, 6 Sep 2022 17:12:24 +0000 (13:12 -0400)]
[mlir][spirv] Change vendor op mnemonics to `spv.VENDOR.name`

Make vendor ops more consistent with the naming scheme within the SPIR-V
dialect.

Issue: https://github.com/llvm/llvm-project/issues/56863

Reviewed By: antiagainst

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

2 years ago[mlir][spirv] Refactor vendor op definitions
Jakub Kuderski [Fri, 2 Sep 2022 18:59:42 +0000 (14:59 -0400)]
[mlir][spirv] Refactor vendor op definitions

Use dedicated vendor op classes/categories. This is so that we can later
change the mnemonics of all vendor ops by changing the base class: `SPV_VendorOp`.

Issue: https://github.com/llvm/llvm-project/issues/56863

2 years ago[mlir][spirv] Add base classes for vendor ops
Jakub Kuderski [Fri, 2 Sep 2022 18:15:51 +0000 (14:15 -0400)]
[mlir][spirv] Add base classes for vendor ops

This is the first patch in the series to rename vendor ops from
`spv.NameVENDOR` to `spv.VENDOR.Name`. The goal is to make the SPIR-V
dialect more internally consistent.

Issue: https://github.com/llvm/llvm-project/issues/56863

2 years ago[clang] Implement setting crash_diagnostics_dir through env variable
Matheus Izvekov [Thu, 1 Sep 2022 02:17:06 +0000 (04:17 +0200)]
[clang] Implement setting crash_diagnostics_dir through env variable

This implements setting the equivalent of `-fcrash-diagnostics-dir`
through the environment variable `CLANG_CRASH_DIAGNOSTICS_DIR`.
If present, the flag still takes precedence.

This helps integration with test frameworks and pipelines.

With this feature, we change the libcxx bootstrapping build
pipeline to produce clang crash reproducers as artifacts.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D133082

2 years agoRevert "[SCCP] convert signed div/rem to unsigned for non-negative operands"
Florian Hahn [Tue, 6 Sep 2022 17:20:16 +0000 (18:20 +0100)]
Revert "[SCCP] convert signed div/rem to unsigned for non-negative operands"

This reverts commit fe1f3cfc2669aca387a45c8ce615b45c1db50fc6.

It looks like this commit breaks building llvm-test-suite.

To reproduce, run `opt -passes=ipsccp` on the IR below.

    @g = internal global i32 256, align 4

    define void @test() {
    entry:
      %0 = load i32, ptr @g, align 4
      %div = sdiv i32 %0, undef
      ret void
    }

2 years ago[AArch64] Add an option to reserve physical registers from RA
Guozhi Wei [Tue, 6 Sep 2022 17:18:01 +0000 (17:18 +0000)]
[AArch64] Add an option to reserve physical registers from RA

This patch adds an option --reserve-regs-for-regalloc, so we can reserve a list
of physical registers. These registers will not be used by register allocator,
but can still be used as ABI requests such as passing arguments to function
call.

Its main purpose is simulating high register pressure by reserving many physical
registers. So it will be much easier to test and debug register allocation
changes.

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

2 years ago[libc++] Avoid instantiating type_trait classes
Nikolas Klauser [Mon, 5 Sep 2022 22:33:34 +0000 (00:33 +0200)]
[libc++] Avoid instantiating type_trait classes

Use `using` aliases to avoid instantiating lots of types

Reviewed By: ldionne, #libc

Spies: libcxx-commits, miyuki

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

2 years ago[ConstraintElimination] Replace pair with named struct (NFC).
Florian Hahn [Tue, 6 Sep 2022 17:03:37 +0000 (18:03 +0100)]
[ConstraintElimination] Replace pair with named struct (NFC).

This slightly improves the readability and allows further extensions in
follow-ups.

2 years ago[mlir][sparse] Refactoring: renaming StorageNewOp to StorageOp
Peiming Liu [Tue, 6 Sep 2022 16:57:09 +0000 (16:57 +0000)]
[mlir][sparse] Refactoring: renaming StorageNewOp to StorageOp

To address comment in https://reviews.llvm.org/D133241

Reviewed By: aartbik

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

2 years agoRevert "[tsan] Replace mem intrinsics with calls to interceptors"
Vitaly Buka [Tue, 6 Sep 2022 16:46:46 +0000 (09:46 -0700)]
Revert "[tsan] Replace mem intrinsics with calls to interceptors"

Breaks
http://45.33.8.238/macm1/43944/step_4.txt
https://lab.llvm.org/buildbot/#/builders/70/builds/26926

This reverts commit 77654a65a373da9c4829de821e7b393ea811ee40.

2 years ago[mlir][sparse] codegen for sparse alloc
Aart Bik [Sat, 3 Sep 2022 00:54:17 +0000 (17:54 -0700)]
[mlir][sparse] codegen for sparse alloc

Reviewed By: Peiming

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

2 years ago[RISCV] Improve vector fround lowering by changing FRM.
Craig Topper [Tue, 6 Sep 2022 16:33:13 +0000 (09:33 -0700)]
[RISCV] Improve vector fround lowering by changing FRM.

This is a follow up to D133238 which did this for ceil/floor.

Reviewed By: arcbbb, frasercrmck

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

2 years ago[clang] fix profiling of template arguments of template and declaration kind
Matheus Izvekov [Wed, 31 Aug 2022 23:44:38 +0000 (01:44 +0200)]
[clang] fix profiling of template arguments of template and declaration kind

Template arguments of template and declaration kind were being profiled
only by their canonical properties, which would cause incorrect
uniquing of constrained AutoTypes, leading to a crash in some cases.

This exposed some places in CheckTemplateArgumentList where non-canonical
arguments where being pushed into the resulting converted list.

We also throw in some asserts to catch early and explain the crashes.

Note that the fix for the 'declaration' kind is untestable at this point,
because there should be no cases right now in the AST where we try
to unique a non-canonical converted template argument.

This fixes GH55567.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D133072

2 years ago[CostModel][X86] Add CostKinds handling for ctpop ops
Simon Pilgrim [Tue, 6 Sep 2022 16:27:15 +0000 (17:27 +0100)]
[CostModel][X86] Add CostKinds handling for ctpop ops

This was achieved with an updated version of the 'cost-tables vs llvm-mca' script D103695 (although it still struggles with avx512 predicate numbers which had to be done manually)

Some of the pre-AVX values still aren't great - atom/slm worst case numbers for ctpop expansion really affect these (especially throughput/latency), so we need to clean them up in a more consistent way - its a pity we don't have models for more older cpus (merom/nehalem etc.) as other examples.

2 years agoAdd docs for Mach-O lld
Michael Eisel [Tue, 6 Sep 2022 16:18:23 +0000 (12:18 -0400)]
Add docs for Mach-O lld

I wasn't able to find any docs for Mach-O in `lld/docs`, so here's an attempt at adding basic docs. One of my goals here is to make it easy for users who are unfamiliar with linkers to successfully use lld.

Reviewed By: #lld-macho, int3

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

2 years ago[InstCombine] remove dead code for add (select cond, (sub), 0); NFC
Sanjay Patel [Tue, 6 Sep 2022 15:55:53 +0000 (11:55 -0400)]
[InstCombine] remove dead code for add (select cond, (sub), 0); NFC

This pattern is handled more generally in SimplifySelectsFeedingBinaryOp().
Tests to confirm that added to the add.ll test file in the previous commit.

2 years ago[InstCombine] add/move tests for add with select operands that simplify; NFC
Sanjay Patel [Tue, 6 Sep 2022 15:54:16 +0000 (11:54 -0400)]
[InstCombine] add/move tests for add with select operands that simplify; NFC

2 years ago[InstCombine] add tests for add of select with 0 and negate arms; NFC
Sanjay Patel [Tue, 6 Sep 2022 14:19:18 +0000 (10:19 -0400)]
[InstCombine] add tests for add of select with 0 and negate arms; NFC

2 years agoFix OpenMP Opt for target without a parallel region.
Doru Bercea [Thu, 1 Sep 2022 16:04:21 +0000 (16:04 +0000)]
Fix OpenMP Opt for target without a parallel region.

Remove ctx redeclaration.

Format code.

Remove parallel check. Modify tests. Clean-up code.

Fix another test.

Move code to helper functions.

Format file.

Minor fixes.

2 years agoRevert "[lldb][bindings] Fix module_access handling of regex"
Stella Stamenova [Tue, 6 Sep 2022 15:57:28 +0000 (08:57 -0700)]
Revert "[lldb][bindings] Fix module_access handling of regex"

This reverts commit 75f05fccbbdd91393bdc7b6183b9dd2b1e859f8e.

This commit broke the windows lldb bot: https://lab.llvm.org/buildbot/#/builders/83/builds/23284

2 years ago[bazel] port 5dbc7cf7cac44
Benjamin Kramer [Tue, 6 Sep 2022 15:42:51 +0000 (17:42 +0200)]
[bazel] port 5dbc7cf7cac44

2 years ago[gn build] port 5dbc7cf7cac44
Nico Weber [Tue, 6 Sep 2022 15:39:02 +0000 (11:39 -0400)]
[gn build] port 5dbc7cf7cac44

2 years agoFix remaining test failures for "[llvm/CodeGen] Enable the ExpandLargeDivRem pass...
Matthias Gehre [Tue, 6 Sep 2022 15:32:29 +0000 (16:32 +0100)]
Fix remaining test failures for "[llvm/CodeGen] Enable the ExpandLargeDivRem pass for X86, Arm and AArch64"

2 years ago[tsan] Replace mem intrinsics with calls to interceptors
Vitaly Buka [Sun, 4 Sep 2022 05:24:33 +0000 (22:24 -0700)]
[tsan] Replace mem intrinsics with calls to interceptors

After https://reviews.llvm.org/rG463aa814182a23 tsan replaces llvm
intrinsics with calls to glibc functions. However this approach is
fragile, as slight changes in pipeline can return llvm intrinsics back.
In particular InstCombine can do that.

Msan/Asan already declare own version of these memory
functions for the similar purpose.

KCSAN, or anything that uses something else than compiler-rt, needs to
implement this callbacks.

Reviewed By: melver

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

2 years agoFix AMDGPU test failures due to "[llvm/CodeGen] Enable the ExpandLargeDivRem pass...
Matthias Gehre [Tue, 6 Sep 2022 15:18:14 +0000 (16:18 +0100)]
Fix AMDGPU test failures due to "[llvm/CodeGen] Enable the ExpandLargeDivRem pass for X86, Arm and AArch64"

2 years agoFix "[llvm/CodeGen] Enable the ExpandLargeDivRem pass for X86, Arm and AArch64" compi...
Matthias Gehre [Tue, 6 Sep 2022 14:55:28 +0000 (15:55 +0100)]
Fix "[llvm/CodeGen] Enable the ExpandLargeDivRem pass for X86, Arm and AArch64" compilation on Windows

2 years ago[AArch64] Additional tests for sinking splats to muls. NFC
David Green [Tue, 6 Sep 2022 15:04:28 +0000 (16:04 +0100)]
[AArch64] Additional tests for sinking splats to muls. NFC

2 years agoAdd parantheses to silence warning.
Amara Emerson [Tue, 6 Sep 2022 14:17:40 +0000 (15:17 +0100)]
Add parantheses to silence warning.

2 years ago[SelectionDAG] Properly copy ExtraInfo on RAUW
Marco Elver [Tue, 6 Sep 2022 13:48:58 +0000 (15:48 +0200)]
[SelectionDAG] Properly copy ExtraInfo on RAUW

During SelectionDAG legalization SDNodes with associated extra info may
be replaced with a new SDNode. Preserve associated extra info on
ReplaceAllUsesWith and remove entries in DeallocateNode.

Reviewed By: vitalybuka

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

2 years ago[SelectionDAG] Rename CallSiteDbgInfo to NodeExtraInfo
Marco Elver [Tue, 6 Sep 2022 13:48:52 +0000 (15:48 +0200)]
[SelectionDAG] Rename CallSiteDbgInfo to NodeExtraInfo

For information infrequently attached to SDNodes, it is useful to
provide a way to add this information out-of-line. This is already done
for call-site specific information.

Rename CallSiteDbgInfo to NodeExtraInfo in preparation of adding
additional information not necessarily related to call sites only.

Reviewed By: vitalybuka

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

2 years ago[llvm/CodeGen] Enable the ExpandLargeDivRem pass for X86, Arm and AArch64
Matthias Gehre [Tue, 19 Jul 2022 10:28:54 +0000 (11:28 +0100)]
[llvm/CodeGen] Enable the ExpandLargeDivRem pass for X86, Arm and AArch64

This adds the ExpandLargeDivRem to the default pass pipeline.
The limit at which it expands div/rem instructions is configured
via a new TargetTransformInfo hook (default: no expansion)
X86, Arm and AArch64 backends implement this hook to expand div/rem
instructions with more than 128 bits.

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

2 years ago[OffloadPackager] Add ability to extract images from other file types
Joseph Huber [Wed, 24 Aug 2022 21:12:06 +0000 (16:12 -0500)]
[OffloadPackager] Add ability to extract images from other file types

A previous patch added support for extracting images from offloading
binaries. Users may wish to extract these files from the file types they
are most commonly emebedded in, such as an ELF or bitcode. This can be
difficult for the user to do manually, as these could be stored in
different section names potentially. This patch addsp support for
extracting these file types.

Reviewed By: saiislam

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

2 years ago[Object] Refactor code for extracting offload binaries
Joseph Huber [Thu, 25 Aug 2022 17:58:55 +0000 (12:58 -0500)]
[Object] Refactor code for extracting offload binaries

We currently extract offload binaries inside of the linker wrapper.
Other tools may wish to do the same extraction operation. This patch
simply factors out this handling into the `OffloadBinary.h` interface.

Reviewed By: yaxunl

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

2 years ago[MachineInstr] Allow setting PCSections in ExtraInfo
Marco Elver [Tue, 6 Sep 2022 13:48:41 +0000 (15:48 +0200)]
[MachineInstr] Allow setting PCSections in ExtraInfo

Provide MachineInstr::setPCSection(), to propagate relevant metadata
through the backend. Use ExtraInfo to store the metadata.

Reviewed By: vitalybuka

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

2 years ago[Metadata] Introduce MD_pcsections
Marco Elver [Tue, 6 Sep 2022 13:48:23 +0000 (15:48 +0200)]
[Metadata] Introduce MD_pcsections

Introduces MD_pcsections metadata kind. See added documentation for
more details.

Subsequent patches enable propagating PC sections metadata through code
generation to the AsmPrinter.

RFC: https://discourse.llvm.org/t/rfc-pc-keyed-metadata-at-runtime/64191

Reviewed By: dvyukov, vitalybuka

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

2 years agoFix Clang Sphinx docs build
Aaron Ballman [Tue, 6 Sep 2022 13:50:47 +0000 (09:50 -0400)]
Fix Clang Sphinx docs build

The CodeOwners.rst file needs to live in the same directory as the rest
of the documentation. This copies the file to the correct place when
making a Sphinx build but continues to leave the .rst file at the root
directory where it's easier for developers to find. This also ensures
that local doc builds using `make html` work as expected.

2 years ago[CostModel][X86] Add CostKinds test coverage for ctlz intrinsics
Simon Pilgrim [Tue, 6 Sep 2022 13:39:15 +0000 (14:39 +0100)]
[CostModel][X86] Add CostKinds test coverage for ctlz intrinsics

2 years ago[CostModel][X86] Add CostKinds test coverage for cttz intrinsics
Simon Pilgrim [Tue, 6 Sep 2022 13:20:58 +0000 (14:20 +0100)]
[CostModel][X86] Add CostKinds test coverage for cttz intrinsics

2 years ago[CostModel][X86] Add CostKinds test coverage for ctpop intrinsics
Simon Pilgrim [Tue, 6 Sep 2022 13:13:25 +0000 (14:13 +0100)]
[CostModel][X86] Add CostKinds test coverage for ctpop intrinsics

2 years ago[SCCP] convert signed div/rem to unsigned for non-negative operands
Sanjay Patel [Tue, 6 Sep 2022 12:56:57 +0000 (08:56 -0400)]
[SCCP] convert signed div/rem to unsigned for non-negative operands

This extends the transform added with D81756 to handle div/rem opcodes.
For example:
https://alive2.llvm.org/ce/z/cX6za6

This replicates part of what CVP already does, but the motivating example
from issue #57472 demonstrates a phase ordering problem - we convert
branches to select before CVP runs and miss the transform.

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

2 years ago[flang] Accept assumed shape arrays as SHAPE in C_F_POINTER
Jean Perier [Tue, 6 Sep 2022 12:42:28 +0000 (14:42 +0200)]
[flang] Accept assumed shape arrays as SHAPE in C_F_POINTER

C_F_POINTER was added in https://reviews.llvm.org/D132303, but the code
assumed that SHAPE would always be an explicit shape with compile time
constant rank. It can actually be an assumed shape, or an explicit shape
with non compile time constant rank. Get the rank from FPTR pointer
instead.

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

2 years ago[GlobalISel] Combine G_INSERT/EXTRACT_VECTOR_ELT with out of bounds indices to undef.
Amara Emerson [Mon, 5 Sep 2022 15:10:59 +0000 (16:10 +0100)]
[GlobalISel] Combine G_INSERT/EXTRACT_VECTOR_ELT with out of bounds indices to undef.

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

2 years agoUpdate the clang and clang-tools-extra code owners files
Aaron Ballman [Tue, 6 Sep 2022 12:28:03 +0000 (08:28 -0400)]
Update the clang and clang-tools-extra code owners files

This also converts the Clang code owners file from a flat text file to
an RST file that is linked in to the rest of our documentation.

The RFC for this can be found at:
https://discourse.llvm.org/t/rfc-proposed-changes-to-clangs-code-ownership/

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

2 years ago[InstSimplify] allow poison/undef in constant match for "C - X ==/!= X -> false/true"
Sanjay Patel [Tue, 6 Sep 2022 12:07:31 +0000 (08:07 -0400)]
[InstSimplify] allow poison/undef in constant match for "C - X ==/!= X -> false/true"

This fold was added with 5e9522c311dd, but over-specified.
We can assume that an undef element is an odd number:
https://alive2.llvm.org/ce/z/djQmWU

2 years ago[InstCombine] reduce code duplication; NFC
Sanjay Patel [Mon, 5 Sep 2022 14:47:38 +0000 (10:47 -0400)]
[InstCombine] reduce code duplication; NFC

2 years ago[InstCombine] add tests for icmp-of-trunc; NFC
Sanjay Patel [Mon, 5 Sep 2022 14:41:56 +0000 (10:41 -0400)]
[InstCombine] add tests for icmp-of-trunc; NFC

2 years ago[OpenMP] Add lit test for metadirective device arch inspired
Animesh Kumar [Tue, 6 Sep 2022 07:52:55 +0000 (02:52 -0500)]
[OpenMP] Add lit test for metadirective device arch inspired
from sollve

This lit test is added based upon the tests present in the
tests/5.0/metadirective directory of the SOLLVE repo
https://github.com/SOLLVE/sollve_vv

Reviewed By: saiislam

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