447930 Commits

Author SHA1 Message Date
Alexander Yermolovich
fa3fa4d0d4 [llvm][dwwarf] Change CU/TU index to 64-bit
Changed contribution data structure to 64 bit. I added the 32bit and 64bit
accessors to make it explicit where we use 32bit and where we use 64bit. Also to
make sure sure we catch all the cases where this data structure is used.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D139379
2023-01-10 10:33:52 -08:00
Peter Ammon
35acc32b3e tsan: fix a race when assigning ThreadSignalContext
The SigCtx function lazily allocates a ThreadSignalContext, and stores it
in the ThreadState. This function may be called by various interceptors and
the signal handler itself.

If SigCtx itself is interrupted by a signal, then (prior to this fix) there
was a possibility of allocating two ThreadSignalContexts. This not only
leaks, it fails to deliver the signal to the program's signal handler, as
the recorded signal is overwritten by the new ThreadSignalContext.

Fix this by using a CAS to swap in the ThreadSignalContext, preventing the
race. Add a test for this case.

Reviewed By: dvyukov, melver

Differential Revision: https://reviews.llvm.org/D140582
2023-01-10 19:32:28 +01:00
Mitch Phillips
dcf23e1361 [GWP-ASan] Fix up bad report for in-page underflow w/ UaF
Complex scenario, but reports when there's both a use-after-free and
buffer-underflow that is in-page (i.e. doesn't touch the guard page)
ended up generating a pretty bad report:

'Use After Free at 0x7ff392e88fef (18446744073709551615 bytes into a
1-byte allocation at 0x7ff392e88ff0) by thread 3836722 here:'

(note the 2^64-bytes-into-alloc, very cool and good!)

Fix up that case, and add a diagnostic about when you have both a
use-after-free and a buffer-overflow that it's probably a bogus report
(assuming the developer didn't *really* screw up and have a uaf+overflow
bug at the same time).

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D139885
2023-01-10 10:29:49 -08:00
Mitch Phillips
296f7fbbb5 [GWP-ASan] Fix atfork handlers being installed multiple times in tests
We incorrectly install the atfork handlers multiple times in the test
harness, tracked down to the default parameter used by
CheckLateInitIsOK. This manifested in a hang if running the tests with
--gtest_repeat={>=2} as the atfork handler ran multiple times, causing
double-lock and double-unlock, which on my machine hung.

Add a check-fail for this case as well to prevent this from happening
again (it was difficult to track down and is an easy mistake to make).

Differential Revision: https://reviews.llvm.org/D139731
2023-01-10 10:16:08 -08:00
Valery N Dmitriev
fd7273359a [SLP] Do not ignore ordering for root node when it has in-tree uses.
When rooted with PHIs, a vectorization tree may have another node with PHIs
which have roots as their operands. We cannot ignore ordering information
for root in such a case.

Differential Revision: https://reviews.llvm.org/D141309
2023-01-10 10:12:51 -08:00
Philip Reames
c4ce1e0131 [RISCV] Avoid emitting hardware fences for singlethread fences
singlethread fences only synchronize with code running on the same hardware thread (i.e. signal handlers). Because of this, we need to prevent instruction reordering, but do not need to emit hardware fence instructions.

The implementation strategy here matches many other backends. The main motivation of this patch is to introduce the MEMBARRIER node and get some test coverage for it.

Differential Revision: https://reviews.llvm.org/D141311
2023-01-10 10:09:59 -08:00
Matt Arsenault
d8534e4e98 AMDGPU: Don't insert ptrtoint for printf lowering 2023-01-10 13:07:01 -05:00
Matt Arsenault
777b905bae AMDGPU: Stop trying to specially handle vector stores in printf lowering
This was broken for 1 element vectors and trying to create invalid
casts. We can directly store any type just fine, so don't bother with
this buggy conversion logic.
2023-01-10 13:07:01 -05:00
Matt Arsenault
2e9c663ab4 clang/AMDGPU: Add missing tests for some builtin
These were tested under opencl but need hip testing for the potential
addrspacecasts.
2023-01-10 13:07:01 -05:00
Matt Arsenault
a200fa04a3 AMDGPU: Move intrinsic definition point
This was incorrectly listed under the block for backend internal
intrinsics only.
2023-01-10 13:07:01 -05:00
Matt Arsenault
3fe1e95207 AMDGPU: Set some more attributes on intrinsics 2023-01-10 13:07:00 -05:00
Heejin Ahn
d198c75e5a [WebAssembly][LiveDebugValues] Handle target index defs
This adds the missing handling for defs for target index operands, as is
already done for registers.

There are two kinds of target indices: local indices and stack operands.

- Locals are something similar to registers in Wasm-land. For local
  indices, we can check for local-defining instructions (`local.set` or
  `local.tee`).

- Wasm is a stack machine, so we have values in certain Wasm value stack
  location, which change when Wasm instructions produce or consume
  values. So basically any value-producing instrucion, i.e., instruction
  with defs, can change values in the Wasm stack. But I think we don't
  need to worry about this here, because `WebAssemblyDebugFixup`, which
  runs right before this analysis, makes sure to insert terminating
  `DBG_VALUE $noreg` instructions whenever a stack value gets popped.
  After `WebAssemblyDebugFixup`, there shouldn't be any `DBG_VALUE`s for
  stack operands that don't have a terminating `DBG_VALUE $noreg` within
  the same BB.

So this CL only works on `DBG_VALUE`s for locals. When we encounter a
`local.set` or `local.tee` instructions, we delete `DBG_VALUE`s for
those target index locations from the open range set, so they will not
be availble in `OutLocs`. For example,
```
bb.0:
  successors: %bb.1
  DBG_VALUE target-index(wasm-local) + 2, $noreg, "var", ...
  ...
  local.set 2 ...

bb.1:
; predecessors: %bb.0
  ; We shouldn't add `DBG_VALUE target (wasm-local) + 2 here because
  ; it was killed by 'local.set' in bb.0
```

After disabling register coalescing at -O1, the average PC ranges
covered for Emscripten core benchmarks is currently 20.6% in the LLVM
tot. After applying D138943 and this CL, the coverage goes up to 57%.
This also enables LiveDebugValues analysis in the Wasm pipeline by
default.

Reviewed By: dschuff, jmorse

Differential Revision: https://reviews.llvm.org/D140373
2023-01-10 09:56:25 -08:00
Heejin Ahn
e9ea7a0e20 [WebAssembly] Use LiveDebugValues analysis
This enables `LiveDebugValues` analysis for Wasm. `DBG_VALUE`s expire at
the end of a BB, and this is the analysis extends their lifetime when
possible, greatly increasing the coverage of variable debug info.

Specifically, this removes the current constraint that this analysis is
only used with physical registers, which was first introduced in D18421,
because Wasm uses only virtual registers. I don't think there's anything
inherent in this analysis that only applies to physical registers; it
was just because all targets using this analysis ran this at the end of
their compiliation pipeline, at which point all their vregs had been
allocated, and Wasm's debug info infrastructure was not really set up
yet, so it was not using it.

This adds supports to Wasm-specific target-index operands, defined in
2166d9529a/llvm/lib/Target/WebAssembly/WebAssembly.h (L87-L100).
Among these, `TI_LOCAL`, `TI_LOCAL_INDIRECT`, and `TI_OPERAND_STACK` are
used by Wasm `DBG_VALUE` instructions.

This does not yet handle mutable target indices, i.e., this does not
terminate a `DBG_VALUE` for a local index when we encounter a new
`local.set` or `local.tee`. It will be implemented as a follow-up.

Reviewed By: dschuff, jmorse

Differential Revision: https://reviews.llvm.org/D138943
2023-01-10 09:54:59 -08:00
Mark de Wever
bc21af6a43 [NFC][libc++][test] Improves code reuse.
This applies D140115 to the new tuple tests.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D140650
2023-01-10 18:49:58 +01:00
Chris Cotter
9fff1ddb56 [NFC] [clang-tools-extra] Alphabetize clang-tidy release notes
Alphabetize order of clang-tidy release notes, and fix `:doc:` link.

Reviewed By: Eugene.Zelenko

Differential Revision: https://reviews.llvm.org/D141391
2023-01-10 17:37:19 +00:00
Kirill Stoimenov
af12f726a0 [HWASAN] Added empty WordIsPoisoned for LSAN support.
Currently it is just an empty implementation to allow the project to link.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D141147
2023-01-10 17:36:31 +00:00
esmeyi
db5b7b3fe2 [XCOFF] Fix the offset error of dwarf sections caused by D137819. 2023-01-10 12:32:13 -05:00
chenglin.bi
be7d0d6db5 [DAGCombiner] Fix issue with rot chain pattern
faa35fc87370 fix the case of negative input shift. But when `c1`, `c2` is not the same side, it will also cause negative shift amount.
And that negative shift amount can't normalize by urem. So add one more bit size to normalize the last shift amount.

Fix: https://github.com/llvm/llvm-project/issues/59898

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D141363
2023-01-11 01:29:09 +08:00
chenglin.bi
b84ab1f7c9 Revert "[LSR] Hoist IVInc to loop header if its all uses are in the loop header"
The original commit seems to cause a regression in numba test.
This reverts commit b1b4758e7f4b2ffe1faa28b00eb037832e5d26a7.
2023-01-11 01:24:34 +08:00
serge-sans-paille
36117cc463
[llvm] Declare llvm::makeArrayRef as obsolete
Also cleans up a few remaining references.

This is the final commit for the series started by
https://reviews.llvm.org/D140896
2023-01-10 18:19:58 +01:00
Alex Brachet
b1372fe7b0 [libc] Fix -Wimplicit-int-conversion warnings
Differential Revision: https://reviews.llvm.org/D140492
2023-01-10 16:41:28 +00:00
Tobias Gysi
3589885d82 [mlir][llvm] Improve error messages during LLVM IR import.
Use the module location instead of unknown location if the imported
LLVM IR module does not have more precise debug information.
Additionally, use the diagMD function to print the metadata instead
of just the metadata kind if the import fails.

Reviewed By: definelicht

Differential Revision: https://reviews.llvm.org/D141357
2023-01-10 17:14:04 +01:00
Valentin Clement
dbee2030a5
[flang] Fix emboxing when input type is directly a record type
In some fir.embox cases as shown in the test, the type descriptor
was not correctly found and the descriptor was populated with a null in the
addendum. This patch fixes this issue.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D141383
2023-01-10 17:08:55 +01:00
Chris Cotter
e43295209b [clang-tidy] Match derived types in in modernize-loop-convert
This patch allows clang-tidy to replace traditional for-loops where the
container type inherits its `begin`/`end` methods from a base class.

Test plan: Added unit test cases that confirm the tool replaces the new
pattern.

Reviewed By: carlosgalvezp

Differential Revision: https://reviews.llvm.org/D140307
2023-01-10 16:08:25 +00:00
Nikita Popov
b05c71814c [Verifier] Convert tests to opaque pointers (NFC)
Some tests are removed because they check conditions that
are not relevant with opaque pointers.
2023-01-10 16:54:55 +01:00
Yitzhak Mandelbaum
3ce03c42db [clang][dataflow] Fix 2 bugs in MemberExpr interpretation.
There were two (small) bugs causing crashes in the analysis.  This patch fixes both of them.

1. An enum value was accessed as a class member. Now, the engine gracefully
ignores such member expressions.

2. Field access in `MemberExpr` of struct/class-typed global variables. Analysis
didn't interpret fields of global vars, because the vars were initialized before
the fields were added to the "allowlist". Now, the allowlist is set _before_
init of globals.

Differential Revision: https://reviews.llvm.org/D141384
2023-01-10 15:48:00 +00:00
Aaron Ballman
03b83cd703 Remove a stale FIXME comment; NFC
Also regenerates the AST matcher documentation. This matcher is tested
in TEST(HasImplicitDestinationType, MatchesSimpleCase) and
TEST(HasImplicitDestinationType, DoesNotMatchIncorrectly) in
ASTMatchersTraversalTest.cpp.
2023-01-10 10:44:40 -05:00
Alex Brachet
f296dce763 Reland: "[libc] Templatize str{,n}cmp"
This will be used to implement the case insensitive str{,n}casecmp

This was initially reverted because it broke tests on arm platforms.
Unfortunately, it didn't break on my arm machine, but I suspect the
problem was the old comparator returned char and not int.

Differential Revision: https://reviews.llvm.org/D141235
2023-01-10 15:39:54 +00:00
Aaron Ballman
44a080eee5 Fix the documentation for the hasBody AST matcher
The problem was whitespace between the comment and the code for the
matcher. Rather than fix the script, I went the easier route and
removed the offending newline. If this problem comes up again though,
we should consider making the script less fragile.
2023-01-10 10:39:30 -05:00
Sanjay Patel
2aa471bd92 [InstCombine] remove zext-of-icmp fold that may conflict with other folds
This bit-hack transform would cause the new test to infinite loop
after 21d3871b7c90f85b3ae.

The deleted transform has existed for a very long time,
but the profitable parts appear to be handled by other
folds now. This fold could replace 2 instructions with
4 instructions, so it was always in danger of going
overboard.

No tests regress by removing the whole thing.
2023-01-10 10:23:21 -05:00
Nico Weber
7a7530a352 [lld] Fix comment typos to cycle bots 2023-01-10 10:20:48 -05:00
Aaron Ballman
f30257ea9f Correct documentation for the hasBody() AST matcher; NFC
Note, when regenerating the documentation for this change, no changes
were made to the HTML file. There is an existing bug with the AST
matcher python script that fails to handle hasBody() specifically. So
this commit is to correct the internal documentation but another change
will be needed to fix the public documentation.
2023-01-10 09:53:19 -05:00
Aaron Ballman
95be33fb99 Update dump_ast_matchers.py to Python 3
Also regenerates the documentation and fixed a validation diagnostic
about use of 'is' vs '=='.
2023-01-10 09:53:06 -05:00
Matthias Springer
0e4735546e [mlir] Fix worklist bug in MultiOpPatternRewriteDriver
When `strict = true`, only pre-existing and newly-created ops are rewritten and/or folded. Such ops are stored in `strictModeFilteredOps`.

Newly-created ops were previously added to `strictModeFilteredOps` after calling `addToWorklist` (via `GreedyPatternRewriteDriver::notifyOperationInserted`). Therefore, newly-created ops were never added to the worklist.

Also fix a test case that should have gone into an infinite loop (`test.replace_with_new_op` was replaced with itself, which should have caused the op to be rewritten over and over), but did not due to this bug.

Differential Revision: https://reviews.llvm.org/D141141
2023-01-10 15:33:22 +01:00
Yitzhak Mandelbaum
089a54469f [clang][dataflow][NFC] Refine names and comments for field filtering.
Tweaks elements of the new API for filtering the set of modeled fields.

Differential Revision: https://reviews.llvm.org/D141319
2023-01-10 14:28:45 +00:00
Shoaib Meenai
49c8f903ef [libc++] Fix aligned_alloc usage for Android
Android only provides this function on API 28+; fix libc++ builds when
targeting older API levels.

Reviewed By: arichardson, #libc, philnik

Differential Revision: https://reviews.llvm.org/D141184
2023-01-10 06:25:50 -08:00
Dinar Temirbulatov
022f5ad3ec Move isAllInactivePredicate and isAllActivePredicate definition upwards, NFC 2023-01-10 14:23:29 +00:00
Andrew Ng
85a2f29fd4 [lld][COFF] Fix bug causing assertion in Chunk::setAlignment
Reinstate use of FakeSection class to avoid constructing SectionChunk
from unintialised coff_section in FakeSectionChunk constructor.

Issue was caused by commit 5a58b19f9c93f3ac51bcde318508131ae78aa10c,
"[LLD] Remove global state in lld/COFF".
2023-01-10 14:19:53 +00:00
Yitzhak Mandelbaum
264976d98e [clang][dataflow] Unify TransferOptions and DataflowAnalysisContext::Options.
Merges `TransferOptions` into the newly-introduced
`DataflowAnalysisContext::Options` and removes explicit parameter for
`TransferOptions`, relying instead on the common options carried by the analysis
context. Given that there was no intent to allow different options between calls
to `transfer`, a common value for the options is preferable.

Differential Revision: https://reviews.llvm.org/D140703
2023-01-10 14:17:25 +00:00
Jay Foad
e2e5d59236 [AMDGPU] Add GFX10/GFX11 wave64 test coverage in huge-private-buffer.ll 2023-01-10 14:17:09 +00:00
Jens Massberg
f082e54cef Avoid u8"" literals in tests, their type changes in C++20
Just specify the encoded bytes instead, which causes less confusion anyway.

Differential Revision: https://reviews.llvm.org/D141368
2023-01-10 15:14:09 +01:00
Jay Foad
a7c2121d03 [AMDGPU] Fix duplicate -verify-machineinstrs option 2023-01-10 14:07:09 +00:00
Tomas Matheson
f3fb973924 [AArch64] Comprehensive tests for atomic operations
There are a lot of variants of atomic operations, and AArch64 has several
distinct options to codegen them, and does different things depending on
available features, architecture version and optimisation level. The current
testing for atomic operations has been added gradually over time and does not
give full coverate.  Given how complex the codegen for atomic operations is, it
is valuable to cover the entire parameter space, i.e. test them all. The
resulting set of tests serve also as a reference for how each is codegened.

In order to keep the test files readable and avoid constant updating for
unrelated codegen changes, the test outputs are filtered to only include the
relevant instructions. This shows for each operation and feature which codegen
approach is taken (e.g. ll/sc loop, atomic instruction, library call).

The following parameter space is tested:
 - feature: +lse, +rcpc, etc
 - optimisation level: O0, O1 (covers GISel and SelectionDAG)
 - atomic instruction: load, store, cmpxchg, atomirmw*
 - size: i8, i16, i32, i64, i128
 - aligned/unaligned accesses
 - endianness: big, little
 - atomic ordering: release, acquire, etc
 - load atomic only: const/non-const
 - cmpxchg only: weak/strong
 - atomicrmw: update operation (add, sub, etc)

Notably not covered:
 - volatility: there should be no difference between volatile/non-volatile
 - atomicrmw fadd/fsub

The files are split by triple, LLVM instruction, and feature. This makes it
easy to diff between features and endianness for a given instruction.

The file that generates the tests is included.

There are 70 test files with an average of 2800 lines each.

Differential Revision: https://reviews.llvm.org/D141064
2023-01-10 14:02:13 +00:00
Alex Zinenko
394892841a [mlir] verify that transform ops have memory effects
Add a verifier to the TransformOpInterface ensuring that operations
implementing the interface define memory effects on their operands and
results.

Add the missing effects to TileToForeachThreadOp, specifically for
operands that were added at a later version of the op without modifying
`getEffects` accordingly.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D141371
2023-01-10 13:49:40 +00:00
Ganesh Gopalasubramanian
506ef97dc8 Revert "[X86] Add RMPQUERY to SNP instructions"
This reverts commit 313b747c5bf293aa86caf0da57b978a9758cd57b.
It wasn't reviwed as yet.
2023-01-10 19:11:25 +05:30
Ganesh Gopalasubramanian
313b747c5b [X86] Add RMPQUERY to SNP instructions 2023-01-10 19:01:18 +05:30
Tobias Gysi
6e39520630 [mlir][llvm] Call the instruction builders from a static method (NFC).
Extract a static method to call the MLIR builders that translate LLVM IR
instructions to MLIR LLVM dialect operations. This change ensures the
MLIR builders have to use the moduleImport argument rather than calling
the import methods directly. As a result, both the intrinsic and the
instruction MLIR builders have to use a moduleImport argument and none
of them has direct access to private moduleImport methods. The revision
thus enforces consistent MLIR builder implementations for instructions
and intrinsics.

The revision also moves parseDataLayoutAlignment closer to its use.

Reviewed By: Dinistro

Differential Revision: https://reviews.llvm.org/D141265
2023-01-10 14:17:56 +01:00
Sam McCall
2bac59bab4 [Support] avoid u8"" literals in tests, their type changes in C++20
Just specify the encoded bytes instead, which causes less confusion anyway.

Differential Revision: https://reviews.llvm.org/D141312
2023-01-10 14:00:22 +01:00
Sam McCall
98ae3616cd [AST] include decls owned by FriendDecl in -ast-dump
Differential Revision: https://reviews.llvm.org/D141362
2023-01-10 13:59:58 +01:00
Jay Foad
fadacaa87a [AMDGPU] Add GFX11 test coverage for FeatureBackOffBarrier 2023-01-10 12:36:16 +00:00