Mike Crowe [Sun, 25 Jun 2023 17:38:09 +0000 (17:38 +0000)]
[clang-tidy] Add modernize-printf-to-std-print check
Add FormatStringConverter utility class that is capable of converting
printf-style format strings into std::print-style format strings along
with recording a set of casts to wrap the arguments as required and
removing now-unnecessary calls to std::string::c_str() and
std::string::data()
Use FormatStringConverter to implement a new clang-tidy check that is
capable of converting calls to printf, fprintf, absl::PrintF,
absl::FPrintF, or any functions configured by an option to calls to
std::print and std::println, or other functions configured by options.
In other words, the check turns:
fprintf(stderr, "The %s is %3d\n", description.c_str(), value);
into:
std::println(stderr, "The {} is {:3}", description, value);
if it can.
std::print and std::println can do almost anything that standard printf
can, but the conversion has some some limitations that are described in
the documentation. If conversion is not possible then the call remains
unchanged.
Depends on D153716
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D149280
Mike Crowe [Sun, 25 Jun 2023 16:41:48 +0000 (16:41 +0000)]
[ASTMatchers] Add argumentCountAtLeast narrowing matcher
This will be used by the modernize-use-std-print clang-tidy check and
related checks later.
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D153716
Nico Weber [Sun, 25 Jun 2023 18:32:36 +0000 (14:32 -0400)]
Revert "[COFF] Support -gsplit-dwarf for COFF on Windows"
This reverts commit
3eee5aa528abd67bb6d057e25ce1980d0d38c445.
Breaks tests on mac, see https://reviews.llvm.org/D152785#4447118
Florian Hahn [Sun, 25 Jun 2023 16:07:21 +0000 (17:07 +0100)]
[ConstraintElim] Add tests with condition used in phi.
Add extra tests where conditions are used in phis for D153660.
Florian Hahn [Sun, 25 Jun 2023 15:58:44 +0000 (16:58 +0100)]
[ConstraintElim] Add uses to remark tests to make it more robust.
Add uses of conditions, so the test keeps testing what it is meant to
test after D153660.
Takuya Shimizu [Sun, 25 Jun 2023 15:27:15 +0000 (00:27 +0900)]
[clang][Diagnostics] Provide parameter source range to arity-mismatch notes
Consider the following piece of code:
```
void func( int aa,
int bb,
int cc) {}
void arity_mismatch() {
func(2, 4);
}
```
BEFORE:
```
source.cpp:6:3: error: no matching function for call to 'func'
6 | func(2, 4);
| ^~~~
source.cpp:1:6: note: candidate function not viable: requires 3 arguments, but 2 were provided
1 | void func( int aa,
| ^
```
AFTER:
```
source.cpp:6:3: error: no matching function for call to 'func'
6 | func(2, 4);
| ^~~~
source.cpp:1:6: note: candidate function not viable: requires 3 arguments, but 2 were provided
1 | void func( int aa,
| ^ ~~~~~~~
2 | int bb,
| ~~~~~~~
3 | int cc) {}
| ~~~~~~
```
Reviewed By: cjdb, aaron.ballman
Differential Revision: https://reviews.llvm.org/D153267
Elliot Goodrich [Sun, 25 Jun 2023 15:09:36 +0000 (16:09 +0100)]
Revert "[llvm] Move StringExtras.h include from Error.h to Error.cpp"
This reverts commit
2fa0dbd7bf353db98b27b56137cced0a67de2748.
Elliot Goodrich [Sat, 17 Jun 2023 12:18:23 +0000 (13:18 +0100)]
[llvm] Move StringExtras.h include from Error.h to Error.cpp
Move the implementation of the `toString` function from
`llvm/Support/Error.h` to the source file, which allows us to move
`#include "llvm/ADT/StringExtras.h"` to the source file as well.
As `Error.h` is present in a large number of translation units this
means we are unnecessarily bringing in the contents of
`StringExtras.h` - itself a large file with lots of includes - and
slowing down compilation.
Also move the `#include "llvm/ADT/SmallVector.h"` directive to the
source file as it's no longer needed, but this does not give as much of
a benefit.
This reduces the total number of preprocessing tokens across the LLVM
source files in lib from (roughly) 1,920,413,050 to 1,903,629,230 - a
reduction of ~0.87%. This should result in a small improvement in
compilation time.
Differential Revision: https://reviews.llvm.org/D153229
Elliot Goodrich [Sat, 17 Jun 2023 12:18:23 +0000 (13:18 +0100)]
[llvm] Add missing StringExtras.h includes
In preparation for removing the `#include "llvm/ADT/StringExtras.h"`
from the header to source file of `llvm/Support/Error.h`, first add in
all the missing includes that were previously included transitively
through this header.
Corentin Jabot [Sun, 25 Jun 2023 08:26:30 +0000 (10:26 +0200)]
[Clang][NFC] Add feature test macro checks for C++2c
Craig Topper [Sun, 25 Jun 2023 07:48:26 +0000 (00:48 -0700)]
[RISCV] Add missing Read classes to some compressed instructions.
Reviewed By: wangpc
Differential Revision: https://reviews.llvm.org/D153669
Craig Topper [Sun, 25 Jun 2023 07:47:56 +0000 (00:47 -0700)]
[RISCV] Add GPR bypasses for most scalar integer instructions to the SiFive7 scheduler model.
SiFive7's scalar execution consists of 4 stages AG, M1, M2, WB.
Most simple arithmetic and branch instructions can execute in
either AG or M2.
If the operands are ready, the instruction will execute in the AG
stage. Otherwise, it executes in the M2 stage. Everything is fully
bypassed, so dependent instructions should only see 1 cycle latency.
This patch adds ReadAdvances to pretend that these instructions
execute in the M2 ALU and reads their operands then. This allows
the scheduler to schedule dependent instructions back to back.
I've increased branch latency to 3 since they are also executed in both
stages. Still need to fix JALR, but I want to cleanup some scheduler
classes first.
Multiply, cpop and division instructions can only start in the AG stage.
Still need to do some work for FP instructions that produce integer results.
I've added an llvm-mca test that creates a long dependency chain.
The timeline view can show that things are bypassed. I
didn't check all permutations, but we have some variety.
Reviewed By: wangpc
Differential Revision: https://reviews.llvm.org/D153666
David Green [Sun, 25 Jun 2023 07:44:43 +0000 (08:44 +0100)]
[AArch64] Add SVE tests for double reducts of vector.reduce.fmaximum/fminimum. NFC
Now that the SVE parts are in, we can fill in the double reduction tests
without them causing problems.
Iain Sandoe [Mon, 12 Jun 2023 19:38:02 +0000 (20:38 +0100)]
[C++20][Modules] Complete implementation of module.import p7.
The following test fails to compile TU b.cpp because we are not making the transitively imported modules visible (per [module.import]/p7)
```
a.cppm:
export module a;
export int foo() {
return 42;
}
b.cppm:
export module b;
import a;
export int bar();
b.cpp:
module b;
int bar() {
return foo();
}
clang++ -c -std=c++2b -fmodule-output a.cppm
clang++ -c -std=c++2b -fmodule-output -fprebuilt-module-path=. b.cppm
clang++ -c -std=c++2b -fprebuilt-module-path=. b.cpp
b.cpp:4:12: error: declaration of 'foo' must be imported from module 'a' before it is required
return foo();
```
This is fixed by the following patch (which also addresses a FIXME in basic.def.odr/p6.cppm).
Differential Revision: https://reviews.llvm.org/D152746
Fangrui Song [Sun, 25 Jun 2023 05:44:06 +0000 (22:44 -0700)]
[BPF] Remove unused legacy passes after TargetMachine::adjustPassManager removal
D137796 made these passes unused.
`opt --bpf-ir-peephole` is specified in one test. Add a `registerPipelineParsingCallback`
so that we can use change the test to use `opt --passes=bpf-ir-peephole` instead.
Haohai Wen [Sun, 25 Jun 2023 03:54:23 +0000 (11:54 +0800)]
[COFF] Support -gsplit-dwarf for COFF on Windows
D152340 has split WinCOFFObjectWriter to WinCOFFWriter. This patch adds
another WinCOFFWriter as DwoWriter to write Dwo sections to dwo file.
Driver options are also updated accordingly to support -gsplit-dwarf in
CL mode.
e.g. $ clang-cl -c -gdwarf -gsplit-dwarf foo.c
Like what -gsplit-dwarf did in ELF, using this option will create DWARF object
(.dwo) file. DWARF debug info is split between COFF object and DWARF object
file. It can reduce the executable file size especially for large project.
Reviewed By: skan, MaskRay
Differential Revision: https://reviews.llvm.org/D152785
Vaibhav Thakkar [Sun, 25 Jun 2023 02:27:10 +0000 (19:27 -0700)]
[clang] Fix pretty-printing for variables declared in a for-loop condition
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D153699
Shao-Ce SUN [Sat, 24 Jun 2023 15:04:49 +0000 (23:04 +0800)]
[flang] Rename remaining `__Fortran_PPC_intrinsics` to `__ppc_intrinsics`
Reviewed By: kkwli0
Differential Revision: https://reviews.llvm.org/D153703
Amaury Séchet [Sun, 25 Jun 2023 01:27:29 +0000 (01:27 +0000)]
[NFC] Autogenerate CodeGen/PowerPC/select-i1-vs-i1.ll
Amaury Séchet [Sun, 25 Jun 2023 01:05:21 +0000 (01:05 +0000)]
[NFC] Autogenerate CodeGen/ARM/2013-07-29-vector-or-combine.ll
Amaury Séchet [Sun, 25 Jun 2023 01:02:49 +0000 (01:02 +0000)]
[NFC] Autogenerate CodeGen/ARM/2011-03-15-LdStMultipleBug.ll
Amaury Séchet [Sun, 25 Jun 2023 00:55:03 +0000 (00:55 +0000)]
[NFC] Autogenerate CodeGen/ARM/and-sext-combine.ll
Amaury Séchet [Sun, 25 Jun 2023 00:44:30 +0000 (00:44 +0000)]
[NFC] Autogenerate CodeGen/ARM/machine-cse-cmp.ll
Amaury Séchet [Sun, 25 Jun 2023 00:14:07 +0000 (00:14 +0000)]
[NFC] Autogenerate CodeGen/ARM/pr35103.ll
yronglin [Sun, 25 Jun 2023 00:14:55 +0000 (08:14 +0800)]
[libc++][ranges] Implement P2494R2 (Relaxing range adaptors to allow for move only types)
Implement P2494R2 `Relaxing range adaptors to allow for move only types`
https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2494r2.html#wording-ftm
According to the words in P2494R2, I haven't add new test for `drop_while_view`, `take_while_view` and `filter_view`, because these views has the requirement that the predicate is an `indirect_unary_predicate`, which requires that the predicate is `copy_constructible`, so they still can't accept move only types as predicate.
```
[P2483R0] also suggests future work to relax the requirements on the predicate types stored by standard views. This paper does not perform this relaxation, as the copy constructibility requirement is enshrined in the indirect callable concepts ([indirectcallable.indirectinvocable]). Thus, while this paper modifies the views that currently use copyable-box for user provided predicates, it only does so to apply the rename of the exposition-only type to movable-box; it does not change any of the constraints on those views. It does, however, relax the requirements on invocables accepted by the transform family of views, because those are not constrained using the indirect callable concepts.
```
Reviewed By: #libc, var-const
Differential Revision: https://reviews.llvm.org/D151629
Jacques Pienaar [Sun, 25 Jun 2023 00:03:37 +0000 (17:03 -0700)]
[mlir][polyapprox] Use llvm::numbers for constants.
Fixes windows build.
Dave Lee [Sat, 24 Jun 2023 22:00:38 +0000 (15:00 -0700)]
[lldb] Use LLDB_LOGF for printf format strings in AppleObjCDeclVendor.cpp
Fangrui Song [Sat, 24 Jun 2023 18:07:12 +0000 (11:07 -0700)]
[DWARF] Remove remnant .zdebug section recognition
There is a minor behavior difference that is not worth testing for the obsoleted
format. Previously, llvm-dwarfdump considers .zdebug_info as a debug section but
does not decompress it, leading to a warning when the content cannot be parsed.
Now llvm-dwarfdump just ignores the section without a warning.
Ian Anderson [Mon, 5 Jun 2023 22:08:54 +0000 (15:08 -0700)]
[libc++] Remove the type_traits includes from limits and new
type_traits is currently unable to include __type_traits/noexcept_move_assign_container.h, because it would cause several include cycles.
type_traits -> __type_traits/noexcept_move_assign_container.h -> __memory/allocator_traits.h -> __memory/construct_at.h -> new -> exception -> type_traits
type_traits -> __type_traits/noexcept_move_assign_container.h -> __memory/allocator_traits.h -> __memory/construct_at.h -> new -> type_traits
type_traits -> __type_traits/noexcept_move_assign_container.h -> __memory/allocator_traits.h -> limits -> type_traits
This is a problem for clang modules after the std mega module is broken up (D144322), because it becomes a module cycle which is a hard error.
Unconditionally remove the type_traits includes from limits and new in all versions, and also remove the exception include from new. (These are already removed in C++23.)
Reviewed By: ldionne, Mordante, #libc
Differential Revision: https://reviews.llvm.org/D153214
Fangrui Song [Sat, 24 Jun 2023 17:06:17 +0000 (10:06 -0700)]
[DWARF] Adjust warning condition for .dwo sections with relocations
D106624 added a .dwo warning (when there are relocations) that may fire for
non-debug sections, e.g. `.rodata.dwo` when there is a data symbol foo in
-fdata-sections mode. Adjust it to only warn for .debug sections.
While here, change the diagnostic to be more conventional
https://llvm.org/docs/CodingStandards.html#error-and-warning-messages and use
the relocated section name instead of the relocation section name.
This change does not handle `.zdebug` (support was mostly removed from LLVM) or
`__debug` (Mach-O, no DWO support).
Reviewed By: ayermolo, HaohaiWen
Differential Revision: https://reviews.llvm.org/D153602
Shao-Ce SUN [Sat, 24 Jun 2023 16:32:42 +0000 (00:32 +0800)]
[openmp] remove initializeRewriteSymbolsLegacyPassPass
Fix build error caused by D153679
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D153704
Piotr Fusik [Sat, 24 Jun 2023 16:27:06 +0000 (18:27 +0200)]
[libc++] Add noexcept clauses to swap per P0408R7 (Efficient Access to basic_stringbuf's Buffer)
Reviewed By: #libc, Mordante
Differential Revision: https://reviews.llvm.org/D153427
Thorsten Schütt [Sat, 24 Jun 2023 05:36:23 +0000 (07:36 +0200)]
[GlobalIsel][X86]] Legalize G_CONSTANT_FOLD_BARRIER
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D153684
Hristo Hristov [Mon, 19 Jun 2023 17:45:03 +0000 (20:45 +0300)]
[libc++][ranges] Addresses: LWG3719 - Directory iterators should be usable with default sentinel
Addresses: LWG3719 - Directory iterators should be usable with default sentinel
https://wg21.link/LWG3719
Reviewed By: #libc, Mordante
Differential Revision: https://reviews.llvm.org/D153299
Nathan James [Sat, 24 Jun 2023 14:18:20 +0000 (14:18 +0000)]
[clang-tidy] Fix false negative in readability-convert-member-functions-to-static
A nested class in a member function can erroneously confuse the check into
thinking that any CXXThisExpr found relate to the outer class, preventing any warnings.
Fix this by not traversing any nested classes.
Fixes https://github.com/llvm/llvm-project/issues/56765
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D130665
Kazu Hirata [Sat, 24 Jun 2023 14:33:54 +0000 (07:33 -0700)]
[CodeGen] Remove unused forward declaration Value
The last use was removed by:
commit
7d894374551f6d5787db0aef2da8dd6aefa616fb
Author: OCHyams <orlando.hyams@sony.com>
Date: Thu Mar 16 08:48:36 2023 +0000
Kazu Hirata [Sat, 24 Jun 2023 14:33:52 +0000 (07:33 -0700)]
[CodeGen] Remove unused forward declarations Instruction and Type
The last uses were removed by:
commit
79b3f0823e562fc652c3272b2ccfb99174445fa6
Author: Tim Northover <tnorthover@apple.com>
Date: Tue Feb 7 11:28:00 2023 +0000
Kazu Hirata [Sat, 24 Jun 2023 14:33:50 +0000 (07:33 -0700)]
[LegacyPM] Remove RewriteSymbolsLegacyPass
Differential Revision: https://reviews.llvm.org/D153679
Kazu Hirata [Sat, 24 Jun 2023 14:33:49 +0000 (07:33 -0700)]
[LegacyPM] Remove PlaceSafepointsLegacyPass
Differential Revision: https://reviews.llvm.org/D153678
Kazu Hirata [Sat, 24 Jun 2023 13:59:52 +0000 (06:59 -0700)]
[CodeGen] Remove unused forward declaration DominatorTree
The last use was removed by:
commit
73523021d0a97c150a76a5cf4a91e99cd03b9efb
Author: Chandler Carruth <chandlerc@gmail.com>
Date: Mon Jan 13 13:07:17 2014 +0000
Kazu Hirata [Sat, 24 Jun 2023 13:59:50 +0000 (06:59 -0700)]
[Analysis] Remove unused forward declaration PhiValues
The last use was removed by:
commit
243acd5dcbc637e477062877185ad76d8ff63d9d
Author: Nikita Popov <npopov@redhat.com>
Date: Fri Dec 9 15:29:35 2022 +0100
Kazu Hirata [Sat, 24 Jun 2023 13:59:49 +0000 (06:59 -0700)]
[Analysis] Remove unused forward declaration GetElementPtrInst
The last use was removed by:
commit
2d79b713663169b3732fcbdf56cac243b5c41e28
Author: Philip Reames <preames@rivosinc.com>
Date: Thu Apr 6 08:23:08 2023 -0700
Kazu Hirata [Sat, 24 Jun 2023 13:59:47 +0000 (06:59 -0700)]
[Analysis] Remove unused forward declaration BasicAAResult
The last use was removed by:
commit
f9b523ebc367f1535bf61797383471e567b24b75
Author: Kazu Hirata <kazu@google.com>
Date: Wed May 31 07:30:14 2023 -0700
LLVM GN Syncbot [Sat, 24 Jun 2023 11:01:56 +0000 (11:01 +0000)]
[gn build] Port
7f6e0052a97f
Piotr Zegar [Sat, 24 Jun 2023 10:59:30 +0000 (10:59 +0000)]
[clang-tidy] Add misc-header-include-cycle check
Check detects cyclic #include dependencies between user-defined headers.
Reviewed By: njames93
Differential Revision: https://reviews.llvm.org/D144828
David Green [Sat, 24 Jun 2023 10:12:58 +0000 (11:12 +0100)]
[AArch64] Add SVE lowering for vector.reduce.fminimum and fmaximum
Following what is already performed for vector.reduce.fmin/fmax, this adds
lowering for the new vector.reduce.fminimum/fmaximum nodes to the SVE fminv
and fmaxv instructions via the existing FMINV_PRED/FMAXV_PRED nodes.
Differential Revision: https://reviews.llvm.org/D153288
Piotr Zegar [Sat, 24 Jun 2023 08:41:52 +0000 (08:41 +0000)]
Revert "[clang-tidy] Add misc-header-include-cycle check"
This reverts commit
f3aa6cc0f5d56752242203c2a9231c1bc230c15e.
Piotr Zegar [Sat, 24 Jun 2023 07:01:32 +0000 (07:01 +0000)]
[clang-tidy] Add misc-header-include-cycle check
Check detects cyclic #include dependencies between user-defined headers.
Reviewed By: njames93
Differential Revision: https://reviews.llvm.org/D144828
Iain Sandoe [Wed, 14 Jun 2023 18:48:04 +0000 (19:48 +0100)]
[C++20][Modules] Implement P2615R1 revised export diagnostics.
It has been reported to that the current clang errors for, specifically,
static_assert in export contexts are a serious blocker to adoption of
modules in some cases.
There is also implementation divergence with GCC and MSVC allowing the
constructs mentioned below where clang currently rejects them with an
error.
The category of errors [for declarations in an exported context] is:
(unnamed, static_assert, empty and asm decls). These are now permitted
after P2615R1 which was approved by WG21 as a DR (and thus should be
applied to C++20 as well).
This patch removes these diagnostics and amends the testsuite accordingly.
Differential Revision: https://reviews.llvm.org/D152946
Johannes Doerfert [Sat, 24 Jun 2023 07:24:02 +0000 (00:24 -0700)]
[Attributor] Avoid more AAs through IR implication
Johannes Doerfert [Sat, 24 Jun 2023 07:25:22 +0000 (00:25 -0700)]
[Attributor] Avoid uninitialized memory read.
Kazu Hirata [Sat, 24 Jun 2023 07:00:06 +0000 (00:00 -0700)]
[Support] Remove countLeadingZeros, countPopulation, etc
These functions have been deprecated since:
commit
ec116ea684b43aadfdda03cea2c2a86423e3fc27
Author: Kazu Hirata <kazu@google.com>
Date: Sun Feb 12 12:11:51 2023 -0800
Differential Revision: https://reviews.llvm.org/D153686
Pedro Falcato [Sat, 24 Jun 2023 05:45:17 +0000 (22:45 -0700)]
[clang] Add -fcheck-new support
Add -fcheck-new and -fno-check-new, from GCC, which make the compiler
not assume pointers returned from operator new are non-null.
Fixes #16931.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D125272
Vitaly Buka [Sat, 24 Jun 2023 04:10:26 +0000 (21:10 -0700)]
[test][MSAN] Fix test by printing action before execution it
We expect log messages from enother thread triggered by actions.
Thorsten Schütt [Fri, 23 Jun 2023 16:36:59 +0000 (18:36 +0200)]
[GlobalIsel][X86] G_STORE extension
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D153643
Johannes Doerfert [Fri, 23 Jun 2023 22:00:48 +0000 (15:00 -0700)]
[Attributor][FIX] Do not ignore refinement for IPO
This is just a cleanup commit, a follow up will make this way more
structured.
Johannes Doerfert [Fri, 23 Jun 2023 20:08:57 +0000 (13:08 -0700)]
[Attributor] Avoid the type check in getCalledFunction
We now consistently use `CallBase::getCalledOperand` rather than
`getCalledFunction`, as we do not want the type checked performed by the
latter. This exposed various missing checks to handle mismatches
properly, but it is good to have them explicit now.
In a follow up we might want to flag certain calls as UB, but for now,
we allow everything to cut down on unexpected differences.
Kai Sasaki [Sat, 24 Jun 2023 02:43:40 +0000 (02:43 +0000)]
[mlir] Replace HTML escaped character
Youngsuk Kim [Sat, 24 Jun 2023 01:52:43 +0000 (21:52 -0400)]
[llvm] Replace use of Type::getPointerTo() (NFC)
Partial progress towards replacing in-tree uses of
`Type::getPointerTo()`.
If `getPointerTo()` is used solely to support an unnecessary bitcast,
remove the bitcast.
Reviewed By: barannikov88, nikic
Differential Revision: https://reviews.llvm.org/D153307
Mehdi Amini [Sat, 24 Jun 2023 01:15:47 +0000 (03:15 +0200)]
Improve fatal error message when handling promised interfaces
When initializing DialectInterfaceCollection, we wouldn't have the missing
interface name in the error.
Differential Revision: https://reviews.llvm.org/D153676
Mehdi Amini [Sat, 24 Jun 2023 01:46:10 +0000 (03:46 +0200)]
Add missing dependent dialects to AsyncToAsyncRuntimePass and GpuKernelOutliningPass
These aren't detected during testing most of the time because the way we
are setting up mlir-opt and the fact that we always use func.func: it'll
trigger the load of the InlinerInterface extension for the FuncDialect which
itself loads these dialects unconditionally.
Fangrui Song [Sat, 24 Jun 2023 01:44:31 +0000 (18:44 -0700)]
[XRay][AArch64] Add .size directive
Kazu Hirata [Sat, 24 Jun 2023 01:26:17 +0000 (18:26 -0700)]
[LegacyPM] Remove unused declarations createLowerMatrixIntrinsicsPass and createLowerMatrixIntrinsicsMinimalPass
The corresponding function definitions were removed by:
commit
2764322912c1fe767831ebfd195118e8534e21aa
Author: Kazu Hirata <kazu@google.com>
Date: Fri Jun 23 01:32:38 2023 -0700
Kazu Hirata [Sat, 24 Jun 2023 01:26:16 +0000 (18:26 -0700)]
[LegacyPM] Remove unused declaration initializeStripSymbolsPass
The corresponding function definition was removed by:
commit
15977742d3ebba05a33a8eac3201ebba9c9f10e3
Author: Arthur Eubanks <aeubanks@google.com>
Date: Tue Dec 20 13:36:20 2022 -0800
Kazu Hirata [Sat, 24 Jun 2023 01:26:14 +0000 (18:26 -0700)]
[LegacyPM] Remove unused declarations initializeCrossDSOCFIPass and initializeGlobalSplitPass
The corresponding function definitions were removed by:
commit
c8b8d6baddf9a744594a69e9fb266b724e2e99b2
Author: Arthur Eubanks <aeubanks@google.com>
Date: Thu Feb 9 17:22:56 2023 -0800
Kazu Hirata [Sat, 24 Jun 2023 01:26:12 +0000 (18:26 -0700)]
[LegacyPM] Remove unused declarations initializeCorrelatedValuePropagationPass and initializeJumpThreadingPass
The corresponding function definitions were removed by:
commit
7c3c981442b11153ac1a2be678db727ff715253b
Author: Arthur Eubanks <aeubanks@google.com>
Date: Wed Mar 8 15:07:17 2023 -0800
LLVM GN Syncbot [Sat, 24 Jun 2023 01:16:38 +0000 (01:16 +0000)]
[gn build] Port
6085eb308491
Alex Brachet [Sat, 24 Jun 2023 01:15:50 +0000 (01:15 +0000)]
Revert "Reland [llvm] Preliminary fat-lto-objects support"
This reverts commit
44265dc3554ef40920b587eeb787a400663af6c7.
varconst [Sat, 24 Jun 2023 01:10:03 +0000 (18:10 -0700)]
[libc++][NFC] Fix incorrect return type of `operator<=>` in `span` test code.
LLVM GN Syncbot [Sat, 24 Jun 2023 00:59:38 +0000 (00:59 +0000)]
[gn build] Port
c9a8a0e8a9b2
Douglas Yung [Sat, 24 Jun 2023 00:58:22 +0000 (17:58 -0700)]
Revert "[llvm-profdata] Refactoring Sample Profile Reader to increase FDO build speed using MD5 as key to Sample Profile map"
This reverts commit
31af18bccea95fe1ae8aa2c51cf7c8e92a1c208e.
This change is causing build failures on many Windows build bots:
https://lab.llvm.org/buildbot/#/builders/216/builds/22833
https://lab.llvm.org/buildbot/#/builders/123/builds/19602
https://lab.llvm.org/buildbot/#/builders/172/builds/28315
https://lab.llvm.org/buildbot/#/builders/119/builds/13870
https://lab.llvm.org/buildbot/#/builders/233/builds/794
https://lab.llvm.org/buildbot/#/builders/235/builds/387
https://lab.llvm.org/buildbot/#/builders/13/builds/36921
https://lab.llvm.org/buildbot/#/builders/127/builds/50510
Douglas Yung [Sat, 24 Jun 2023 00:57:37 +0000 (17:57 -0700)]
Revert "[llvm-profdata] Fix mixed-sign comparison warnings"
This reverts commit
a2e7f26160359ed3913badb5acdd05aa8c663b46.
The original patch (31af18b) will be reverted, so reverting this follow-up patch first.
Robert Suderman [Fri, 23 Jun 2023 23:54:48 +0000 (16:54 -0700)]
[mlir][math] Improved math.atan approximation
Used the cephes numerical approximation for `math.atan`. This is a
significant accuracy improvement over the previous taylor series
approximation.
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D153656
Alex Bradbury [Sat, 24 Jun 2023 00:04:56 +0000 (17:04 -0700)]
Recommit "[RISCV] Implement support for bf16 truncate/extend on hard FP targets"
Without the changes from D153598.
Original commit message:
For the same reasons as D151284, this requires custom lowering of the
truncate libcall on hard float ABIs (the normal libcall code path is
used on soft ABIs).
The extend operation is implemented by a shift just as in the standard
legalisation, but needs to be custom lowered because i32 isn't a legal
type on RV64.
This patch aims to make the minimal changes that result in correct
codegen for the bfloat.ll tests.
Differential Revision: https://reviews.llvm.org/D151663
Craig Topper [Sat, 24 Jun 2023 00:01:28 +0000 (17:01 -0700)]
[RISCV] Use binary search on the extension tables in RISCVISAInfo.cpp. NFC
After D153170 the tables are now sorted by extension name so we can use that to
avoid a linear search.
Reviewed By: asb, MaskRay
Differential Revision: https://reviews.llvm.org/D153598
Craig Topper [Sat, 24 Jun 2023 00:00:11 +0000 (17:00 -0700)]
Revert "[RISCV] Implement support for bf16 truncate/extend on hard FP targets"
This was committed with D153598 merged into it. Reverting to recommit as separate patches.
This reverts commit
690b1c847f0b188202a86dc25a0a76fd8c4618f4.
Johannes Doerfert [Sat, 24 Jun 2023 00:06:47 +0000 (17:06 -0700)]
[Attributor][NFC] Avoid string concat for non-tracing runs
Johannes Doerfert [Tue, 20 Jun 2023 05:59:31 +0000 (22:59 -0700)]
[Attributor] Check IR attributes before creating new AAs
Instead of creating an AA for an IR attribute we can first check if it
is implied/known. If so, we can save the time to create the AA, figure
out it is implied, fix it, and later manifest it in the IR
(redundantly). Other IR attributes can be added to the list in
`AA::hasAssumedIRAttr` later on, for now we support 8 different ones.
Johannes Doerfert [Fri, 23 Jun 2023 02:21:02 +0000 (19:21 -0700)]
[Attributor][NFCI] Use pointers to pass around AAs
This will make it easier to create less trivial AAs in the future as we
can simply return `nullptr` rather than an AA with in invalid state.
LLVM GN Syncbot [Sat, 24 Jun 2023 00:07:35 +0000 (00:07 +0000)]
[gn build] Port
44265dc3554e
Teresa Johnson [Fri, 23 Jun 2023 18:01:22 +0000 (11:01 -0700)]
[LTO][GlobalDCE] Use pass parameter instead of module flag for LTO phase
D63932 added a module flag to indicate that we are executing the regular
LTO post merge pipeline, so that GlobalDCE could perform more aggressive
optimization for Dead Virtual Function Elimination. This caused issues
trying to reuse bitcode that had already been through the LTO pipeline
(see context in D139816).
Instead support this by passing down a parameter flag to the
GlobalDCEPass constructor, which is the more usual way for indicating
this information.
Most test changes are to remove incidental uses of this flag. Of the 2
real uses, llvm/test/LTO/ARM/lto-linking-metadata.ll is now obsolete and
removed in this patch, and the virtual-functions-visibility-post-lto.ll
test is updated to use the regular LTO default pipeline where this
parameter is set to true.
Differential Revision: https://reviews.llvm.org/D153655
Craig Topper [Fri, 23 Jun 2023 23:52:45 +0000 (16:52 -0700)]
[RISCV] Split ReadSFB into ReadSFBJmp and ReadSFBALU.
The operands may need to be available at different times.
Matt Arsenault [Thu, 22 Jun 2023 21:50:59 +0000 (17:50 -0400)]
clang: Add missing cases to elementwise builtin SemaCXX test
Matt Arsenault [Sun, 18 Jun 2023 19:40:43 +0000 (15:40 -0400)]
clang: Add __builtin_elementwise_rint and nearbyint
These are basically the same thing and only differ for strictfp,
so add both for future proofing. Note all the elementwise functions are
currently broken for strictfp, and use non-constrained ops. Add a test
that demonstrates this, but doesn't attempt to fix it.
Hongtao Yu [Thu, 22 Jun 2023 21:02:53 +0000 (14:02 -0700)]
[Pseudo Probe] Remove the assert of allowing only one call probe for a callsite.
Compiler-generated static symbols, such as the global initializers, can shared the same name and can coexist in the binary. As a result, their pseudo probes are all kept in the binary too. This could cause multiple call probes decoded against one callsite, as probes are decoded against there owning functions by name. I'm temporarily disabling an assert to keep the debug build green until we have a better fix.
Reviewed By: wenlei
Differential Revision: https://reviews.llvm.org/D153588
Matt Arsenault [Thu, 22 Jun 2023 18:28:01 +0000 (14:28 -0400)]
clang: Fix elementwise value naming to match instruction
Johannes Doerfert [Thu, 22 Jun 2023 20:11:33 +0000 (13:11 -0700)]
[Attributor][NFC] Allow to restrict the Attributor to cached passes
If the user wants to avoid running additional passes, they can now
initialize the AnalysisGetter accordingly.
Johannes Doerfert [Mon, 19 Jun 2023 21:46:11 +0000 (14:46 -0700)]
[Attributor] Remove the iteration count verification
It was never really useful to track #iterations, though it helped during
the initial development. What we should track, in a follow up, are
potentially #updates. That is also what we should restrict instead of
the #iterations.
Matt Arsenault [Wed, 19 Apr 2023 21:02:23 +0000 (17:02 -0400)]
ValueTracking: Use new version of cannotBeOrderedLessThanZero
Pass all arguments so now assumes work.
Matt Arsenault [Tue, 18 Apr 2023 23:41:56 +0000 (19:41 -0400)]
ValueTracking: Prepare to phase out CannotBeOrderedLessThanZero
Introduce a full featured wrapper around computeKnownFPClass
to start replacing the uses with.
Paul Kirth [Fri, 24 Mar 2023 00:21:51 +0000 (00:21 +0000)]
Reland [llvm] Preliminary fat-lto-objects support
Fat LTO objects contain both LTO compatible IR, as well as generated
object code. This allows users to defer the choice of whether to use LTO
or not to link-time. This is a feature available in GCC for some time,
and makes the existing -ffat-lto-objects flag functional in the same
way as GCC's.
Within LLVM, we add a new EmbedBitcodePass that serializes the module to
the object file, and expose a new pass pipeline for compiling fat
objects. The new pipeline initially clones the module and runs the
selected (Thin)LTOPrelink pipeline, after which it will serialize the
module into a `.llvm.lto` section of an ELF file. When compiling for
(Thin)LTO, this normally the point at which the compiler would emit a
object file containing the bitcode and metadata.
After that point we compile the original module using the
PerModuleDefaultPipeline used for non-LTO compilation. We generate
standard object files at the end of this pipeline, which contain machine
code and the new `.llvm.lto` section containing bitcode.
Since the two pipelines operate on different copies of the module, we
can be sure that the bitcode in the `.llvm.lto` section and object code
in `.text` are congruent with the existing output produced by the
default and LTO pipelines.
Original RFC: https://discourse.llvm.org/t/rfc-ffat-lto-objects-support/63977
Earlier versions of this patch were missing REQUIRES lines for llc
related tests in Transforms/EmbedBitcode. Those tests are now under
CodeGen/X86, which should avoid running the check on unsupported
platforms.
Reviewed By: tejohnson, MaskRay, nikic
Differential Revision: https://reviews.llvm.org/D146776
Sami Tolvanen [Fri, 23 Jun 2023 16:31:42 +0000 (16:31 +0000)]
[RISCV] Implement KCFI operand bundle lowering
With `-fsanitize=kcfi` (Kernel Control-Flow Integrity), Clang emits
"kcfi" operand bundles to indirect call instructions. Similarly to
the target-specific lowering added in D119296, implement KCFI operand
bundle lowering for RISC-V.
This patch disables the generic KCFI pass for RISC-V in Clang, and
adds the KCFI machine function pass in `RISCVPassConfig::addPreSched`
to emit target-specific `KCFI_CHECK` pseudo instructions before calls
that have KCFI operand bundles. The machine function pass also bundles
the instructions to ensure we emit the checks immediately before the
calls, which is not possible with the generic pass.
`KCFI_CHECK` instructions are lowered in `RISCVAsmPrinter` to a
contiguous code sequence that traps if the expected hash in the
operand bundle doesn't match the hash before the target function
address. This patch emits an `ebreak` instruction for error handling
to match the Linux kernel's `BUG()` implementation. Just like for X86,
we also emit trap locations to a `.kcfi_traps` section to support
error handling, as we cannot embed additional information to the trap
instruction itself.
Relands commit
62fa708ceb027713b386c7e0efda994f8bdc27e2 with fixed
tests.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D148385
Mehdi Amini [Fri, 23 Jun 2023 22:44:35 +0000 (00:44 +0200)]
Fix missing return introduced when adding support for properties in MLIR in
5e118f933b659
This is a rarely used API: `matchAndRewrite()` is the usual way of using
patterns.
Matt Arsenault [Mon, 17 Apr 2023 20:33:09 +0000 (16:33 -0400)]
ValueTracking: Handle cannotBeOrderedLessThanZero for fadd
Move cannotBeOrderedLessThanZero logic into computeKnownFPClass.
Kazu Hirata [Fri, 23 Jun 2023 22:21:07 +0000 (15:21 -0700)]
[llvm-profdata] Fix mixed-sign comparison warnings
This patch fixes -Wsign-compare warnings from:
llvm/unittests/tools/llvm-profdata/MD5CollisionTest.cpp:117:3: note:
in instantiation of function template specialization
'testing::internal::EqHelper::Compare<unsigned long, int, nullptr>'
requested here
llvm/unittests/tools/llvm-profdata/MD5CollisionTest.cpp:134:3: note:
in instantiation of function template specialization
'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>'
requested here
llvm/unittests/tools/llvm-profdata/MD5CollisionTest.cpp:144:3: note:
in instantiation of function template specialization
'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>'
requested here
llvm/unittests/tools/llvm-profdata/MD5CollisionTest.cpp:160:3: note:
in instantiation of function template specialization
'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>'
requested here
Vitaly Buka [Fri, 23 Jun 2023 21:57:25 +0000 (14:57 -0700)]
[test][msan] Add test for dc4d9d6
Vitaly Buka [Fri, 23 Jun 2023 00:12:37 +0000 (17:12 -0700)]
[msan] Optimize zeroing allocated memory
Reviewed By: thurston
Differential Revision: https://reviews.llvm.org/D153599
LLVM GN Syncbot [Fri, 23 Jun 2023 21:50:49 +0000 (21:50 +0000)]
[gn build] Port
31af18bccea9
William Huang [Thu, 25 May 2023 03:35:50 +0000 (03:35 +0000)]
[llvm-profdata] Refactoring Sample Profile Reader to increase FDO build speed using MD5 as key to Sample Profile map
This is phase 1 of multiple planned improvements on the sample profile loader. The major change is to use MD5 hash code ((instead of the function itself) as the key to look up the function offset table and the profiles, which significantly reduce the time it takes to construct the map.
The optimization is based on the fact that many practical sample profiles are using MD5 values for function names to reduce profile size, so we shouldn't need to convert the MD5 to a string and then to a SampleContext and use it as the map's key, because it's extremely slow.
Several changes to note:
(1) For non-CS SampleContext, if it is already MD5 string, the hash value will be its integral value, instead of hashing the MD5 again. In phase 2 this is going to be optimized further using a union to represent MD5 function (without converting it to string) and regular function names.
(2) The SampleProfileMap is a wrapper to *map<uint64_t, FunctionSamples>, while providing interface allowing using SampleContext as key, so that existing code still work. It will check for MD5 collision (unlikely but not too unlikely, since we only takes the lower 64 bits) and handle it to at least guarantee compilation correctness (conflicting old profile is dropped, instead of returning an old profile with inconsistent context). Other code should not try to use MD5 as key to access the map directly, because it will not be able to handle MD5 collision at all. (see exception at (5) )
(3) Any SampleProfileMap::emplace() followed by SampleContext assignment if newly inserted, should be replaced with SampleProfileMap::Create(), which does the same thing.
(4) Previously we ensure an invariant that in SampleProfileMap, the key is equal to the Context of the value, for profile map that is eventually being used for output (as in llvm-profdata/llvm-profgen). Since the key became MD5 hash, only the value keeps the context now, in several places where an intermediate SampleProfileMap is created, each new FunctionSample's context is set immediately after insertion, which is necessary to "remember" the context otherwise irretrievable.
(5) When reading a profile, we cache the MD5 values of all functions, because they are used at least twice (one to index into FuncOffsetTable, the other into SampleProfileMap, more if there are additional sections), in this case the SampleProfileMap is directly accessed with MD5 value so that we don't recalculate it each time (expensive)
Performance impact:
When reading a ~1GB extbinary profile (fixed length MD5, not compressed) with 10 million function names and 2.5 million top level functions (non CS functions, each function has varying nesting level from 0 to 20), this patch improves the function offset table loading time by 20%, and improves full profile read by 5%.
Reviewed By: davidxl, snehasish
Differential Revision: https://reviews.llvm.org/D147740
Sami Tolvanen [Fri, 23 Jun 2023 21:42:57 +0000 (21:42 +0000)]
Revert "[RISCV] Implement KCFI operand bundle lowering"
This reverts commit
62fa708ceb027713b386c7e0efda994f8bdc27e2.
Reverting to investigate -verify-machineinstrs errors in MIR tests.