Commit Graph

475458 Commits

Author SHA1 Message Date
Fangrui Song
2147e9e09f [SystemZ] Fix IWYU
The file should include <map> instead of relying on the transitive include from
MC/MCPseudoProbe.h.
2023-09-20 17:54:32 -07:00
Jim Ingham
3c61e4bf28 Copy and paste error in a file header. 2023-09-20 17:43:44 -07:00
Jim Ingham
de94c109b6 The test: test_run_then_attach_wait_interrupt was flakey on Linux & Windows.
I changed the test so I could tell whether the problem was sometimes the
interrupt was failing, or maybe the was just racy.  It failed again, but
in the new failures we waited 20 seconds for the attach-wait to get interrupted
and that never happened.

So there seems to be some real raciness in the feature of interrupting an
attach-wait, but only on Linux & Windows.  The bug fix that this test was
testing was for a bug that would cause us to never try to interrupt in this
case.  So it looks like this test is uncovering some flakiness in the underlying
interrupt support when in this state.  That's a separate bug that needs fixing.

For now, I disabled the test except on macOS where it seems to run reliably.
2023-09-20 17:38:27 -07:00
Shoaib Meenai
61c5ad8857
[Sema] Fix fixit cast printing inside macros (#66853)
`Lexer::getLocForEndOfToken` is documented as returning an invalid
source location when the end of the token is inside a macro expansion.
We don't want that for this particular application, so just calculate
the end location directly instead.

Before this, format fix-its would omit the closing parenthesis (thus
producing invalid code) for macros, e.g.:

```
$ cat format.cpp
extern "C" int printf(const char *, ...);
enum class Foo { Bar };
#define LOG(...) printf(__VA_ARGS__)
void f(Foo foo) { LOG("%d\n", foo); }

$ clang -fsyntax-only format.cpp
format.cpp:4:29: warning: format specifies type 'int' but the argument has type 'Foo' [-Wformat]
    4 | void f(Foo f) { LOG("%d\n", f); }
      |                      ~~     ^
      |                             static_cast<int>(
format.cpp:3:25: note: expanded from macro 'LOG'
    3 | #define LOG(...) printf(__VA_ARGS__)
      |                         ^~~~~~~~~~~
1 warning generated.
```

We now emit a valid fix-it:

```
$ clang -fsyntax-only format.cpp
format.cpp:4:31: warning: format specifies type 'int' but the argument has type 'Foo' [-Wformat]
    4 | void f(Foo foo) { LOG("%d\n", foo); }
      |                        ~~     ^~~
      |                               static_cast<int>( )
format.cpp:3:25: note: expanded from macro 'LOG'
    3 | #define LOG(...) printf(__VA_ARGS__)
      |                         ^~~~~~~~~~~
1 warning generated.
```

Fixes https://github.com/llvm/llvm-project/issues/63462
2023-09-20 17:32:35 -07:00
Craig Topper
ea064ba6a2 Revert "[RISCV] Improve contant materialization to end with 'not' if the cons… (#66950)"
This reverts commit a8b8e94764.

Forgot to update MC tests.
2023-09-20 17:05:00 -07:00
Craig Topper
a8b8e94764
[RISCV] Improve contant materialization to end with 'not' if the cons… (#66950)
…tant has leading ones.

We can invert the value and treat it as if it had leading zeroes.
2023-09-20 16:52:51 -07:00
Fangrui Song
2be94d18b5 Revert "[MC] Make .pseudo_probe sections deterministic after D91878"
This reverts commit c8fd0cf713.

Caused heap-use-after-free
2023-09-20 16:36:23 -07:00
Jan Svoboda
c03d18441c [clang] NFCI: Use FileEntryRef in PreamblePatch 2023-09-20 16:10:18 -07:00
LLVM GN Syncbot
be52db0719 [gn build] Port 933ad5c897 2023-09-20 22:56:15 +00:00
Nico Weber
54e1454965 [gn] expand dummy target from 2ed813ff26
It also needs a sources list for the sync script not to complain.
2023-09-20 18:55:40 -04:00
Michael Maitland
81b0c24cb1 [RISCV] Add llvm/test/Transforms/VectorCombine/RISCV/lit.local.cfg
This directory was missing a lit.local.cfg which was causing some build
bots to fail when #65706 was comitted.
2023-09-20 15:50:19 -07:00
Peiming Liu
3d27d1152e
[mlir][sparse] Generates python bindings for SparseTensorTransformOps. (#66937) 2023-09-20 15:35:50 -07:00
Michael Maitland
e0aaa1956d
[VectorCombine][RISCV] Convert VPIntrinsics with splat operands to splats (#65706)
of the scalar operation

VP Intrinsics whose vector operands are both splat values may be
simplified into the scalar version of the operation and the result is
splatted.

This issue is the intrinsic dual of #65072.
2023-09-20 18:27:51 -04:00
Wu Yingcong
db4ba210ca
[fuzzer] Relax the FileCheck string for test fuzzer-custommutator.test (#66343)
The FileCheck string `LLVMFuzzerCustomMutatorLongSequence: {{.*}} MS:
{{[0-9]*}} {{(([a-zA-Z]*-){11,})}} {{.*}}` is too restrictive and may
fail the test in some case.

If we look at the commit that added this
check(66df98945e),
This check is for printing out the long mutation sequence, such as this
one
```
#53552  REDUCE cov: 6 ft: 6 corp: 5/9b lim: 4096 exec/s: 0 rss: 37Mb L: 2/3 MS: 54 ChangeByte-PersAutoDict-ChangeBit-ChangeBinInt-ChangeBit-ChangeBit-ChangeByte-CMP-EraseBytes-EraseBytes-CrossOver-InsertRepeatedBytes-ChangeByte-EraseBytes-InsertRepeatedBytes-ShuffleBytes-ChangeByte-ShuffleBytes-ChangeBit-CrossOver-ChangeBit-ShuffleBytes-ChangeBinInt-ShuffleBytes-EraseBytes-InsertByte-Custom-ShuffleBytes-CopyPart-InsertRepeatedBytes-PersAutoDict-InsertRepeatedBytes-ChangeByte-CrossOver-CrossOver-PersAutoDict-PersAutoDict-EraseBytes-ChangeBit-CopyPart-ChangeByte-CopyPart-InsertRepeatedBytes-CrossOver-CrossOver-CrossOver-CrossOver-ShuffleBytes-EraseBytes-InsertByte-InsertRepeatedBytes-CrossOver-EraseBytes-Custom- DE: "\377\377"-"\001\000"-"\001\000"-"\000\000\000\000\000\000\000\000"-"\001\000\000\000"-
```

But if we look at the code doing the printing
```cpp
void MutationDispatcher::PrintMutationSequence(bool Verbose) {
  Printf("MS: %zd ", CurrentMutatorSequence.size());
  size_t EntriesToPrint =
      Verbose ? CurrentMutatorSequence.size()
              : std::min(kMaxMutationsToPrint, CurrentMutatorSequence.size());
  for (size_t i = 0; i < EntriesToPrint; i++)
    Printf("%s-", CurrentMutatorSequence[i].Name);
  if (!CurrentDictionaryEntrySequence.empty()) {
    Printf(" DE: ");
    EntriesToPrint = Verbose ? CurrentDictionaryEntrySequence.size()
                             : std::min(kMaxMutationsToPrint,
                                        CurrentDictionaryEntrySequence.size());
    for (size_t i = 0; i < EntriesToPrint; i++) {
      Printf("\"");
      PrintASCII(CurrentDictionaryEntrySequence[i]->GetW(), "\"-");
    }
  }
}
```

We can see that the `DE: XXX` is not always printed. So the following
output is possible(and is from real-life failure), notince the missing
of `DE: XXX`.
```
#13613  NEW    cov: 5 ft: 5 corp: 4/6b lim: 4096 exec/s: 0 rss: 32Mb L: 2/2 MS: 27 InsertByte-ChangeBinInt-ChangeBinInt-CrossOver-ShuffleBytes-ChangeBit-EraseBytes-ShuffleBytes-InsertByte-InsertRepeatedBytes-CopyPart-InsertByte-ChangeByte-ChangeBit-InsertByte-CrossOver-EraseBytes-CopyPart-ShuffleBytes-EraseBytes-InsertByte-InsertRepeatedBytes-CrossOver-CrossOver-ShuffleBytes-ChangeBit-Custom-
#13765  ......
```
This output is totally legit and will fail that check.

So I remove the check for the following strings, I think `MS: {{[0-9]*}}
{{(([a-zA-Z]*-){11,})}}` is sufficient for checking the long mutation
sequence. This should help resolve the flaky failure of
fuzzer-custommutator.test.
2023-09-20 15:19:25 -07:00
Zequan Wu
c414e5856a
[Doc] Clarify the comments about how handleErrors works. (#65655) 2023-09-20 18:14:03 -04:00
Jacques Pienaar
75453714f0
[mlir][python] Expose AsmState python side. (#66819)
This does basic plumbing, ideally want a context approach to reduce
needing to thread these manually, but the current is useful even in that
state.

Made Value.get_name change backwards compatible, so one could either set
a field or create a state to pass in.
2023-09-20 15:12:06 -07:00
Fangrui Song
f5b42eaadb [ELF] -r --compress-debug-sections: update implicit addends for .rel.debug_* referencing STT_SECTION symbols (#66804)
https://reviews.llvm.org/D48929 updated addends for non-SHF_ALLOC sections
relocated by REL for -r links, but the patch did not update the addends when
--compress-debug-sections={zlib,zstd} is used (#66738).

https://reviews.llvm.org/D116946 handled tombstone values in debug
sections in relocatable links. As a side effect, both
relocateNonAllocForRelocatable (using `sec->relocations`) and
relocatenonNonAlloc (using raw REL/RELA) may run.

Actually, we can adjust the condition in relocatenonAlloc to completely replace
relocateNonAllocForRelocatable. This patch implements this idea and fixes #66738.

As relocateNonAlloc processes the raw relocations like copyRelocations() does,
the condition `if (config->relocatable && type != target.noneRel)` in `copyRelocations`
(commit 08d6a3f133, modified by https://reviews.llvm.org/D62052)
can be made specific to SHF_ALLOC sections.

As a side effect, we can now report diagnostics for PC-relative relocations for
-r. This is a less useful diagnostic that is not worth too much code. As
https://github.com/ClangBuiltLinux/linux/issues/1937 has violations, just
suppress the warning for -r. Tested by commit 561b98f9e0.
2023-09-20 14:50:13 -07:00
Mingming Liu
2639fdc5dd [InlineCost]Account for switch instructons when the switch condition could be simplified as a result of inlines.
Reviewed By: kazu

Differential Revision: https://reviews.llvm.org/D152053
2023-09-20 14:49:06 -07:00
Fangrui Song
9ee65a7618 Revert "[Coverage] Fix -Wswitch after D138847"
This reverts commit ca22d6e405.

The base patch 618a22144d has been reverted.
2023-09-20 14:45:19 -07:00
Fangrui Song
561b98f9e0 [ELF][test] Improve non-abs-reloc.s to test non-STT_SECTION local symbol 2023-09-20 14:40:32 -07:00
Alan Phipps
ab3cd075b3 Revert "[Coverage][llvm-cov] Enable MC/DC Support in LLVM Source-based Code Coverage (2/3)"
This reverts commit 618a22144d.

Buildbots failing on windows and one other issue.
2023-09-20 16:32:34 -05:00
Daniel Thornburgh
7f3467412e Revert "Remove some raciness from the TestProcessAttach.test_run_then_attach_wait_interrupt"
This reverts commit df93c4ffdf.
This change is breaking the LLDB CI builders, e.g.
https://lab.llvm.org/buildbot/#/builders/68/builds/60350
2023-09-20 14:30:24 -07:00
Dave Lee
56b148aa8d
[lldb] Fix stdcpp type summary mistakenly marked as regex (NFC) (#66949)
`std::basic_string<char>` is not a regex, and treating it as such could
unintentionally
cause a formatter to substring match a template type parameter, for
example:
`std::vector<std::basic_string<char>>`.

Differential Revision: https://reviews.llvm.org/D158663
2023-09-20 14:24:04 -07:00
Fangrui Song
ca22d6e405 [Coverage] Fix -Wswitch after D138847 2023-09-20 14:20:58 -07:00
Matheus Izvekov
8b04f1e49a
[X86] fix combineSubSetcc to handle a large constant (#66941) 2023-09-20 23:17:33 +02:00
Vitaly Buka
2613c77cba
[HWASAN] Prevent SEGV in report near inaccessible memory (#66861)
We can't use IsAccessibleMemoryRange on short granule check because of
performance impact. However we can prevent crashing if report prints out
"Tags for short granules around the buggy address".
2023-09-20 14:07:30 -07:00
Kazu Hirata
e764ec6291 [mlir] Fix warnings
This patch fixes:

  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp:1525:3:
  error: default label in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp:1541:3:
  error: default label in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]
2023-09-20 14:06:55 -07:00
Piotr Zegar
5eaa5312e7 [clang-tidy][NFC] Update documentation for bugprone-undefined-memory-manipulation
Add example and more information to check documentation.
2023-09-20 21:01:34 +00:00
Christopher Ferris
93e12f1160
[scudo] Remove hard-coded use of AndroidConfig. (#66845)
The bionic wrappers hard-coded use of AndroidConfig. This overrides the
custom config code, so remove the hard-coding.
2023-09-20 13:48:57 -07:00
Fangrui Song
c8fd0cf713 [MC] Make .pseudo_probe sections deterministic after D91878
MCPseudoProbeSections::emit iterates over MCProbeDivisions and creates sections.
When the map key is MCSymbol *, the iteration order is not stable. The
underlying BumpPtrAllocator largely decreases the flakiness. That said,
the allocations from BumpPtrAllocator may have different orders.
Under tcmalloc, llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll fails
about 7 times per 1000 runs.
2023-09-20 13:47:48 -07:00
Jason Molenda
933ad5c897 [lldb] Add 'modify' type watchpoints, make it default (#66308)
Watchpoints in lldb can be either 'read', 'write', or 'read/write'. This
is exposing the actual behavior of hardware watchpoints. gdb has a
different behavior: a "write" type watchpoint only stops when the
watched memory region *changes*.

A user is using a watchpoint for one of three reasons:

1. Want to find what is changing/corrupting this memory.
2. Want to find what is writing to this memory.
3. Want to find what is reading from this memory.

I believe (1) is the most common use case for watchpoints, and it
currently can't be done in lldb -- the user needs to continue every time
the same value is written to the watched-memory manually. I think gdb's
behavior is the correct one. There are some use cases where a developer
wants to find every function that writes/reads to/from a memory region,
regardless of value, I want to still allow that functionality.

This is also a bit of groundwork for my large watchpoint support
proposal
https://discourse.llvm.org/t/rfc-large-watchpoint-support-in-lldb/72116
where I will be adding support for AArch64 MASK watchpoints which watch
power-of-2 memory regions. A user might ask to watch 24 bytes, and a
MASK watchpoint stub can do this with a 32-byte MASK watchpoint if it is
properly aligned. And we need to ignore writes to the final 8 bytes of
that watched region, and not show those hits to the user.

This patch adds a new 'modify' watchpoint type and it is the default.

Re-landing this patch after addressing testsuite failures found in CI on
Linux, Intel machines, and windows.

rdar://108234227
2023-09-20 13:42:16 -07:00
Alan Phipps
618a22144d [Coverage][llvm-cov] Enable MC/DC Support in LLVM Source-based Code Coverage (2/3)
Part 2 of 3. This includes the Visualization and Evaluation components.

Differential Revision: https://reviews.llvm.org/D138847
2023-09-20 15:30:47 -05:00
Corentin Jabot
33dfd90700 Fix sphinx bot build 2023-09-20 22:27:29 +02:00
Jim Ingham
df93c4ffdf Remove some raciness from the TestProcessAttach.test_run_then_attach_wait_interrupt
command.

We were reading the command output right after sending the interrupt, but
sometimes that wasn't long enough for the command result text to have been emitted.
I added a poll for the state change to eStateExited, and then added a bit more sleep
to give the command a chance to complete.
2023-09-20 13:08:40 -07:00
Alexey Bataev
7705342122 [SLP]Do not gather node, if the instruction, that does not require
scheduling, is previously vectorized.

If the main node was vectorized already, but does not require
scheduling, we still can try to vectorize it in this new node instead of
gathering.
2023-09-20 12:52:37 -07:00
Richard Smith
1aadd4766e Remove #include that the cp-to-llvm script added.
This is a short-term fix to make the buildbots happy. We should also fix
the script.
2023-09-20 12:42:34 -07:00
Richard Smith
4b163e343c Implement mangling rules for C++20 concepts and requires-expressions.
This implements proposals from:

- https://github.com/itanium-cxx-abi/cxx-abi/issues/24: mangling for
  constraints, requires-clauses, requires-expressions.
- https://github.com/itanium-cxx-abi/cxx-abi/issues/31: requires-clauses and
  template parameters in a lambda expression are mangled into the <lambda-sig>.
- https://github.com/itanium-cxx-abi/cxx-abi/issues/47 (STEP 3): mangling for
  template argument is prefixed by mangling of template parameter declaration
  if it's not "obvious", for example because the template parameter is
  constrained (we already implemented STEP 1 and STEP 2).

This changes the manglings for a few cases:

- Functions and function templates with constraints.
- Function templates with template parameters with deduced types:
  `typename<auto N> void f();`
- Function templates with template template parameters where the argument has a
  different template-head:
  `template<template<typename...T>> void f(); f<std::vector>();`

In each case where a mangling changed, the change fixes a mangling collision.

Note that only function templates are affected, not class templates or variable
templates, and only new constructs (template parameters with deduced types,
constrained templates) and esoteric constructs (templates with template
template parameters with non-matching template template arguments, most of
which Clang still does not accept by default due to
`-frelaxed-template-template-args` not being enabled by default), so the risk
to ABI stability from this change is relatively low. Nonetheless,
`-fclang-abi-compat=17` can be used to restore the old manglings for cases
which we could successfully but incorrectly mangle before.

Fixes #48216, #49884, #61273

Reviewed By: erichkeane, #libc_abi

Differential Revision: https://reviews.llvm.org/D147655
2023-09-20 12:38:15 -07:00
Piotr Zegar
5d95d27e50
[clang-tidy] Fix support for typedefs in readability-identifier-naming (#66835)
Typedef rename were not properly handled when typedef were used behind
pointer, or as a part of function type. Additionally because entire
function were passed as an source-range, when function started with
macro, such change were not marked for a fix.

Removed workaround and used proper TypedefTypeLoc instead.

Fixes #55156, #54699
2023-09-20 21:29:54 +02:00
Piotr Zegar
33aa095a8b [clang-tidy][NFC] Add release notes entry for D127036
Add release notes entry describing change in
bugprone-undefined-memory-manipulation check.
2023-09-20 18:56:00 +00:00
Fabian Wolff
6780d53f41 [clang-tidy] Warn about arrays in bugprone-undefined-memory-manipulation
Adds basic support for arrays to non-trivial types.

Fixes #55579

Differential Revision: https://reviews.llvm.org/D127036
2023-09-20 18:56:00 +00:00
Fangrui Song
08b10afc1e [bazel] Port D149368 mlir openmp 2023-09-20 11:53:59 -07:00
Louis Dionne
0740b7e3e2 [libc++abi][NFC] Remove mentions of LIBCXXABI_SHARED_LIBRARIES
LIBCXXABI_SHARED_LIBRARIES doesn't exist anymore, so this always expanded
to nothing at all.
2023-09-20 14:52:02 -04:00
Aiden Grossman
3dc2f2618b
[MLGO] Move MBB Profile Dump test to Generic (#66856)
This patch moves the MBB Profile Dump to ./llvm/test/CodeGen/Generic
from ./llvm/test/CodeGen/MlRegAlloc as the profile dump doesn't have
anything to do with the ML guided register allocation heuristic.
2023-09-20 11:50:33 -07:00
Fangrui Song
9f4c9b90c9 Revert D155711 "[SimplifyCFG] Hoist common instructions on Switch."
This reverts commit 96ea48ff5d.

The change may cause Verifier.cpp error
"musttail call must precede a ret with an optional bitcast"
2023-09-20 11:49:20 -07:00
Andrew Gozillon
76916669b9 [MLIR][OpenMP] Initial Lowering of Declare Target for Data
This patch adds initial lowering for DeclareTargetAttr on
GlobalOp's utilising registerTargetGlobalVariable
and getAddrOfDeclareTargetVar from the
OMPIRBuilder.

It also adds initial processing of declare target map
operands, populating the combinedInfo that the
OMPIRBuilder requires to generate kernels and
it's kernel argument structure.

The combination of these additions allows simple mapping
of declare target globals to Target regions, as such a simple
runtime test showcasing this and testing it has been added.

The patch currently does not factor in filtering
based on device_type clauses (e.g. no emission of
globals for device if host specified), this will come in
a future iteration. And for the moment it's only been
tested with 1-D arrays and basic fortran data types,
more complex types (such as user defined derived
types from Fortran, allocatables or Fortran pointers)
may need further work.

reviewers: kiranchandramohan, skatrak

Differential Revision: https://reviews.llvm.org/D149368
2023-09-20 13:31:15 -05:00
Alexey Bataev
03feab7499 [SLP][NFC]Add a test with the reused main op instruction, NFC. 2023-09-20 11:28:59 -07:00
Noah Goldstein
6d6314ba64 [DAGCombiner] Extend combineFMulOrFDivWithIntPow2 to work for non-splat float vecs
Do so by extending `matchUnaryPredicate` to also work for
`ConstantFPSDNode` types then encapsulate the constant checks in a
lambda and pass it to `matchUnaryPredicate`.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D154868
2023-09-20 13:28:24 -05:00
Noah Goldstein
47c642f9a0 [DAGCombiner] Fold IEEE fmul/fdiv by Pow2 to add/sub of exp
Note: This is moving D154678 which previously implemented this in
InstCombine. Concerns where brought up that this was de-canonicalizing
and really targeting a codegen improvement, so placing in DAGCombiner.

This implements:

```
(fmul C, (uitofp Pow2))
    -> (bitcast_to_FP (add (bitcast_to_INT C), Log2(Pow2) << mantissa))
(fdiv C, (uitofp Pow2))
    -> (bitcast_to_FP (sub (bitcast_to_INT C), Log2(Pow2) << mantissa))
```
The motivation is mostly fdiv where 2^(-p) is a fairly common
expression.

The patch is intentionally conservative about the transform, only
doing so if we:
    1) have IEEE floats
    2) C is normal
    3) add/sub of max(Log2(Pow2)) stays in the min/max exponent
       bounds.

Alive2 can't realistically prove this, but did test float16/float32
cases (within the bounds of the above rules) exhaustively.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D154805
2023-09-20 13:28:24 -05:00
Noah Goldstein
32a46919a2 [AMDGPU] Add tests for folding fmul/fdiv by Pow2 to add/sub of exp; NFC
Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D159405
2023-09-20 13:28:24 -05:00
Noah Goldstein
6ec53b4567 [X86] Add tests for folding fmul/fdiv by Pow2 to add/sub of exp; NFC
Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D154804
2023-09-20 13:28:24 -05:00