Commit Graph

381095 Commits

Author SHA1 Message Date
Simon Pilgrim 73adc26ac0 [DAG] expandAddSubSat - break if-else chain. NFCI.
Fix styleguide issue - each if() block always returns so we don't need to make them a if-else chain.
2021-02-26 11:02:08 +00:00
Max Kazantsev a754dc2358 [Test] Two more interesting test cases & their codegen counterparts 2021-02-26 17:23:12 +07:00
Vinayaka Bandishti ce0f10a1d1 [MLIR][affine] Certain Call Ops to prevent fusion
Fixes a bug in affine fusion pipeline where an incorrect fusion is performed
despite a Call Op that potentially modifies memrefs under consideration
exists between source and target.

Fixes part of https://bugs.llvm.org/show_bug.cgi?id=49220

Reviewed By: bondhugula, dcaballe

Differential Revision: https://reviews.llvm.org/D97252
2021-02-26 15:27:41 +05:30
Fraser Cormack 37014db013 [RISCV] Use existing method for the LMUL1 type. NFCI.
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D97467
2021-02-26 09:44:05 +00:00
Clement Courbet b16cbd8890 [llvm-exegesis][X86] Ignore a few unmeasurable opcodes.
Differential Revision: https://reviews.llvm.org/D90744
2021-02-26 10:48:15 +01:00
Yang Fan e9475a2762
[Sema] Fix MSVC "attribute is not recognized" warning (NFC)
MSVC warning:
```
\llvm-project\clang\lib\Sema\SemaChecking.cpp(10323): warning C5030: attribute 'clang::fallthrough' is not recognized
```
2021-02-26 17:28:24 +08:00
Max Kazantsev cb2bc9aad5 [Test] Add one more test with corner cases for non-wrapping IVs 2021-02-26 16:17:50 +07:00
Yang Fan d5e0868e5e
[Basic] Fix Wreturn-type gcc warning (NFC) 2021-02-26 17:14:13 +08:00
Yu-Hsun Chiang d412dbe388 [clang][NFC] Extract Target and AuxTarget creation in CompilerInstance to new function
As @sammccall mentioned in [[ https://reviews.llvm.org/D97109 | D97109 ]], I've extract the logic of creating Target and AuxTarget into a new function called `createTargetAndAuxTarget`.

Since there are many similar code in clang or other related tools, consolidating them into a single function may help others to maintain the logic handling target related things.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D97493
2021-02-26 09:29:11 +01:00
Jakub Budiský 2a42c759ae [clang-format] [PR19056] Add support for access modifiers indentation
Adds support for coding styles that make a separate indentation level for access modifiers, such as Code::Blocks or QtCreator.

The new option, `IndentAccessModifiers`, if enabled, forces the content inside classes, structs and unions (“records”) to be indented twice while removing a level for access modifiers. The value of `AccessModifierOffset` is disregarded in this case, aiming towards an ease of use.

======
The PR (https://bugs.llvm.org/show_bug.cgi?id=19056) had an implementation attempt by @MyDeveloperDay already (https://reviews.llvm.org/D60225) but I've decided to start from scratch. They differ in functionality, chosen approaches, and even the option name. The code tries to re-use the existing functionality to achieve this behavior, limiting possibility of breaking something else.

Reviewed By: MyDeveloperDay, curdeius, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D94661
2021-02-26 09:17:07 +01:00
Christian Sigg 0b05908feb [mlir] Remove some rarely used OpState members and use Operation members instead.
Skipping the deprecation dance here.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D97494
2021-02-26 08:37:11 +01:00
Petr Hosek bf6380c096 [Driver] Don't pass -ffile-compilation-dir through to cc1
This is a driver only flag so it has to be expanded when invoking cc1.

Differential Revision: https://reviews.llvm.org/D97528
2021-02-25 23:03:54 -08:00
Craig Topper a3beae6171 [RISCV] Add test cases for fixed vector extract element with non-constant index. NFC 2021-02-25 22:36:38 -08:00
Fangrui Song 880c9c56c1 [MC] Allow .cfi_sections with empty section list
GNU as supports this. This mode silently ignores
.cfi_startproc/.cfi_endproc and .cfi_* in between.

Also drop a diagnostic `in '.cfi_sections' directive`: the diagnostic
already includes the line and it is clear the line is a `.cfi_sections` directive.
2021-02-25 22:29:49 -08:00
Petr Hosek 8459b8ef39 [Driver] Rename -fprofile-{prefix-map,compilation-dir} to -fcoverage-{prefix-map,compilation-dir}
These flags affect coverage mapping (-fcoverage-mapping), not
-fprofile-[instr-]generate so it makes more sense to use the
-fcoverage-* prefix.

Differential Revision: https://reviews.llvm.org/D97434
2021-02-25 21:40:12 -08:00
Petr Hosek 9e56a093ee [Driver] Create -ffile-compilation-dir alias
We introduce -ffile-compilation-dir shorthand to avoid having to set
-fdebug-compilation-dir and -fprofile-compilation-dir separately. This
is similar to -ffile-prefix-map.

Differential Revision: https://reviews.llvm.org/D97433
2021-02-25 21:20:10 -08:00
Bill Wendling a9f9ceb35f [X86] Use correct padding when in 16-bit mode
In 16-bit mode, some of the nop patterns used in 32-bit mode can end up
mangling other instructions. For instance, an aligned "movz" instruction
may have the 0x66 and 0x67 prefixes omitted, because the nop that's used
messes things up.

       xorl    %ebx, %ebx
       .p2align 4, 0x90
       movzbl  (%esi,%ebx), %ecx

Use instead nop patterns we know 16-bit mode can handle.

Differential Revision: https://reviews.llvm.org/D97268
2021-02-25 20:05:45 -08:00
Fangrui Song 599711dce5 [llvm-dwarfdump] StringMap -> MapVector to make iteration order stable
Exposed by D97396
2021-02-25 20:05:05 -08:00
Kazu Hirata 5fc9e30985 [Scalar] Use range-based for loops (NFC) 2021-02-25 19:54:38 -08:00
Kazu Hirata edd92e018a [TableGen] Use ListSeparator (NFC) 2021-02-25 19:54:36 -08:00
Eric Schweitz 67360decc3 [flang][fir] Add array value operations.
We lower expressions with rank > 0 to a set of high-level array operations.
These operations are then analyzed and refined to more primitve
operations in subsequent pass(es).

This patch upstreams these array operations and some other helper ops.

Authors: Eric Schweitz, Rajan Walia, Kiran Chandramohan, et.al.

https://github.com/flang-compiler/f18-llvm-project/pull/565

Differential Revision: https://reviews.llvm.org/D97421
2021-02-25 19:16:43 -08:00
Justin Lebar e890fffcab
Fix signed-compare warning.
Introduced in my c90dac27e9.
2021-02-25 18:14:40 -08:00
Rob Suderman c47aa3c8de Revert [MLIR][TOSA] Added Tosa to Standard/SCF Lowerings (const, if, while)
This reverts commit a813e9be5b.

Results in an ASAN failure due to bypassing rewriter.

Differential Revision: https://reviews.llvm.org/D97518
2021-02-25 18:05:16 -08:00
Chen Zheng d39bc36b1b [debug-info] refactor emitDwarfUnitLength
remove `Hi` `Lo` argument from `emitDwarfUnitLength`, so we
can make caller of emitDwarfUnitLength easier.

Reviewed By: MaskRay, dblaikie, ikudrin

Differential Revision: https://reviews.llvm.org/D96409
2021-02-25 21:00:25 -05:00
Justin Lebar c90dac27e9
[clang] Print 32 candidates on the first failure, with -fshow-overloads=best.
Previously, -fshow-overloads=best always showed 4 candidates.  The
problem is, when this isn't enough, you're kind of up a creek; the only
option available is to recompile with different flags.  This can be
quite expensive!

With this change, we try to strike a compromise.  The *first* error with
more than 4 candidates will show up to 32 candidates.  All further
errors continue to show only 4 candidates.

The hope is that this way, users will have *some chance* of making
forward progress, without facing unbounded amounts of error spam.

Differential Revision: https://reviews.llvm.org/D95754
2021-02-25 17:45:19 -08:00
Peter Collingbourne 9678b07e42 Revert 7a0da88943, "scudo: Support memory tagging in the secondary allocator."
We measured a 2.5 seconds (17.5%) regression in Android boot time
performance with this change.
2021-02-25 16:50:02 -08:00
Craig Topper d7fca3f0bf [RISCV] Support fixed vector extract_element for FP types. 2021-02-25 16:30:28 -08:00
Fangrui Song 4bbcd63eea [ELF] Add -z start-stop-gc to let __start_/__stop_ not retain C identifier name sections
For one metadata section usage, each text section references a metadata section.
The metadata sections have a C identifier name to allow the runtime to collect them via `__start_/__stop_` symbols.

Since `__start_`/`__stop_` references are always present from live sections, the
C identifier name sections appear like GC roots, which means they cannot be
discarded by `ld --gc-sections`.

To make such sections GCable, either SHF_LINK_ORDER or a section group is needed.

SHF_LINK_ORDER is not suitable for the references can be inlined into other functions
(See D97430:
Function A (in the section .text.A) references its `__sancov_guard` section.
Function B inlines A (so now .text.B references `__sancov_guard` - this is invalid with the semantics of SHF_LINK_ORDER).

In the linking stage,
if `.text.A` gets discarded, and `__sancov_guard` is retained via the reference from `.text.B`,
the output will be invalid because `__sancov_guard` references the discarded `.text.A`.
LLD errors "sh_link points to discarded section".
)

A section group have size overhead, and is cumbersome when there is just one metadata section.

Add `-z start-stop-gc` to drop the "__start_/__stop_ references retain
non-SHF_LINK_ORDER non-SHF_GROUP C identifier name sections" rule.
We reserve the rights to switch the default in the future.

Reviewed By: phosek, jrtc27

Differential Revision: https://reviews.llvm.org/D96914
2021-02-25 15:46:37 -08:00
Yonghong Song 6d102f15a3 BPF: Add LLVMTransformUtils in CMakefile LINK_COMPONENTS
Commit 1959ead525 ("BPF: Implement TTI.getCmpSelInstrCost()
properly") introduced a dependency on LLVMTransformUtils
library. Let us encode this dependency explicitly in
CMakefile to avoid build error.
2021-02-25 15:43:25 -08:00
Ryan Prichard 91f8aacc04 [Android] Use -l:libunwind.a with --rtlib=compiler-rt
On Android, the unwinder isn't part of the C++ STL and isn't (in older
versions) exported from libc.so. Instead, the driver links the static
unwinder archive implicitly. Currently, the Android NDK implicitly
links libgcc.a to provide both builtins and the unwinder.

To support switching to compiler-rt builtins and libunwind, make
--rtlib=compiler-rt behave the same way on Android, and implicitly pass
-l:libunwind.a to the linker.

Adjust the -ldl logic. For the Android NDK, the unwinder (whether
libgcc.a or libunwind.a) is linked statically and calls a function in
the dynamic loader for finding unwind tables (e.g. dl_iterate_phdr).
On Android, this function is in libc.a for static executables and
libdl.so otherwise, so -ldl is needed. (glibc doesn't need -ldl because
its libc.so exports dl_iterate_phdr.)

Differential Revision: https://reviews.llvm.org/D96403
2021-02-25 15:40:02 -08:00
Jianzhou Zhao c88fedef2a [dfsan] Conservative solution to atomic load/store
DFSan at store does store shadow data; store app data; and at load does
load shadow data; load app data.

When an application data is atomic, one overtainting case is

thread A: load shadow
thread B: store shadow
thread B: store app
thread A: load app

If the application address had been used by other flows, thread A reads
previous shadow, causing overtainting.

The change is similar to MSan's solution.
1) enforce ordering of app load/store
2) load shadow after load app; store shadow before shadow app
3) do not track atomic store by reseting its shadow to be 0.
The last one is to address a case like this.

Thread A: load app
Thread B: store shadow
Thread A: load shadow
Thread B: store app

This approach eliminates overtainting as a trade-off between undertainting
flows via shadow data race.

Note that this change addresses only native atomic instructions, but
does not support builtin libcalls yet.
   https://llvm.org/docs/Atomics.html#libcalls-atomic

Reviewed-by: morehouse

Differential Revision: https://reviews.llvm.org/D97310
2021-02-25 23:34:58 +00:00
Kostya Kortchinsky 41751b6373 [Clang][ASan] Correct AsanDtorKindToString to return non-void in default case
Post D96572, a warning started showing up for me:
`clang/lib/Basic/Sanitizers.cpp:73:1: warning: control reaches end of non-void function [-Wreturn-type]`

So this adds a default to the case to return invalid, which seems appropriate,
and appears to correct the issue.

Differential Revision: https://reviews.llvm.org/D97496
2021-02-25 15:32:18 -08:00
James Y Knight 24539f1ef2 Add Alignment argument to IRBuilder CreateAtomicRMW and CreateAtomicCmpXchg.
And then push those change throughout LLVM.

Keep the old signature in Clang's CGBuilder for now -- that will be
updated in a follow-on patch (D97224).

The MLIR LLVM-IR dialect is not updated to support the new alignment
attribute, but preserves its existing behavior.

Differential Revision: https://reviews.llvm.org/D97223
2021-02-25 18:29:42 -05:00
LLVM GN Syncbot 52c781f6f1 [gn build] Port 4753a69a31 2021-02-25 23:16:39 +00:00
Francis Visoiu Mistrih fee9abe69c [Remarks] Provide more information about auto-init calls
This now analyzes calls to both intrinsics and functions.

For intrinsics, grab the ones we know and care about (mem* family) and
analyze the arguments.

For calls, use TLI to get more information about the libcalls, then
analyze the arguments if known.

```
auto-init.c:4:7: remark: Call to memset inserted by -ftrivial-auto-var-init. Memory operation size: 4096 bytes. [-Rpass-missed=annotation-remarks]
  int var[1024];
      ^
```

Differential Revision: https://reviews.llvm.org/D97489
2021-02-25 15:14:09 -08:00
Francis Visoiu Mistrih 4753a69a31 [Remarks] Provide more information about auto-init stores
This adds support for analyzing the instruction with the !annotation
"auto-init" in order to generate a more user-friendly remark.

For now, support the store size, and whether it's atomic/volatile.

Example:

```
auto-init.c:4:7: remark: Store inserted by -ftrivial-auto-var-init.Store size: 4 bytes. [-Rpass-missed=annotation-remarks]
  int var;
      ^
```

Differential Revision: https://reviews.llvm.org/D97412
2021-02-25 15:14:09 -08:00
Francis Visoiu Mistrih c49b600b2f [Remarks] Emit remarks for "auto-init" !annotations
Using the !annotation metadata, emit remarks pointing to code added by
`-ftrivial-auto-var-init` that survived the optimizer.

Example:

```
auto-init.c:4:7: remark: Initialization inserted by -ftrivial-auto-var-init. [-Rpass-missed=annotation-remarks]
  int buf[1024];
      ^
```

The tests are testing various situations like calls/stores/other
instructions, with debug locations, and extra debug information on
purpose: more patches will come to improve the reporting to make it more
user-friendly, and these tests will show how the reporting evolves.

Differential Revision: https://reviews.llvm.org/D97405
2021-02-25 15:14:09 -08:00
Adrian Prantl 00b3f2f310 Add more historic DWARF vendor extensions
The maintainer of libdwarf kindly provided this patch with a bunch of
historic DWARF extensions that are missing from Dwarf.def. This list
is helpful to avoid potential conflicts in the user-defined vendor
extension space in the future.

Patch by David Anderson!

[Relanded with an updated test.]

Differential Revision: https://reviews.llvm.org/D97242
2021-02-25 15:09:42 -08:00
Zequan Wu 4500f0a732 [Clang][Attributes] Allow not_tail_called attribute to be applied to virtual function.
It would be beneficial to allow not_tail_called attribute to be applied to
virtual functions. I don't see any drawback of allowing this.

Differential Revision: https://reviews.llvm.org/D96832
2021-02-25 14:58:18 -08:00
Yonghong Song 1959ead525 BPF: Implement TTI.getCmpSelInstrCost() properly
The Select insn in BPF is expensive as BPF backend
needs to resolve with conditionals.  This patch set
the getCmpSelInstrCost() to SCEVCheapExpansionBudget
for Select insn to prevent some Select insn related
optimizations.

This change is motivated during bcc code review for
   https://github.com/iovisor/bcc/pull/3270
where IndVarSimplifyPass eventually caused generating
the following asm code:
  ;       for (i = 0; (i < VIRTIO_MAX_SGS) && (i < num); i++) {
      14:       16 05 40 00 00 00 00 00 if w5 == 0 goto +64 <LBB0_6>
      15:       bc 51 00 00 00 00 00 00 w1 = w5
      16:       04 01 00 00 ff ff ff ff w1 += -1
      17:       67 05 00 00 20 00 00 00 r5 <<= 32
      18:       77 05 00 00 20 00 00 00 r5 >>= 32
      19:       a6 01 01 00 05 00 00 00 if w1 < 5 goto +1 <LBB0_4>
      20:       b7 05 00 00 06 00 00 00 r5 = 6
  00000000000000a8 <LBB0_4>:
      21:       b7 02 00 00 00 00 00 00 r2 = 0
      22:       b7 01 00 00 00 00 00 00 r1 = 0
  ;       for (i = 0; (i < VIRTIO_MAX_SGS) && (i < num); i++) {
      23:       7b 1a e0 ff 00 00 00 00 *(u64 *)(r10 - 32) = r1
      24:       7b 5a c0 ff 00 00 00 00 *(u64 *)(r10 - 64) = r5
Note that insn #15 has w1 = w5 and w1 is refined later but r5(w5) is
eventually saved on stack at insn #24 for later use. This cause
later verifier failures.

With this change, IndVarSimplifyPass won't do the above
transformation any more.

Differential Revision: https://reviews.llvm.org/D97479
2021-02-25 14:48:53 -08:00
Richard Smith d95c6d3b69 [www] Add cxx_status tracking for C++23.
Convert the list of standards to a table; it's starting to get unwieldy.
2021-02-25 14:47:43 -08:00
Rob Suderman a813e9be5b [MLIR][TOSA] Added Tosa to Standard/SCF Lowerings (const, if, while)
Includes a lowering for tosa.const, tosa.if, and tosa.while to Standard/SCF dialects. TosaToStandard is
used for constant lowerings and TosaToSCF handles the if/while ops.

Reviewed By: silvas

Differential Revision: https://reviews.llvm.org/D97352
2021-02-25 14:35:21 -08:00
Richard Smith 95d0d8e9e9 Fix constructor declarations that are invalid in C++20 onwards.
Under C++ CWG DR 2237, the constructor for a class template C must be
written as 'C(...)' not as 'C<T>(...)'. This fixes a build failure with
GCC in C++20 mode.

In passing, remove some other redundant '<T>' qualification from the
affected classes.
2021-02-25 14:25:01 -08:00
Martin Storsjö c7d46f221e [libcxx] Use the allocating form of getcwd() on Glibc and Apple platforms
This avoids having to query pathconf for a max size for
preallocating a buffer for the return value.

This is an extension to the POSIX getcwd() spec.

Differential Revision: https://reviews.llvm.org/D97460
2021-02-26 00:14:12 +02:00
Martin Storsjö fb2e4f5401 [libcxx] [test] Add a MinGW target
This can't easily be autodetected (unless LIBCXX_TARGET_TRIPLE is
specified, or unless we query what the compiler's default target is,
which only is supported by clang), but can be chosen manually via
LIBCXX_TARGET_INFO.

This chooses mingw style lib naming, and uses -nostdlibc++ instead
of -nodefaultlib -nostdlib (as the latter requires specifying a lot of
details manually - this is done in the cmake config though).

Differential Revision: https://reviews.llvm.org/D97294
2021-02-26 00:10:48 +02:00
Martin Storsjö 72fe14d40a [libcxx] [cmake] Add asm to the runtimes build languages
This fixes building libunwind with a new enough version of cmake.

(libunwind treats its asm sources as C depending on the cmake version
on some platforms; this fixes builds when such workarounds aren't used,
when cmake treats asm correctly on its own.)

Differential Revision: https://reviews.llvm.org/D97399
2021-02-26 00:10:48 +02:00
Martin Storsjö 3be7968c36 [libcxx] [test] Ifdef out uses of create_fifo on windows
Restructure code in directory_entry.obs/file_type_obs.pass.cpp
and directory_entry.obs/hard_link_count.pass.cpp to reduce the
amount of ifdeffery needed.

In file_type_obs.pass.cpp, we can't inline the calls to
env.create_* into the lambda calls (e.g. "test_path(env.create_*())"),
because the lambda removes the referenced file, and the hardlink
must be created while the earlier test file exists.

In hard_link_count.pass.cpp, move restoration of the original
directory permissions to the end of the lambda, so that new
directory entries can be created after the lambda has run once.

Differential Revision: https://reviews.llvm.org/D89948
2021-02-26 00:10:47 +02:00
Martin Storsjö f15377084c [libcxx] [test] Use string().c_str() to convert a std::filesystem::path to a const char*
On Windows, path::value_type is wchar_t, so one can't pass the return
value of path::c_str() directly to std::remove().

This matches what was done for tests under std/input.output/filesystems
in 81db3c31aa and
3784bdf217.

Differential Revision: https://reviews.llvm.org/D97458
2021-02-26 00:10:47 +02:00
Nicolas Guillemot 3573a90b8a [PM] Show the pass argument in pre/post-pass IR dumps
This patch adds each pass' pass argument in the header for IR dumps.
For example:

Before:

```
    *** IR Dump Before InstructionSelect ***
```

After:

```
    *** IR Dump Before InstructionSelect (instruction-select) ***
```

The goal is to make it easier to know what argument to pass to
command line options like `debug-only` or `run-pass` to further
investigate a given pass.
2021-02-25 14:02:00 -08:00
AndreyChurbanov 1df6e58e55 [OpenMP] libomp minor cleanup
Cleanup changes:
- check value read from file;
- remove dead code;
- make unsigned variable to read hexadecimal number to;
- add debug assertion to check ref count.

Differential Revision: https://reviews.llvm.org/D96893
2021-02-26 00:44:51 +03:00