Joseph Huber [Wed, 13 Jul 2022 15:25:31 +0000 (11:25 -0400)]
[CUDA] Allow the new driver to compile CUDA in non-RDC mode
The new driver primarily allows us to support RDC-mode compilations with
proper linking. This is not needed for non-RDC mode compilation, but we
still would like the new driver to be able to handle this mode so we can
transition away from the old driver in the future. This patch adds the
necessary code to support creating a fatbinary for CUDA code generation
as well as removing old assumptions and errors about RDC-mode with the
new driver.
Reviewed By: tra
Differential Revision: https://reviews.llvm.org/D129655
Jez Ng [Thu, 14 Jul 2022 01:13:45 +0000 (21:13 -0400)]
[lld-macho] Enable EH frame relocation / pruning
This just removes the code that gates the logic. The main issue here is
perf impact: without {D122258}, LLD takes a significant perf hit because
it now has to do a lot more work in the input parsing phase. But with
that change to eliminate unnecessary EH frames from input object files,
the perf overhead here is minimal. Concretely, here are the numbers for
some builds as measured on my 16-core Mac Pro:
**chromium_framework**
This is without the use of `-femit-dwarf-unwind=no-compact-unwind`:
base diff difference (95% CI)
sys_time 1.826 ± 0.019 1.962 ± 0.034 [ +6.5% .. +8.4%]
user_time 9.306 ± 0.054 9.926 ± 0.082 [ +6.2% .. +7.1%]
wall_time 8.225 ± 0.068 8.947 ± 0.128 [ +8.0% .. +9.6%]
samples 15 22
With that flag enabled, the regression mostly disappears, as hoped:
base diff difference (95% CI)
sys_time 1.839 ± 0.062 1.866 ± 0.068 [ -0.9% .. +3.8%]
user_time 9.452 ± 0.068 9.490 ± 0.067 [ -0.1% .. +0.9%]
wall_time 8.383 ± 0.127 8.452 ± 0.114 [ -0.1% .. +1.8%]
samples 17 21
**Unnamed internal app**
Without `-femit-dwarf-unwind`, this is the perf hit:
base diff difference (95% CI)
sys_time 1.372 ± 0.029 1.317 ± 0.024 [ -4.6% .. -3.5%]
user_time 2.835 ± 0.028 2.980 ± 0.027 [ +4.8% .. +5.4%]
wall_time 3.205 ± 0.079 3.383 ± 0.066 [ +4.9% .. +6.2%]
samples 102 83
With `-femit-dwarf-unwind`, the perf hit almost disappears:
base diff difference (95% CI)
sys_time 1.274 ± 0.026 1.270 ± 0.025 [ -0.9% .. +0.3%]
user_time 2.812 ± 0.023 2.822 ± 0.035 [ +0.1% .. +0.7%]
wall_time 3.166 ± 0.047 3.174 ± 0.059 [ -0.2% .. +0.7%]
samples 95 97
Just for fun, I measured the impact of `-femit-dwarf-unwind` on ld64
(`base` has the extra DWARF unwind info in the input object files,
`diff` doesn't):
base diff difference (95% CI)
sys_time 1.128 ± 0.010 1.124 ± 0.023 [ -1.3% .. +0.6%]
user_time 7.176 ± 0.030 7.106 ± 0.094 [ -1.5% .. -0.4%]
wall_time 7.874 ± 0.041 7.795 ± 0.121 [ -1.7% .. -0.3%]
samples 16 25
And for LLD:
base diff difference (95% CI)
sys_time 1.315 ± 0.019 1.280 ± 0.019 [ -3.2% .. -2.0%]
user_time 2.980 ± 0.022 2.822 ± 0.016 [ -5.5% .. -5.0%]
wall_time 3.369 ± 0.038 3.175 ± 0.033 [ -6.2% .. -5.3%]
samples 47 47
So parsing the extra EH frames is a lot more expensive for us than for
ld64. But given that we are quite a lot faster than ld64 to begin with,
I guess this isn't entirely unexpected...
Reviewed By: #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D129540
Nico Weber [Tue, 12 Jul 2022 14:54:54 +0000 (10:54 -0400)]
[docs] Document git-clang-format
clang-format's documentation documented the more general clang-format-diff.py
script. Add documentation for the less general but arguably easier-to-use
git integration as well.
Differential Revision: https://reviews.llvm.org/D129563
Nico Weber [Thu, 14 Jul 2022 01:05:36 +0000 (21:05 -0400)]
[gn build] fix building lldb after
b5ccfeb6bfbb
Stefan Pintilie [Wed, 13 Jul 2022 19:08:55 +0000 (14:08 -0500)]
[PowerPC][LLD] Change PPC64R2SaveStub to only use non-PC-relative code
Currently the PPC64R2SaveStub thunk will produce Power 10 code by default.
This produced an issue when linking older code that made use of the st_other=1
bit but was never meant to be linked or run on Power 10.
This patch makes it so that only the R_PPC64_REL24_NOTOC relocation can produce
Power 10 code.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D129580
einvbri [Thu, 7 Jul 2022 09:38:56 +0000 (04:38 -0500)]
[analyzer] Fix use of length in CStringChecker
CStringChecker is using getByteLength to get the length of a string
literal. For targets where a "char" is 8-bits, getByteLength() and
getLength() will be equal for a C string, but for targets where a "char"
is 16-bits getByteLength() returns the size in octets.
This is verified in our downstream target, but we have no way to add a
test case for this case since there is no target supporting 16-bit
"char" upstream. Since this cannot have a test case, I'm asserted this
change is "correct by construction", and visually inspected to be
correct by way of the following example where this was found.
The case that shows this fails using a target with 16-bit chars is here.
getByteLength() for the string literal returns 4, which fails when
checked against "char x[4]". With the change, the string literal is
evaluated to a size of 2 which is a correct number of "char"'s for a
16-bit target.
```
void strcpy_no_overflow_2(char *y) {
char x[4];
strcpy(x, "12"); // with getByteLength(), returns 4 using 16-bit chars
}
```
This change exposed that embedded nulls within the string are not
handled. This is documented as a FIXME for a future fix.
```
void strcpy_no_overflow_3(char *y) {
char x[3];
strcpy(x, "12\0");
}
```
Reviewed By: martong
Differential Revision: https://reviews.llvm.org/D129269
Philip Reames [Thu, 14 Jul 2022 00:12:48 +0000 (17:12 -0700)]
[LSR] Add test coverage for ICmpZero cases involving urem RHS
For the moment, we're pretty conservative here. My motivating case is the vscale one (as that is idiomatic for scalable vectorized loops on RISCV). There are two obvious approaches to fixing this, and I tried to add reasonable coverage for both even though I'll likely only fix one.
Florian Hahn [Thu, 14 Jul 2022 00:01:42 +0000 (17:01 -0700)]
[LV] Use PredRecipe directly instead of getOrAddVPValue (NFC).
There is no need to look up the VPValue for Instr, PredRecipe can be
used directly.
Peter Klausler [Mon, 11 Jul 2022 17:08:01 +0000 (10:08 -0700)]
[flang] Avoid crash from forward referenced derived type
Fortran permits forward references to derived types in contexts that don't
require knowledge of the derived type definition for semantic analysis,
such as in the declaration of a pointer or allocatable variable or component.
But when the forward-referenced derived type is used later for a component
reference, it is possible for the DerivedTypeSpec in he base variable or component
declaration to still have a null scope pointer even if the type has been defined,
since DerivedTypeSpec and TypeSpec objects are created in scopes of use
rather than in scopes of definition. The fix is to call
DerivedTypeSpec::Instantiate() in the name resolution of each component
name so that the scope gets filled in if it is still null.
Differential Revision: https://reviews.llvm.org/D129681
Dave Lee [Sat, 9 Jul 2022 00:34:10 +0000 (17:34 -0700)]
[lldb] Add image dump pcm-info command
Add `pcm-info` to the `target module dump` subcommands.
This dump command shows information about clang .pcm files. This command
effectively runs `clang -module-file-info` and produces identical output.
The .pcm file format is tightly coupled to the clang version. The clang
embedded in lldb is not guaranteed to match the version of the clang executable
available on the local system.
There have been times when I've needed to view the details about a .pcm file
produced by lldb's embedded clang, but because the clang executable was a
slightly different version, the `-module-file-info` invocation failed. With
this command, users can inspect .pcm files generated by lldb too.
Differential Revision: https://reviews.llvm.org/D129456
Peter Klausler [Fri, 8 Jul 2022 23:16:42 +0000 (16:16 -0700)]
[flang] Error detection/avoidance for TRANSFER with empty MOLD= type
When MOLD= is an array and there is no SIZE= in a call to TRANSFER(),
the size of an element of the MOLD= is used as the denominator in a
division to establish the extent of the vector result. When the
total storage size of the SOURCE= is known to be zero, the result is
empty and no division is needed.
To avoid a division by zero at runtime, we need to check for a zero-sized
MOLD= element type when the storage size of SOURCE= is nonzero and there
is no SIZE=. Further, in the compilation-time rewriting of calls to
SHAPE(TRANSFER(...)) and SIZE(TRANSFER(...)) for constant folding and
simplification purposes, we can't replace the call with an arithmetic
element count expression when the storage size of SOURCE= is not known
to be zero and the element size of MOLD= is not known to be nonzero at
compilation time.
These changes mostly affect tests using a MOLD= argument that is an
assumed-length character.
Differential Revision: https://reviews.llvm.org/D129680
Fangrui Song [Wed, 13 Jul 2022 23:47:35 +0000 (16:47 -0700)]
[Support] Fix LLVM_ENABLE_ZLIB==0 builds
owenca [Mon, 11 Jul 2022 06:49:16 +0000 (23:49 -0700)]
[clang-format][NFC] Replace most of std::vector with SmallVector
Differential Revision: https://reviews.llvm.org/D129466
Peter Klausler [Fri, 8 Jul 2022 22:25:01 +0000 (15:25 -0700)]
[flang][runtime] Complete list-directed character input with DECIMAL='COMMA'
Most of the infrastructure for DECIMAL='COMMA' mode was in place
in the I/O runtime support library, but I dropped the ball for
list-directed character input, which has its own detection of
input separators. Finish the job.
Differential Revision: https://reviews.llvm.org/D129679
Peter Klausler [Fri, 8 Jul 2022 21:35:42 +0000 (14:35 -0700)]
[flang] Ensure name resolution visits "=>NULL()" in entity-decl
Most modern Fortran programs declare procedure pointers with a
procedure-declaration-stmt, but it's also possible to declare one
with a type-declaration-stmt with a POINTER attribute. In this
case, e.g. "real, external, pointer :: p => null()" the initializer
is required to be a null-init. The parse tree traversal in name
resolution would visit the null-init if the symbol were an object
pointer only, leading to a crash in the case of a procedure pointer.
That explanation of the bug is longer than the fix. In short,
ensure that a null-init in an entity-decl is visited for both
species of pointers.
Differential Revision: https://reviews.llvm.org/D129676
Fangrui Song [Wed, 13 Jul 2022 23:26:54 +0000 (16:26 -0700)]
[Support] Change compression::zlib::{compress,uncompress} to use uint8_t *
It's more natural to use uint8_t * (std::byte needs C++17 and llvm has
too much uint8_t *) and most callers use uint8_t * instead of char *.
The functions are recently moved into `llvm::compression::zlib::`, so
downstream projects need to make adaption anyway.
Alexander Shaposhnikov [Wed, 13 Jul 2022 23:21:45 +0000 (23:21 +0000)]
[SimplifyCFG] Improve SwitchToLookupTable optimization
Try to use the original value as an index (in the lookup table)
in more cases (to avoid one subtraction and shorten the dependency chain)
(https://github.com/llvm/llvm-project/issues/56189).
Test plan:
1/ ninja check-all
2/ bootstrapped LLVM + Clang pass tests
Differential revision: https://reviews.llvm.org/D128897
Peter Klausler [Thu, 7 Jul 2022 21:51:40 +0000 (14:51 -0700)]
[flang][runtime] Keep frame buffer in sync with file when truncating
When the I/O runtime is truncating an external file due to an
implied ENDFILE or explicit ENDFILE, ensure that the unit's frame
buffer for the file discards any data that have become obsolete.
This bug caused trouble with ACCESS='STREAM' I/O using POS= on
a WRITE, but it may have not been limited to that scenario.
Differential Revision: https://reviews.llvm.org/D129673
Peter Klausler [Thu, 7 Jul 2022 16:32:21 +0000 (09:32 -0700)]
[flang][runtime] Refine list-directed REAL(2) output
The rule used by list-directed REAL output editing to select
between Ew.d and Fw.d output editing breaks down for 16-bit
floating-point data, since the number of significant decimal
digits is so low that Ew,d output editing is nearly always selected.
Cap the test so that five-digit values will be output with Fw.d
editing.
Differential Revision: https://reviews.llvm.org/D129672
Nico Weber [Wed, 13 Jul 2022 22:35:25 +0000 (18:35 -0400)]
[gn build] (semi-manually) Port
5acd47169884
Peter Klausler [Tue, 5 Jul 2022 23:32:59 +0000 (16:32 -0700)]
[flang] Fold TRANSFER()
Fold usage of the raw data reinterpretation intrinsic function TRANSFER().
Differential Revision: https://reviews.llvm.org/D129671
Anubhab Ghosh [Tue, 12 Jul 2022 23:15:19 +0000 (16:15 -0700)]
[ORC] Add a shared-memory based orc::MemoryMapper.
This is an implementation of orc::MemoryMapper that maps shared memory
pages in both executor and controller process and writes directly to
them avoiding transferring content over EPC. All allocations are properly
deinitialized automatically on the executor side at shutdown by the
ExecutorSharedMemoryMapperService.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D128544
Yonghong Song [Tue, 12 Jul 2022 19:21:11 +0000 (12:21 -0700)]
[BPF] Handle anon record for CO-RE relocations
When doing experiment in kernel, for kernel data structure sockptr_t
in CO-RE operation, I hit an assertion error. The sockptr_t definition
and usage look like below:
#pragma clang attribute push (__attribute__((preserve_access_index)), apply_to = record)
typedef struct {
union {
void *kernel;
void *user;
};
unsigned is_kernel : 1;
} sockptr_t;
#pragma clang attribute pop
int test(sockptr_t *arg) {
return arg->is_kernel;
}
The assertion error looks like
clang: ../lib/Target/BPF/BPFAbstractMemberAccess.cpp:878: llvm::Value*
{anonymous}::BPFAbstractMemberAccess::computeBaseAndAccessKey(llvm::CallInst*,
{anonymous}::BPFAbstractMemberAccess::CallInfo&, std::__cxx11::string&,
llvm::MDNode*&): Assertion `TypeName.size()' failed.
In this particular, the clang frontend attach the debuginfo metadata associated
with anon structure with the preserve_access_info IR intrinsic. But the first
debuginfo type has to be a named type so libbpf can have a sound start to
do CO-RE relocation.
Besides the above approach using pragma to push attribute, the below typedef/struct
definition can have preserve_access_index directly applying to the anon struct.
typedef struct {
union {
void *kernel;
void *user;
};
unsigned is_kernel : 1;
} __attribute__((preserve_access_index) sockptr_t;
This patch fixed the issue by preprocessing function argument/return types
and local variable types used by other CO-RE intrinsics. For any
typedef struct/union { ... } typedef_name
an association of <anon struct/union, typedef> is recorded to replace
the IR intrinsic metadata 'anon struct/union' to 'typedef'.
It is possible that two different 'typedef' types may have identical
anon struct/union type. For such a case, the association will be
<anon struct/union, nullptr> to indicate the invalid case.
Differential Revision: https://reviews.llvm.org/D129621
Leonard Chan [Wed, 13 Jul 2022 22:07:59 +0000 (15:07 -0700)]
[hwasan] Add __hwasan_add_frame_record to the hwasan interface
Hwasan includes instructions in the prologue that mix the PC and SP and store
it into the stack ring buffer stored at __hwasan_tls. This is a thread_local
global exposed from the hwasan runtime. However, if TLS-mechanisms or the
hwasan runtime haven't been setup yet, it will be invalid to access __hwasan_tls.
This is the case for Fuchsia where we instrument libc, so some functions that
are instrumented but can run before hwasan initialization will incorrectly
access this global. Additionally, libc cannot have any TLS variables, so we
cannot weakly define __hwasan_tls until the runtime is loaded.
A way we can work around this is by moving the instructions into a hwasan
function that does the store into the ring buffer and creating a weak definition
of that function locally in libc. This way __hwasan_tls will not actually be
referenced. This is not our long-term solution, but this will allow us to roll
out hwasan in the meantime.
This patch includes:
- A new llvm flag for choosing to emit a libcall rather than instructions in the
prologue (off by default)
- The libcall for storing into the ringbuffer (__hwasan_add_frame_record)
Differential Revision: https://reviews.llvm.org/D128387
Cole Kissane [Wed, 13 Jul 2022 22:08:40 +0000 (15:08 -0700)]
[llvm] fix zlib buffer truncate edge cases and fix nits in tests
- add check before truncating (un)compressed data buffer if the buffer is already a perfect length, to avoid triggering truncate assertion in edge case.
- explictly coerce LLVM_ENABLE_ZLIB to a 0 or 1 value in OFF case, to match current ON, FORCE_ON behavior.
- fix code style nits in zlib tests
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D129698
Leonard Chan [Wed, 13 Jul 2022 22:06:07 +0000 (15:06 -0700)]
Revert "[hwasan] Add __hwasan_record_frame_record to the hwasan interface"
This reverts commit
4956620387ee45a48a394853a47ddd65195c4cc6.
This broke a sanitizer builder: https://lab.llvm.org/buildbot/#/builders/77/builds/19597
Amara Emerson [Wed, 13 Jul 2022 21:30:51 +0000 (14:30 -0700)]
[GlobalISel] Fix and(load)->zextload combine crash.
We shouldn't use getOpcodeDef() if we need to guarantee the def has only one
user since under the hood it may look through copies and optimization hints,
which themselves may have multiple users.
Peter Klausler [Fri, 8 Jul 2022 20:38:31 +0000 (13:38 -0700)]
[flang] Refine semantic checks for procedure pointer assignment
Some procedure pointers and EXTERNAL procedures have neither
explicit interfaces nor result types; these procedures are obviously
not known to be functions, but they could be, so semantics must not
assume that they are necessarily subroutines. Refine the procedure
pointer / dummy procedure compatibility check to handle these more
ambiguous cases and not elicit inappropriate error messages.
Differential Revision: https://reviews.llvm.org/D129674
Roy Jacobson [Tue, 12 Jul 2022 19:24:19 +0000 (22:24 +0300)]
[DOC] Add DR1734 and DR1496 Clang's cxx_dr_status as not implemented
Those two DRs about the (copy) triviality of types with deleted special member functions are not implemented in Clang.
Document them as such.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D129583
Florian Hahn [Wed, 13 Jul 2022 21:39:59 +0000 (14:39 -0700)]
[LV] Move VPBranchOnMaskRecipe::execute to VPlanRecipes.cpp (NFC).
Craig Topper [Wed, 13 Jul 2022 19:50:49 +0000 (12:50 -0700)]
[RISCV] Fold (sra (sext_inreg (shl X, C1), i32), C2) -> (sra (shl X, C1+32), C2+32).
The former pattern will select as slliw+sraiw while the latter
will select as slli+srai. This can enable the slli+srai to be
compressed.
Differential Revision: https://reviews.llvm.org/D129688
Maksim Panchenko [Fri, 8 Jul 2022 23:07:13 +0000 (16:07 -0700)]
[docs] Add BOLT Office Hours
Reviewed By: rafauler
Differential Revision: https://reviews.llvm.org/D129408
leonardchan [Wed, 6 Jul 2022 21:47:43 +0000 (05:47 +0800)]
[hwasan] Add __hwasan_record_frame_record to the hwasan interface
Hwasan includes instructions in the prologue that mix the PC and SP and store
it into the stack ring buffer stored at __hwasan_tls. This is a thread_local
global exposed from the hwasan runtime. However, if TLS-mechanisms or the
hwasan runtime haven't been setup yet, it will be invalid to access __hwasan_tls.
This is the case for Fuchsia where we instrument libc, so some functions that
are instrumented but can run before hwasan initialization will incorrectly
access this global. Additionally, libc cannot have any TLS variables, so we
cannot weakly define __hwasan_tls until the runtime is loaded.
A way we can work around this is by moving the instructions into a hwasan
function that does the store into the ring buffer and creating a weak definition
of that function locally in libc. This way __hwasan_tls will not actually be
referenced. This is not our long-term solution, but this will allow us to roll
out hwasan in the meantime.
This patch includes:
- A new llvm flag for choosing to emit a libcall rather than instructions in the
prologue (off by default)
- The libcall for storing into the ringbuffer (__hwasan_record_frame_record)
Differential Revision: https://reviews.llvm.org/D128387
Martin Storsjö [Wed, 13 Jul 2022 20:56:27 +0000 (23:56 +0300)]
[clang][deps] Silence a GCC warning about missing returns after a fully covered switch. NFC.
Martin Storsjö [Wed, 13 Jul 2022 20:56:03 +0000 (23:56 +0300)]
[lldb] Silence a GCC warning about missing returns after a fully covered switch. NFC.
Siva Chandra Reddy [Wed, 13 Jul 2022 20:51:12 +0000 (20:51 +0000)]
[libc][NFC] Make all integration tests depend on the threads implementation.
The integration tests use the loader which sets up the main thread's
self object. So, all integration tests have to depend on the threads
implementation.
Siva Chandra Reddy [Mon, 11 Jul 2022 22:12:47 +0000 (22:12 +0000)]
[libc] Linux threads - Setup TLS area of a new thread and cleanup at exit.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D129543
LLVM GN Syncbot [Wed, 13 Jul 2022 20:38:59 +0000 (20:38 +0000)]
[gn build] Port
3ce78cbd2392
Kazu Hirata [Wed, 13 Jul 2022 20:38:50 +0000 (13:38 -0700)]
[Analysis] clang-format InlineAdvisor.cpp (NFC)
Ben Langmuir [Wed, 13 Jul 2022 19:10:20 +0000 (12:10 -0700)]
[test] Fix macOS triple check
While the inferred host triple for macOS is something like
<arch>-apple-darwin, it's also valid to have <arch>-apple-macos.
Currently that globally changes whether an SDKROOT is provided in tests,
so make this check more portable.
Differential Revision: https://reviews.llvm.org/D129684
Ben Langmuir [Tue, 12 Jul 2022 23:55:11 +0000 (16:55 -0700)]
[clang][deps] Fix handling of -MT in module command-line
Follow-up to
6626f6fec3d3, this fixes the handling of -MT
* If no targets are provided, we need to invent one since cc1 expects
the driver to have handled it. The default is to use -o, quoting as
necessary for a make target.
* Fix the splitting for empty string, which was incorrectly treated as
{""} instead of {}.
* Add a way to test this behaviour in clang-scan-deps.
Differential Revision: https://reviews.llvm.org/D129607
Daniel Bertalan [Sat, 9 Jul 2022 22:05:13 +0000 (00:05 +0200)]
[lld-macho] Accept dylibs with LC_DYLD_EXPORTS_TRIE
This load command specifies the offset and size of the exports trie.
This information used to be a field in LC_DYLD_INFO, but in newer
libraries, it has a dedicated load command: LC_DYLD_EXPORTS_TRIE.
The format of the trie is the same for both load commands, so the code
for parsing it can be shared.
LLD does not generate this yet; it is mainly useful when chained fixups
are in use, as the other members of LC_DYLD_INFO are unused then, so the
smaller LC_DYLD_EXPORTS_TRIE can be output instead.
LLDB gained support for this in D107673.
Fixes #54550
Differential Revision: https://reviews.llvm.org/D129430
LLVM GN Syncbot [Wed, 13 Jul 2022 20:25:34 +0000 (20:25 +0000)]
[gn build] Port
a5c0638dec83
Hui Xie [Mon, 11 Jul 2022 22:39:59 +0000 (23:39 +0100)]
[libc++][ranges] implement `std::ranges::set_symmetric_difference`
[libc++][ranges] implement `std::ranges::set_symmetric_difference`
Differential Revision: https://reviews.llvm.org/D129520
Alex Brachet [Wed, 13 Jul 2022 20:20:30 +0000 (20:20 +0000)]
[libc] Specify rounding mode for strto[f|d] tests
The specified rounding mode will be used and restored
to what it was before the test ran.
Additionally, it moves ForceRoundingMode and RoundingMode
out of MPFRUtils to be used in more places.
Differential Revision: https://reviews.llvm.org/D129685
Roman Rusyaev [Wed, 13 Jul 2022 20:02:32 +0000 (13:02 -0700)]
Change shebang from python to python3 in update_cc_test_checks.py
All update_test_checks.py scripts were updated in this revision
https://reviews.llvm.org/D70730 except for update_cc_test_checks.py.
Reviewed By: barannikov88
Differential Revision: https://reviews.llvm.org/D129590
Joseph Huber [Wed, 13 Jul 2022 19:56:15 +0000 (15:56 -0400)]
[CUDA][HIP][NFC] Do not add `-fgpu-rdc` flag twice
Summary:
We currently add the `-fgpu-rdc` flag twice. Once unconditionally for
both the host and device phases of compilation, and a second time only
for the host. When we moved to an unconditional addition of this flag it
the old one was most likely not removed. This patch simply removes the
redundant flag and changes no functionality.
Craig Topper [Wed, 13 Jul 2022 19:45:18 +0000 (12:45 -0700)]
[RISCV] Add test case show missed opportunity to turn slliw+sraiw into slli+srai.
slliw and sraiw have no compressed encodings. slli and srai
do have compressed encodings.
Pre-commit for D129688
Joseph Huber [Wed, 13 Jul 2022 19:44:08 +0000 (15:44 -0400)]
[LinkerWrapper] Fix deleted constructor error on older compilers
Summary:
The previous patch moved some functoinality into a new function and
returned it. The vector contained move-only members. Newer compilers
should figure this out and I didn't notice any problems, but other ones
have problems. Explicitly move this vector to hopefully solve the issue.
Jolanta Jensen [Fri, 8 Jul 2022 13:55:08 +0000 (14:55 +0100)]
[NFC] Minor cleanup of usage of FloatModeKind with bitmask enums
Differential Revision: https://reviews.llvm.org/D129373
Joseph Huber [Wed, 13 Jul 2022 18:55:55 +0000 (14:55 -0400)]
[LinkerWrapper] Support time tracing in the linker wrapper
Summary:
This patch adds the new `--wrapper-time-trace=` option to write a time
tracing JSON file indicating where time was spent in the linker wrapper.
We also reformat and group some of the existing code to make
constraining the scope easier for time tracing. We use the `--wrapper`
prefix to set this apart from the time tracing that lld may use.
Joseph Huber [Wed, 13 Jul 2022 17:35:39 +0000 (13:35 -0400)]
[LinkerWrapper] Add support for timescope tracing
Zarko Todorovski [Wed, 13 Jul 2022 19:32:16 +0000 (15:32 -0400)]
[Clang][Sema][AIX][PowerPC] Emit byval alignment warning only when struct is passed to a function
Previous warning went on whenever a struct with a struct member with alignment => 16
was declared. This led to too many false positives and led to diagnostic lit failures
due to it being emitted too frequently. Only emit the warning when such a struct and
that struct contains a member that has an alignment of 16 bytes is passed to a caller
function since this is where the potential binary compatibility issue with XL 16.1.0
and older exists.
Reviewed By: sfertile, aaron.ballman
Differential Revision: https://reviews.llvm.org/D118350
ymeng [Thu, 7 Jul 2022 13:52:04 +0000 (06:52 -0700)]
[trace][intel pt] Support dumping the trace info in json
Thanks to ymeng@fb.com for coming up with this change.
`thread trace dump info` can dump some metrics that can be useful for
analyzing the performance and quality of a trace. This diff adds a --json
option for dumping this information in json format that can be easily
understood my machines.
Differential Revision: https://reviews.llvm.org/D129332
Gaurav Gaur [Wed, 29 Jun 2022 20:09:12 +0000 (13:09 -0700)]
[trace][intel pt] Add a cgroup filter
It turns out that cgroup filtering is relatively trivial and works
really nicely. Thid diffs adds automatic cgroup filtering when in
per-cpu mode, unless a new --disable-cgroup-filtering flag is passed in
the start command. At least on Meta machines, all processes are spawned
inside a cgroup by default, which comes super handy, because per cpu
tracing is now much more precise.
A manual test gave me this result
- Without filtering:
Total number of trace items: 36083
Total number of continuous executions found: 229
Number of continuous executions for this thread: 2
Total number of PSB blocks found: 98
Number of PSB blocks for this thread 2
Total number of unattributed PSB blocks found: 38
- With filtering:
Total number of trace items: 87756
Total number of continuous executions found: 123
Number of continuous executions for this thread: 2
Total number of PSB blocks found: 10
Number of PSB blocks for this thread 3
Total number of unattributed PSB blocks found: 2
Filtering gives us great results. The number of instructions collected
more than double (probalby because we have less noise in the trace), and
we have much less unattributed PSBs blocks and unrelated PSBs in
general. The ones that are unrelated probably belong to other processes
in the same cgroup.
Differential Revision: https://reviews.llvm.org/D129257
Walter Erquinigo [Fri, 8 Jul 2022 01:31:18 +0000 (18:31 -0700)]
[trace][intel pt] Create a CPU change event and expose it in the dumper
Thanks to fredzhou@fb.com for coming up with this feature.
When tracing in per-cpu mode, we have information of in which cpu we are execution each instruction, which comes from the context switch trace. This diff makes this information available as a `cpu changed event`, which an additional accessor in the cursor `GetCPU()`. As cpu changes are very infrequent, any consumer should listen to cpu change events instead of querying the actual cpu of a trace item. Once a cpu change event is seen, the consumer can invoke GetCPU() to get that information. Also, it's possible to invoke GetCPU() on an arbitrary instruction item, which will return the last cpu seen. However, this call is O(logn) and should be used sparingly.
Manually tested with a sample program that starts on cpu 52, then goes to 18, and then goes back to 52.
Differential Revision: https://reviews.llvm.org/D129340
Manish Gupta [Wed, 13 Jul 2022 17:53:52 +0000 (17:53 +0000)]
[mlir][NVGPU] Verifiers for nvgpu.mma.sync Op
- Adds verification for `nvgpu.mma.sync` op
- Adds tests to `mlir/test/Dialect/NVGPU/invalid.mlir`
- `nvgpu.mma.sync` verifier caught a bug and triggered a failure in m16n8k4_tf32_f32 variant in `mlir/test/Conversion/NVGPUToNVVM/nvgpu-to-nvvm.mlir`
- The output shape of vector holding thread-level accumulators was inconsistent and fixed in this change
Reviewed By: ThomasRaoux
Differential Revision: https://reviews.llvm.org/D129400
Roy Sundahl [Mon, 11 Jul 2022 02:55:10 +0000 (19:55 -0700)]
[asan][ubsan][test] Add weak attributes for dyld Mach-O weak-def-coalescing
Apple's dynamic linker won't weak-def_coalesce from a file unless there is
at least one weak symbol in the compilation unit so local __ubsan_on_report
never has the chance to override the weak one even though the dynamic linker
may see it first. This works around the issue by adding an unused weak symbol.
(Amended: Remove excessive clang-format artifacts)
rdar://
95244261
Differential Revision: https://reviews.llvm.org/D127929
Walter Erquinigo [Wed, 6 Jul 2022 23:05:25 +0000 (16:05 -0700)]
[trace] Add an option to save a compact trace bundle
A trace bundle contains many trace files, and, in the case of intel pt, the
largest files are often the context switch traces because they are not
compressed by default. As a way to improve this, I'm adding a --compact option
to the `trace save` command that filters out unwanted processes from the
context switch traces. Eventually we can do the same for intel pt traces as
well.
Differential Revision: https://reviews.llvm.org/D129239
Alex Bradbury [Wed, 13 Jul 2022 18:34:46 +0000 (19:34 +0100)]
[RISCV][test][NFC] Regenerate RISC-V tests with update_llc_test_checks.py -u
If a change alters more than a couple of tests it's really handy to be
able to regenerate any that were created by update_llc_test_checks.py
with something like `update_llc_test_checks.py -u
llvm/test/CodeGen/RISCV`. I noticed this causes some extraneous changes
(perhaps due to hand editing). This commit addresses that by updating
any fails that are modified by update_llc_test_checks.py -u.
LLVM GN Syncbot [Wed, 13 Jul 2022 18:31:08 +0000 (18:31 +0000)]
[gn build] Port
101d1e9b3c86
Nikolas Klauser [Wed, 13 Jul 2022 16:07:26 +0000 (18:07 +0200)]
[libc++] Implement ranges::find_end, ranges::search{, _n}
Reviewed By: var-const, #libc, huixie90
Spies: thakis, h-vetinari, huixie90, libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/D124079
Steve Scalpone [Wed, 13 Jul 2022 18:21:01 +0000 (11:21 -0700)]
[flang] Document the Intrinsic Types
Describe the built-in integer, real, complex and logical
types implemented in flang, capturing the as-implemented
characteristics.
Differential Revision: https://reviews.llvm.org/D129658
Florian Hahn [Wed, 13 Jul 2022 18:13:21 +0000 (11:13 -0700)]
[GlobalOpt] Add more tests with large number of stores to globals.
Add a few more test cases for D129525.
Peicong Wu [Wed, 29 Jun 2022 18:42:14 +0000 (11:42 -0700)]
[trace][intel pt] Measure the time it takes to decode a thread in per-cpu mode
This metric was missing. We were only measuring in per-thread mode, and
this completes the work.
For a sample trace I have, the `dump info` command shows
```
Timing for this thread:
Decoding instructions: 0.12s
```
I also improved a bit the TaskTime function so that callers don't need to
specify the template argument
Differential Revision: https://reviews.llvm.org/D129249
Philip Reames [Tue, 12 Jul 2022 20:47:07 +0000 (13:47 -0700)]
[RISCV] Exploit fact that vscale is always power of two to replace urem sequence
When doing scalable vectorization, the loop vectorizer uses a urem in the computation of the vector trip count. The RHS of that urem is a (possibly shifted) call to @llvm.vscale.
vscale is effectively the number of "blocks" in the vector register. (That is, types such as <vscale x 8 x i8> and <vscale x 1 x i8> both fill one 64 bit block, and vscale is essentially how many of those blocks there are in a single vector register at runtime.)
We know from the RISCV V extension specification that VLEN must be a power of two between ELEN and 2^16. Since our block size is 64 bits, the must be a power of two numbers of blocks. (For everything other than VLEN<=32, but that's already broken.)
It is worth noting that AArch64 SVE specification explicitly allows non-power-of-two sizes for the vector registers and thus can't claim that vscale is a power of two by this logic.
Differential Revision: https://reviews.llvm.org/D129609
rnofenko [Tue, 12 Jul 2022 17:05:14 +0000 (10:05 -0700)]
[trace][intel pt] Add a nice parser for the trace size
Thanks to rnofenko@fb.com for coming up with these changes.
This diff adds support for passing units in the trace size inputs. For example,
it's now possible to specify 64KB as the trace size, instead of the
problematic 65536. This makes the user experience a bit friendlier.
Differential Revision: https://reviews.llvm.org/D129613
V Donaldson [Tue, 12 Jul 2022 16:27:40 +0000 (09:27 -0700)]
[flang] Intrinsic module file update
Use symbolic iostat values in iso_fortran_env.f90.
Add generic names to the interfaces in __fortran_ieee_exceptions.f90.
Fangrui Song [Wed, 13 Jul 2022 17:14:25 +0000 (10:14 -0700)]
[docs][llvm-objcopy] Fix unpaired `<align>``
Fangrui Song [Wed, 13 Jul 2022 17:04:21 +0000 (10:04 -0700)]
[llvm-objcopy][ELF] Add --set-section-type
The request is mentioned on D129053. I feel that having this functionality is
mildly useful (not strong).
* Rename .ctors to .init_array and change sh_type to SHT_INIT_ARRAY (GNU objcopy
detects the special name but we don't).
* Craft tests for a new SHT_LLVM_* extension
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D129337
Alex Brachet [Wed, 13 Jul 2022 16:53:39 +0000 (16:53 +0000)]
[libc][NFC] Make explicit casts for gcc
Alex Brachet [Wed, 13 Jul 2022 16:52:13 +0000 (16:52 +0000)]
[libc] Add explicit casts for gcc
Simon Pilgrim [Wed, 13 Jul 2022 16:35:38 +0000 (17:35 +0100)]
[DAG] SimplifyDemandedVectorElts - adjust demanded elements for selection mask for known zero results
If an element is known zero from both selections then it shouldn't matter what the selection mask element is.
Joseph Huber [Wed, 13 Jul 2022 16:31:29 +0000 (12:31 -0400)]
[LinkerWrapper] Fix linker-wrapper not working with host-LTO
Benoit Jacob [Mon, 4 Jul 2022 20:25:24 +0000 (20:25 +0000)]
lowerParallel is also called on unit-size, one-sided reduction dims
See: https://gist.github.com/bjacob/
d8be8ec7e70ed0be4b3a5794ced2a7e8
Differential Revision: https://reviews.llvm.org/D129096
Jonas Devlieghere [Wed, 13 Jul 2022 16:11:45 +0000 (09:11 -0700)]
Revert "[clang] Implement ElaboratedType sugaring for types written bare"
This reverts commit
bdc6974f92304f4ed542241b9b89ba58ba6b20aa because it
breaks all the LLDB tests that import the std module.
import-std-module/array.TestArrayFromStdModule.py
import-std-module/deque-basic.TestDequeFromStdModule.py
import-std-module/deque-dbg-info-content.TestDbgInfoContentDequeFromStdModule.py
import-std-module/forward_list.TestForwardListFromStdModule.py
import-std-module/forward_list-dbg-info-content.TestDbgInfoContentForwardListFromStdModule.py
import-std-module/list.TestListFromStdModule.py
import-std-module/list-dbg-info-content.TestDbgInfoContentListFromStdModule.py
import-std-module/queue.TestQueueFromStdModule.py
import-std-module/stack.TestStackFromStdModule.py
import-std-module/vector.TestVectorFromStdModule.py
import-std-module/vector-bool.TestVectorBoolFromStdModule.py
import-std-module/vector-dbg-info-content.TestDbgInfoContentVectorFromStdModule.py
import-std-module/vector-of-vectors.TestVectorOfVectorsFromStdModule.py
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/45301/
Fraser Cormack [Wed, 13 Jul 2022 10:10:41 +0000 (11:10 +0100)]
[llvm-reduce] Fix crash when reducing integer vectors to 1
Integer vectors were previously ignored when reducing operands. When
6b8bd0f72 introduced support for reducing floating-point
scalars/vectors, the vector case was written to only handle
floating-point values. It would crash when creating an invalid
ConstantFP from the integer element type.
Instead of reinstating the old integer vector behaviour, we might as
well reduce integer vectors to all-one splats.
A couple of existing tests has also been renamed from "remove" to
"reduce" to better reflect the deltas they test.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D129629
Jacques Pienaar [Wed, 13 Jul 2022 16:05:04 +0000 (09:05 -0700)]
[mlir] Plumb through default attribute populate for extensible dialect.
Mitch Phillips [Wed, 13 Jul 2022 15:39:35 +0000 (08:39 -0700)]
Update sanitize_* IR documentation.
sanitize_none was never actually committed, and should be removed.
no_sanitize_memtag is to be removed in D128950.
sanitize_memtag is new in D128950.
Also update the comments on other no_sanitize_* to indicate that they're
impacted by the sanitizer ignorelist and the global-disable attribute.
Reviewed By: eugenis
Differential Revision: https://reviews.llvm.org/D129410
Mitch Phillips [Wed, 13 Jul 2022 15:39:31 +0000 (08:39 -0700)]
Add missing sanitizer metadata plumbing from CFE.
clang misses attaching sanitizer metadata for external globals.
Reviewed By: eugenis
Differential Revision: https://reviews.llvm.org/D129492
Mitch Phillips [Wed, 13 Jul 2022 15:39:26 +0000 (08:39 -0700)]
Remove 'no_sanitize_memtag'. Add 'sanitize_memtag'.
For MTE globals, we should have clang emit the attribute for all GV's
that it creates, and then use that in the upcoming AArch64 global
tagging IR pass. We need a positive attribute for this sanitizer (rather
than implicit sanitization of all globals) because it needs to interact
with other parts of LLVM, including:
1. Suppressing certain global optimisations (like merging),
2. Emitting extra directives by the ASM writer, and
3. Putting extra information in the symbol table entries.
While this does technically make the LLVM IR / bitcode format
non-backwards-compatible, nobody should have used this attribute yet,
because it's a no-op.
Reviewed By: eugenis
Differential Revision: https://reviews.llvm.org/D128950
Alex Brachet [Wed, 13 Jul 2022 15:42:47 +0000 (15:42 +0000)]
[libc] Reset rounding mode after fsetround tests
Differential Revision: https://reviews.llvm.org/D129619
Kai Nacke [Wed, 13 Jul 2022 14:08:44 +0000 (10:08 -0400)]
[SystemZ] Enable `-mtune=` option in clang.
https://reviews.llvm.org/D128910 enabled handling of
attribute "tune-cpu" in LLVM. This PR now enables
option `-mtune` in clang, which then generates the
new attribute.
Reviewed By: uweigand
Differential Revision: https://reviews.llvm.org/D129562
Mark de Wever [Sat, 9 Jul 2022 14:14:40 +0000 (16:14 +0200)]
[libc++][format] Improves parsing speed.
A format string like "{}" is quite common. In this case avoid parsing
the format-spec when it's not present. Before the parsing was always
called, therefore some refactoring is done to make sure the formatters
work properly when their parse member isn't called.
From the wording it's not entirely clear whether this optimization is
allowed
[tab:formatter]
```
and the range [pc.begin(), pc.end()) from the last call to f.parse(pc).
```
Implies there's always a call to `f.parse` even when the format-spec
isn't present. Therefore this optimization isn't done for handle
classes; it's unclear whether that would break user defined formatters.
The improvements give a small reduciton is code size:
719408 12472 488 732368 b2cd0 before
718824 12472 488 731784 b2a88 after
The performance benefits when not using a format-spec are:
```
Comparing ./formatter_int.libcxx.out-baseline to ./formatter_int.libcxx.out
Benchmark Time CPU Time Old Time New CPU Old CPU New
----------------------------------------------------------------------------------------------------------------------------------------------------
BM_Basic<uint32_t> -0.0688 -0.0687 67 62 67 62
BM_Basic<int32_t> -0.1105 -0.1107 73 65 73 65
BM_Basic<uint64_t> -0.1053 -0.1049 95 85 95 85
BM_Basic<int64_t> -0.0889 -0.0888 93 85 93 85
BM_BasicLow<__uint128_t> -0.0655 -0.0655 96 90 96 90
BM_BasicLow<__int128_t> -0.0693 -0.0694 97 90 97 90
BM_Basic<__uint128_t> -0.0359 -0.0359 256 247 256 247
BM_Basic<__int128_t> -0.0414 -0.0414 239 229 239 229
```
For the cases where a format-spec is used the results remain similar,
some are faster some are slower, differing per run.
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D129426
Philip Reames [Wed, 13 Jul 2022 00:22:55 +0000 (17:22 -0700)]
[DAGCombine] fold (urem x, (lshr pow2, y)) -> (and x, (add (lshr pow2, y), -1))
We have the same fold in InstCombine - though implemented via OrZero flag on isKnownToBePowerOfTwo. The reasoning here is that either a) the result of the lshr is a power-of-two, or b) we have a div-by-zero triggering UB which we can ignore.
Differential Revision: https://reviews.llvm.org/D129606
Dylan Fleming [Wed, 13 Jul 2022 14:20:59 +0000 (14:20 +0000)]
[Flang] Fix path strings in CreateFIRLangRef.py
In D129186, CreateFIRLangRef.py was created to help fix
formatting problems with FIRLangRef.md.
However, due to an error while rebasing, the last edit was lost,
as such the current path variables are Unix-style.
This patch addresses what was discussed in the previous patch and
now uses os.path.join instead.
Differential Revision: https://reviews.llvm.org/D129644
Martin Sebor [Wed, 13 Jul 2022 15:18:00 +0000 (09:18 -0600)]
[InstCombine] Enable strtol folding with nonnull endptr
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D129593
Mark de Wever [Sun, 26 Jun 2022 08:58:02 +0000 (10:58 +0200)]
[libc++][chrono] Adds operator<=> for day.
Since the calendar classes were introduced in C++20 there's no need to
keep the old comparison operators.
This commit does the day calender class, the other calendar classes will
be in a followup commit.
Implements parts of:
- P1614R2 The mothership has landed
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D128603
Sam McCall [Tue, 12 Jul 2022 21:08:17 +0000 (23:08 +0200)]
[clangd] Enable designator inlay hints by default.
Differential Revision: https://reviews.llvm.org/D129595
Nikita Popov [Wed, 13 Jul 2022 14:22:40 +0000 (16:22 +0200)]
[SCCP] Fix typo in previous commit
Ooops, I tested a build from the wrong checkout.
Nikita Popov [Wed, 13 Jul 2022 14:20:34 +0000 (16:20 +0200)]
[SCCP] Avoid ConstantExpr::get() call
Use ConstantFoldUnaryOpOperand() API instead. This is in
preparation for removing fneg constant expressions.
Nikita Popov [Wed, 13 Jul 2022 13:35:13 +0000 (15:35 +0200)]
[TargetFolder] Use DL-aware folding for icmp
The Fold() call was accidentally dropped in
138fcc5f7619b5f066b9529a41ed47695149c8df, though it doesn't seem
to make a difference in practice (no test changes).
Nikita Popov [Wed, 13 Jul 2022 12:51:04 +0000 (14:51 +0200)]
[IRBuilder] Migrate fneg to fold infrastructure
Make use of a single FoldUnOpFMF() API, though in practice FNeg
is the only unary operation that exists.
This is likely NFC in practice, because users of InstSimplifyFolder
don't create fneg.
serge-sans-paille [Wed, 13 Jul 2022 12:53:04 +0000 (14:53 +0200)]
[clang] Ignore DependentSizeArray in -Warray-parameter
Acknowledge we don't know how to handle those yet.
Simon Pilgrim [Wed, 13 Jul 2022 12:52:07 +0000 (13:52 +0100)]
[AArch64] Regenerate arm64-vshuffle.ll test checks
Not quite ready to use the update script, but can clean it up slightly so the diffs aren't so great.
Simon Pilgrim [Wed, 13 Jul 2022 12:50:30 +0000 (13:50 +0100)]
[AArch64] Regenerate arm64-vselect.ll test checks
The ushll -> sshll FIXME had been fixed long ago, but nobody noticed because the test wasn't checking for either.....
Simon Pilgrim [Wed, 13 Jul 2022 12:48:46 +0000 (13:48 +0100)]
[ARM] Regenerate select_xform.ll test checks
Antonio Frighetto [Wed, 13 Jul 2022 12:36:04 +0000 (08:36 -0400)]
[Fixed Point] Fix C++20 compilation error
Due to how operator== changed after operator<=> landing in C++20
(error: use of overloaded operator '==' is ambiguous (with operand
types 'const llvm::APSInt' and 'const unsigned long')),
CheckIntPartMin/CheckIntPartMax interfaces are now leveraging
APSInt::compareValues.
Differential Revision: https://reviews.llvm.org/D129567
David Green [Wed, 13 Jul 2022 12:28:11 +0000 (13:28 +0100)]
Revert "Move instruction predicate verification to emitInstruction"
This reverts commit
e2fb8c0f4b940e0285ee36c112469fa75d4b60ff as it does
not build for Release builds, and some buildbots are giving more warning
than I saw locally. Reverting to fix those issues.
Max Kazantsev [Wed, 13 Jul 2022 12:03:03 +0000 (19:03 +0700)]
[IndVars][NFC] Make IVOperand parameter an instruction