Fangrui Song [Tue, 27 Jun 2023 05:20:02 +0000 (22:20 -0700)]
[test] Improve symbol visibility test
Aiden Grossman [Tue, 27 Jun 2023 04:59:09 +0000 (04:59 +0000)]
[llvm-exegesis] Fix test failure caused by assymetric values
I fixed compilation on 32-bit ARM earlier in the -Werror case using
preprocessor directives but forgot to update the unit tests that also
depend upon that value. This patch updates the unit tests as well as a
quick fix for the builders that were broken by the earlier patch.
Han Shen [Sat, 24 Jun 2023 17:19:26 +0000 (10:19 -0700)]
[NFC] Refactor MBB hotness/coldness into templated PSI functions.
In D152399, we calculate BPI->BFI in MachineFunctionSplit pass just to
use PSI->isFunctionHotInCallGraph, which is expensive. Instead, we can
implement this directly with MBFI.
Reviewer mentioned in the comment, that machine_size_opts already has
isFunctionColdInCallGraph, isFunctionHotInCallGraphNthPercentile, etc
implemented. These can be refactored and reused across MFS and machine
size opts.
This CL does this - it refactors out those internal static functions
into PSI as templated functions, so they can be accessed easily.
Differential Revision: https://reviews.llvm.org/D152758
Advenam Tacet [Thu, 1 Jun 2023 05:13:24 +0000 (05:13 +0000)]
[2a/3][ASan][libcxx] std::deque annotations
This revision is a part of a series of patches extending AddressSanitizer C++ container overflow detection capabilities by adding annotations, similar to those existing in `std::vector`, to `std::string` and `std::deque` collections. These changes allow ASan to detect cases when the instrumented program accesses memory which is internally allocated by the collection but is still not in-use (accesses before or after the stored elements for `std::deque`, or between the size and capacity bounds for `std::string`).
The motivation for the research and those changes was a bug, found by Trail of Bits, in a real code where an out-of-bounds read could happen as two strings were compared via a std::equals function that took `iter1_begin`, `iter1_end`, `iter2_begin` iterators (with a custom comparison function). When object `iter1` was longer than `iter2`, read out-of-bounds on `iter2` could happen. Container sanitization would detect it.
This revision introduces annotations for `std::deque`. Each chunk of the container can now be annotated using the `__sanitizer_annotate_double_ended_contiguous_container` function, which was added in the rG1c5ad6d2c01294a0decde43a88e9c27d7437d157. Any attempt to access poisoned memory will trigger an ASan error. Although false negatives are rare, they are possible due to limitations in the ASan API, where a few (usually up to 7) bytes before the container may remain unpoisoned. There are no false positives in the same way as with `std::vector` annotations.
This patch only supports objects (deques) that use the standard allocator. However, it can be easily extended to support all allocators, as suggested in the D146815 revision.
Furthermore, the patch includes the addition of the `is_double_ended_contiguous_container_asan_correct` function to `libcxx/test/support/asan_testing.h`. This function can be used to verify whether a `std::deque` object has been correctly annotated.
Finally, the patch extends the unit tests to verify ASan annotations (added LIBCPP_ASSERTs).
If a program is compiled without ASan, all helper functions will be no-ops. In binaries with ASan, there is a negligible performance impact since the code from the change is only executed when the deque container changes in size and it’s proportional to the change. It is important to note that regardless of whether or not these changes are in use, every access to the container's memory is instrumented.
If you have any questions, please email:
- advenam.tacet@trailofbits.com
- disconnect3d@trailofbits.com
Reviewed By: #libc, philnik
Differential Revision: https://reviews.llvm.org/D132092
Advenam Tacet [Tue, 27 Jun 2023 01:30:03 +0000 (03:30 +0200)]
[ASan] Remove sanity checks during annotation of contiguous container
This revision removes sanity checks in
`__sanitizer_annotate_contiguous_container`.
(Changed them to `DCHECK_EQ`.)
Those checks may be problematic, if someone manually unpoisoned memory block.
Manual unpoisoning may be used if part of the program is not
instrumented.
Those checks are helpful while confirming correctness of ASan annotations
implementation.
Originally suggested here: https://reviews.llvm.org/D136765#4174546
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D145482
Slava Zakharin [Mon, 26 Jun 2023 20:20:04 +0000 (13:20 -0700)]
[flang][hlfir] Special handling for temporary LHS in AssignOp.
When `AssignOp` is used with LHS that is a compiler generated temporary
special care must be taken to initialize the temporary and avoid
finalizations of its components. This change-set adds optional
`temporary_lhs` attribute for `AssignOp` to convey this information
to HLFIR-to-FIR conversion pass. Currently, this results in
calling `AssignTemporary` runtime for doing the assignment.
Reviewed By: jeanPerier, tblah
Differential Revision: https://reviews.llvm.org/D152482
Jie Fu [Tue, 27 Jun 2023 01:14:07 +0000 (09:14 +0800)]
[llvm-exegesis] Fix unused variable 'VAddressSpaceCeiling' warning (NFC)
/Users/jiefu/llvm-project/llvm/tools/llvm-exegesis/lib/X86/Target.cpp:52:33: error: unused variable 'VAddressSpaceCeiling' [-Werror,-Wunused-const-variable]
static constexpr const intptr_t VAddressSpaceCeiling = 0x0000800000000000;
^
1 error generated.
Fangrui Song [Tue, 27 Jun 2023 01:05:00 +0000 (18:05 -0700)]
[llvm-profdata][unittest] Fix -Wsign-compare after D147740
Fangrui Song [Tue, 27 Jun 2023 01:02:22 +0000 (18:02 -0700)]
[MC] Report location information for MCDwarfCallFrameFragment diagnostics
Fangrui Song [Tue, 27 Jun 2023 00:58:29 +0000 (17:58 -0700)]
[MC] Add SMLoc to MCCFIInstruction
to help debug and report better diagnostics for functions like
relaxDwarfCallFrameFragment (D153167).
In MCStreamer, some emitCFI* functions already take a SMLoc argument. Add a
SMLoc argument to the remaining functions that generate a MCCFIInstruction.
Jason Molenda [Tue, 27 Jun 2023 00:45:16 +0000 (17:45 -0700)]
FileSystem::EnumerateDirectory should skip entries w/o Status, not halt
EnumerateDirectory gets the vfs::Status of each directory entry to
decide how to process it. If it is unable to get the Status for
a directory entry, it will currently halt the directory iteration
entirely. It should only skip this entry.
Differential Revision: https://reviews.llvm.org/D153822
rdar://
110861210
Hongtao Yu [Mon, 26 Jun 2023 18:50:30 +0000 (11:50 -0700)]
[CSSPGO][Preinliner] Bump up the threshold to favor previous compiler inline decision.
The compiler has more insight and knowledge about functions based on their IR and attribures and should make a better inline decision than the offline preinliner does which is purely based on callsites hotness and code size. Therefore I'm making changes to favor previous compiler inline decision by bumping up the callsite allowance.
This should improve the performance by more than 1% according to testing on Meta services.
Reviewed By: wenlei
Differential Revision: https://reviews.llvm.org/D153797
LLVM GN Syncbot [Tue, 27 Jun 2023 00:06:15 +0000 (00:06 +0000)]
[gn build] Port
12e9c7aaa66b
William Huang [Sat, 24 Jun 2023 07:43:05 +0000 (07:43 +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
River Riddle [Mon, 26 Jun 2023 18:36:06 +0000 (11:36 -0700)]
[mlir][bytecode] Fix lazy loading of non-isolated regions
The bytecode reader currently assumes all regions can be lazy
loaded, which breaks reading any non-isolated region. This patch
fixes that by properly handling nested non-lazy regions, and only
considers isolated regions as lazy.
Differential Revision: https://reviews.llvm.org/D153795
Benjamin Kramer [Mon, 26 Jun 2023 23:24:15 +0000 (01:24 +0200)]
[bazel][mlir] Add missing dependencies for
5a1cdcbd8698cd263696b38e2672fccac9ec793c
Petr Hosek [Fri, 21 Apr 2023 02:50:46 +0000 (02:50 +0000)]
[Driver][BareMetal] Support --emit-static-lib in BareMetal driver
This allows building static libraries with Clang driver.
Differential Revision: https://reviews.llvm.org/D148869
Alex MacLean [Mon, 26 Jun 2023 23:12:43 +0000 (16:12 -0700)]
[SelectionDAG] Add memory size for CSEMap ID calculation
In NVPTX `ReplaceVectorLoad()`, i1 and i8 types are promoted to i16,
followed by a truncate operation. Thus, v2i8 (or v2i1) and v2i16 will
have the same VTList, which causes a collision in CSEMap.
To differentiate the original VTList, let's add the size in generating
an ID. Otherwise the compiler crashes in refineAlignment:
`MMO->getSize() == getSize() && "Size mismatch!"`
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D153712
Jerry Wu [Sun, 25 Jun 2023 08:21:09 +0000 (08:21 +0000)]
[mlir] Add pattern to handle trivial shape_cast in SPIR-V
Handle the trivial case of size-1 vector.shape_cast.
Differential Revision: https://reviews.llvm.org/D153719
Jim Ingham [Mon, 26 Jun 2023 23:01:18 +0000 (16:01 -0700)]
Don't allow SBValue::Cast to cast from a smaller type to a larger,
as we don't in general know where the extra data should come from.
Differential Revision: https://reviews.llvm.org/D153657
fernandosalas [Mon, 26 Jun 2023 22:41:18 +0000 (22:41 +0000)]
[scudo] Secondary Cache Dump
Dumped some basic info about what is being cached and about the cache
itself. Output of test below:
...
Stats: MapAllocatorCache: EntriesCount: 33, MaxEntriesCount: 64, MaxEntrySize: 1048576
StartBlockAddress: 0x6d342c1000, EndBlockAddress: 0x6d342d2000, BlockSize: 69632
StartBlockAddress: 0x6fc45ff000, EndBlockAddress: 0x6fc462f000, BlockSize: 196608
...
Reviewed By: Chia-hungDuan
Differential Revision: https://reviews.llvm.org/D153483
Riley [Mon, 26 Jun 2023 22:30:27 +0000 (22:30 +0000)]
[scudo] Fix data leak in wrappers_c_test.cpp
In SmallAlign implemented deallocation for the pointers
Reviewed By: cferris, Chia-hungDuan
Differential Revision: https://reviews.llvm.org/D153480
Chia-hung Duan [Mon, 26 Jun 2023 22:28:38 +0000 (22:28 +0000)]
[scudo] Fix insufficient blocks when pushing BatchClass blocks
`populateFreeListAndPopBatch` may return batch with single block. Merge
it with the reported free blocks and enqueue them together.
Reviewed By: cferris, fabio-d
Differential Revision: https://reviews.llvm.org/D153787
Eduard Zingerman [Thu, 15 Jun 2023 00:58:21 +0000 (03:58 +0300)]
[BPF] Propagate NoMerge attribute when lowering function calls
`NoMerge` attribute on machine instructions prevents certain
transformations from merging these instructions.
One of such transformations is 'llvm/lib/CodeGen/BranchFolding.cpp'.
This attribute should be copied from IR `call` instructions to machine
level instructions. See `X86TargetLowering::LowerCall` as another
example.
Differential Revision: https://reviews.llvm.org/D152987
Eduard Zingerman [Thu, 15 Jun 2023 00:35:07 +0000 (03:35 +0300)]
[clang] Allow 'nomerge' attribute for function pointers
Allow specifying 'nomerge' attribute for function pointers,
e.g. like in the following C code:
extern void (*foo)(void) __attribute__((nomerge));
void bar(long i) {
if (i)
foo();
else
foo();
}
With the goal to attach 'nomerge' to both calls done through 'foo':
@foo = external local_unnamed_addr global ptr, align 8
define dso_local void @bar(i64 noundef %i) local_unnamed_addr #0 {
; ...
%0 = load ptr, ptr @foo, align 8, !tbaa !5
; ...
if.then:
tail call void %0() #1
br label %if.end
if.else:
tail call void %0() #1
br label %if.end
if.end:
ret void
}
; ...
attributes #1 = { nomerge ... }
Report a warning in case if 'nomerge' is specified for a variable that
is not a function pointer, e.g.:
t.c:2:22: warning: 'nomerge' attribute is ignored because 'j' is not a function pointer [-Wignored-attributes]
2 | int j __attribute__((nomerge));
| ^
The intended use-case is for BPF backend.
BPF provides a sort of "standard library" functions that are called
helpers. BPF also verifies usage of these helpers before program
execution. Because of limitations of verification / runtime model it
is important to keep calls to some of such helpers from merging.
An example could be found by the link [1], there input C code:
if (data_end - data > 1024) {
bpf_for_each_map_elem(&map1, cb, &cb_data, 0);
} else {
bpf_for_each_map_elem(&map2, cb, &cb_data, 0);
}
Is converted to bytecode equivalent to:
if (data_end - data > 1024)
tmp = &map1;
else
tmp = &map2;
bpf_for_each_map_elem(tmp, cb, &cb_data, 0);
However, BPF verification/runtime requires to use the same map address
for each particular `bpf_for_each_map_elem()` call.
The 'nomerge' attribute is a perfect match for this situation, but
unfortunately BPF helpers are declared as pointers to functions:
static long (*bpf_for_each_map_elem)(void *map, ...) = (void *) 164;
Hence, this commit, allowing to use 'nomerge' for function pointers.
[1] https://lore.kernel.org/bpf/
03bdf90f-f374-1e67-69d6-
76dd9c8318a4@meta.com/
Differential Revision: https://reviews.llvm.org/D152986
Kelvin Li [Mon, 26 Jun 2023 18:30:10 +0000 (14:30 -0400)]
[flang] Fix flang-aarch64-latest-gcc build failure due to f295c88
Insert a return statement
Alex Langford [Mon, 26 Jun 2023 21:21:48 +0000 (14:21 -0700)]
[lldb] Increase the maximum number of classes we can read from shared cache
The shared cache has grown past the previously hardcoded limit. As a
temporary measure, I am increasing the hardcoded number of classes we
can expect to read from the shared cache. This is not a good long-term
solution.
Differential Revision: https://reviews.llvm.org/D153817
David Green [Mon, 26 Jun 2023 21:41:18 +0000 (22:41 +0100)]
[AArch64] Don't recreate nodes in tryCombineLongOpWithDup
If we don't find a node with either operand through
isEssentiallyExtractHighSubvector, there is little point
recreating the node with the same operands. Returning
SDValue better communicates that no changes were made.
This fixes #63491 by not recreating uabd nodes with swapped
operands. As noted in the ticket there are other fixes that
might be useful to make too, but this should prevent the
infinite combine.
Andres Villegas [Mon, 26 Jun 2023 21:35:39 +0000 (14:35 -0700)]
[llvm-libtool-darwin] Switch to OptTableSummary
Switch the parse of command line options fromllvm::cl to OptTable.
The motivation for this change is to continue adding llvm based tools
to the llvm driver multicall.
Differential Revision: https://reviews.llvm.org/D153665
Douglas Yung [Mon, 26 Jun 2023 21:33:09 +0000 (14:33 -0700)]
[NFC] Bump up DIAG_SIZE_AST as we have hit the limit as of f27afed.
Fangrui Song [Mon, 26 Jun 2023 21:26:06 +0000 (14:26 -0700)]
[MC] Reject CFI advance_loc separated by a non-private label for Mach-O
Due to Mach-O's .subsections_via_symbols mechanism, non-private labels cannot
appear between .cfi_startproc/.cfi_endproc. Compilers do not produce such
labels, but hand-written assembly may. Give an error. Unfortunately,
emitDwarfAdvanceFrameAddr generated MCExpr doesn't have location
informatin.
Note: evaluateKnownAbsolute is to force folding A-B to a constant even if A and
B are separate by a non-private label. The function is a workaround for some
Mach-O assembler issues and should generally be avoided.
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D153167
yzhang93 [Mon, 26 Jun 2023 21:18:15 +0000 (14:18 -0700)]
[mlir] Narrow bitwidth emulation for MemRef load
This patch adds support for narrow bitwidth storage emulation. The goal is to support sub-byte type
codegen for LLVM CPU. Specifically, a type converter is added to convert memref of narrow bitwidth
(e.g., i4) into supported wider bitwidth (e.g., i8). Another focus of this patch is to populate the
pattern for int4 memref.load. memref.store pattern should be added in a seperate patch.
Reviewed By: hanchung, mravishankar
Differential Revision: https://reviews.llvm.org/D151519
cabreraam [Mon, 26 Jun 2023 21:03:07 +0000 (17:03 -0400)]
[flang][hlfir] `hlfir.char_extremum` lowering
This patch implements the lowering for the `hlfir.char_extremum` operation.
Discussion for this patch can be found in the draft patch [here](https://reviews.llvm.org/D143326). The reason
for not promoting this draft to a true patch for review was because I needed to separate the op
definition/codegen and lowering into two separate patches, as preferred by @jeanPerier.
Depends on D152474
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D152475
Fangrui Song [Mon, 26 Jun 2023 21:00:58 +0000 (14:00 -0700)]
[dataflow] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds after D153006
Aiden Grossman [Mon, 26 Jun 2023 20:52:55 +0000 (20:52 +0000)]
[llvm-exegesis] Define SYS_mmap to be SYS_mmap2 on 32-bit ARM
llvm-exegesis currently isn't compiling on 32-bit ARM due to SYS_mmap
not being defined as 32-bit ARM instead uses SYS_mmap2. This patch
defines SYS_mmap to be SYS_mmap2 in the relevant places to allow for
compilation to succeed.
Matthias Braun [Mon, 5 Jun 2023 22:15:01 +0000 (15:15 -0700)]
Ignore load/store until stack address computation
No longer conservatively assume a load/store accesses the stack when we
can prove that we did not compute any stack-relative address up to this
point in the program.
We do this in a cheap not-quite-a-dataflow-analysis: Assume
`NoStackAddressUsed` when all predecessors of a block already guarantee
it. Process blocks in reverse post order to guarantee that except for
loop headers we have processed all predecessors of a block before
processing the block itself. For loops we accept the conservative answer
as they are unlikely to be shrink-wrappable anyway.
Differential Revision: https://reviews.llvm.org/D152213
Matthias Braun [Thu, 25 May 2023 01:08:59 +0000 (18:08 -0700)]
Switch tests to use update_llc_test_checks
Switch and update some tests to use `update_llc_test_checks` to reduce
clutter in upcoming change.
Differential Revision: https://reviews.llvm.org/D152215
Aiden Grossman [Mon, 26 Jun 2023 20:41:54 +0000 (20:41 +0000)]
[llvm-exegesis] Define MAP_FIXED_NOREPLACE if not available
Some builders are currently failing as they don't have
MAP_FIXED_NOREPLACE available. This patch checks if MAP_FIXED_NOREPLACE
is available and if it isn't, it is simply defined as MAP_FIXED.
Shubham Sandeep Rastogi [Wed, 21 Jun 2023 23:47:28 +0000 (16:47 -0700)]
Do not emit a named symbol to denote the start of the debug_frame section
When emitting a debug_frame section, it contains a named symbol.
> echo "void foo(void) {}" | clang -arch arm64 -ffreestanding -g -c -o \
/tmp/test.o -x c -
> nm /tmp/test.o -s __DWARF __debug_frame
0000000000000200 s ltmp1
There are no such symbols emitted in any of the other DWARF sections,
this is because when the __debug_frame section is created, it doesn't
get a `BeginSymName` and so it creates a named symbol, such as `ltmp1`
and emits it when we switch to the section in MCDwarf.cpp.
This patch fixes the above issue.
Differential Revision: https://reviews.llvm.org/D153484
Aiden Grossman [Mon, 26 Jun 2023 20:26:30 +0000 (20:26 +0000)]
[llvm-exegesis] Explicitly link llvm-exegesis unit tests against librt
On some platforms such as PPC shm_open is in librt and it isn't
automatically linked against. This patch explicitly links against librt
in the unittests which should hopefully fix the symbol resolution
errors.
Diego Caballero [Mon, 26 Jun 2023 20:24:29 +0000 (20:24 +0000)]
[mlir][Vector] Fix vectorization of generic ops with transposed outputs
This patch fixes a bug in the way we compute the vector type for vector
transfer writes when the value to store needs to be transposed.
Reviewed By: nicolasvasilache, mravishankar
Differential Revision: https://reviews.llvm.org/D153687
Nicolas Vasilache [Mon, 26 Jun 2023 20:07:51 +0000 (20:07 +0000)]
[mlir][linalg] Add named op for matmul_transpose_a
matmul with transposed LHS operand allows better memory access
patterns on several architectures including common GPUs. Having a named
op for it allows to handle this kind of matmul in a more explicit way.
LLVM GN Syncbot [Mon, 26 Jun 2023 20:01:56 +0000 (20:01 +0000)]
[gn build] Port
f8927838fa85
LLVM GN Syncbot [Mon, 26 Jun 2023 20:01:55 +0000 (20:01 +0000)]
[gn build] Port
83f875dc94d7
Nico Weber [Mon, 26 Jun 2023 20:00:53 +0000 (16:00 -0400)]
[gn] prepare for porting
f8927838fa8558702794
Aart Bik [Mon, 26 Jun 2023 19:09:33 +0000 (12:09 -0700)]
[mlir][sparse] minor code changes
Submitting for Wren
Reviewed By: K-Wu
Differential Revision: https://reviews.llvm.org/D153804
Fangrui Song [Mon, 26 Jun 2023 19:55:48 +0000 (12:55 -0700)]
Nicolas Vasilache [Mon, 26 Jun 2023 19:43:58 +0000 (19:43 +0000)]
[mlir][linalg] Add missing op to match the generated file
D141430 added the generated yaml file for (batch_)?matmul_transpose_b ops, but the source of truth core_named_ops.py was not updated.
This change fixes .py file to generate the same result as the yaml file.
Differential revision: https://reviews.llvm.org/D150059
Authored-by: kon72 <kinsei0916@gmail.com>
Philip Reames [Mon, 26 Jun 2023 19:46:16 +0000 (12:46 -0700)]
[RISCV] Regen rvv/fixed-vectors-fmf.ll to avoid spurious test deltas
Fangrui Song [Mon, 26 Jun 2023 19:48:20 +0000 (12:48 -0700)]
[dataflow] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds after D153006
Anthony Cabrera [Thu, 8 Jun 2023 21:53:50 +0000 (17:53 -0400)]
[flang][hlfir] `hlfir.char_extremum` op definition and codegen
This patch adds an hlfir operation called `char_extremum`, which takes the
lexicographic comparison between a variadic number (minimum of 2 arguments) of
characters.
Discussion for this work can be found in the draft revision found
[here](https://reviews.llvm.org/D143326). The reason I'm not promoting that draft to
a true patch for review was because I needed to separate out the op
definition/codegen and lowering as two separate patches, as preferred by
@jeanPerier.
Differential Revision: https://reviews.llvm.org/D152474
Fangrui Song [Mon, 26 Jun 2023 19:28:02 +0000 (12:28 -0700)]
[Driver][ARM] Warn about -mabi= for assembler input
Previously, Clang Driver reported a warning when assembler input was assembled
with the -mabi= option. D152856 added TargetSpecific to -mabi= option and
reported an error for such a case. This change restores the previous behavior by
reporting a warning.
GCC translates -mabi={apcs-gnu,atpcs} to gas -meabi=gnu and other -mabi= values
to -meabi=5. We don't support setting e_flags to any value other than
EF_ARM_EABI_VER5.
Close https://github.com/ClangBuiltLinux/linux/issues/1878
Reviewed By: michaelplatings
Differential Revision: https://reviews.llvm.org/D153691
Aiden Grossman [Sat, 20 May 2023 09:46:50 +0000 (09:46 +0000)]
[llvm-exegesis] Add Target Memory Utility Functions
This patch adds in several functions to ExegesisTarget that will assist
in setting up memory for the planned memory annotations.
Reviewed By: courbet
Differential Revision: https://reviews.llvm.org/D151023
Sam McCall [Thu, 22 Jun 2023 19:54:52 +0000 (21:54 +0200)]
[dataflow] Make SAT solver deterministic
The SAT solver imported its constraints by iterating over an unordered DenseSet.
The path taken, and ultimately the runtime, the specific solution found, and
whether it would time out or complete could depend on the iteration order.
Instead, have the caller specify an ordered collection of constraints.
If this is built in a deterministic way, the system can have deterministic
behavior.
(The main alternative is to sort the constraints by value, but this option
is simpler today).
A lot of nondeterminism still appears to be remain in the framework, so today
the solver's inputs themselves are not deterministic yet.
Differential Revision: https://reviews.llvm.org/D153584
Craig Topper [Mon, 26 Jun 2023 19:14:34 +0000 (12:14 -0700)]
[RISCV] Add i32 as a legal type for GPR register class.
I'm investigating if it is feasible to have i32 as a legal type for RV64.
The first thing we need to do is make i32 a valid type for the GPR
register class.
We already added f32/f64 as valid types which required adding explicit
types to tablegen patterns. Adding additional types to GPR is free now.
Reviewed By: sunshaoce
Differential Revision: https://reviews.llvm.org/D151177
Aiden Grossman [Mon, 26 Jun 2023 18:57:51 +0000 (18:57 +0000)]
[NFC][llvm-exegesis] Disable tests using preprocessor directives
This patch changes to disabling tests in SubprocessMemoryTest.cpp using
preprocessor directives rather than pulling the file out of the build
using CMake. This is the de facto canonical way to do it in the rest of
the tree as seen in other unittest files such as DwarfDebugInfoTest.cpp.
Mike Crowe [Mon, 26 Jun 2023 18:24:45 +0000 (18:24 +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
Valentin Clement [Mon, 26 Jun 2023 18:57:42 +0000 (11:57 -0700)]
[flang][openacc] Support array reduction for max in lowering
Add loweirng support for array reduction with the
max operator. Simplify generation of init value.
Depends on D153661
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D153663
Craig Topper [Mon, 26 Jun 2023 18:55:56 +0000 (11:55 -0700)]
[RISCV][SelectionDAGBuilder] Fix an implicit scalable TypeSize to fixed size conversion in getUniformBase.
If the index needs to be scaled by a scalable size, just give up.
Fixes #63459
Reviewed By: frasercrmck, RKSimon
Differential Revision: https://reviews.llvm.org/D153601
Shubham Sandeep Rastogi [Mon, 26 Jun 2023 18:52:34 +0000 (11:52 -0700)]
Revert "Do not emit a named symbol to denote the start of the debug_frame section"
This reverts commit
d6576add99e5ebf936f836aa3ecdc85deb33687e.
Reverted because
BUILD FAILED: failed 41960 expected passes 86 expected failures 28788 unsupported tests 1 unexpected failures (failure)
Jeff Niu [Mon, 26 Jun 2023 15:28:43 +0000 (08:28 -0700)]
[mlir][index] Add identity folders for add and sub
Depends on D153736
Reviewed By: rriddle, jpienaar
Differential Revision: https://reviews.llvm.org/D153780
Jeff Niu [Mon, 26 Jun 2023 01:18:44 +0000 (18:18 -0700)]
[mlir][index] Add `index.mul` identity folders
Fold `mul(x, 1)` and `mul(x, 0)`.
Depends on D153736
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D153736
Jeff Niu [Mon, 26 Jun 2023 00:44:38 +0000 (17:44 -0700)]
[mlir][index] Fold `cmp(max/min(x, cstA), cstB)`
This is a case that is not picked up by integer range inference and
suggests a weakness with integer range inference on the index dialect.
The problem is that when `[1, SMAX_64]` is truncated to 32 bits, the
resulting range could be `[SMIN_32, SMAX_32]`, making the subsequent
comparison worthless. This is because integer range inference doesn't
know that the result of the max/min inference also changes based on the
bitwidth, and doing the truncation locally at the input of the
comparison op loses that information.
This also was a pattern that frequently showed up in our code, so adding
it as a folder allows dead code to be pruned more frequently.
Depends on D153731
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D153732
Jeff Niu [Sun, 25 Jun 2023 21:28:14 +0000 (14:28 -0700)]
[mlir][index] Mark certain ops as Commutative
Mark the relevant index dialect operations as Commutative. Specifically,
this allows the folder to move constant operands to the RHS.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D153731
Matt Arsenault [Tue, 13 Jun 2023 21:37:53 +0000 (17:37 -0400)]
OpenMP: Add fma math test
Philip Reames [Mon, 26 Jun 2023 18:42:31 +0000 (11:42 -0700)]
[RISCV] Check that SEW and policy operands are immediates in verifier
This converts a crash (due an assertion inside getImm) into a verifier failure. Much easier to debug when you have malformed instructions.
Matt Arsenault [Sun, 18 Jun 2023 13:30:37 +0000 (09:30 -0400)]
OpenMP: Don't include stdbool.h in builtin headers
Pre-C99 didn't include bool, and C99 allows you to redefine true/false
apparently.
Matt Arsenault [Tue, 13 Jun 2023 21:31:00 +0000 (17:31 -0400)]
OpenMP: Use generated checks and pragma declare target
David Goldman [Mon, 26 Jun 2023 16:25:56 +0000 (12:25 -0400)]
[clangd][ObjC] Support ObjC class rename from implementation decls
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D152720
Shubham Sandeep Rastogi [Wed, 21 Jun 2023 23:47:28 +0000 (16:47 -0700)]
Do not emit a named symbol to denote the start of the debug_frame section
When emitting a debug_frame section, it contains a named symbol.
> echo "void foo(void) {}" | clang -arch arm64 -ffreestanding -g -c -o \
/tmp/test.o -x c -
> nm /tmp/test.o -s __DWARF __debug_frame
0000000000000200 s ltmp1
There are no such symbols emitted in any of the other DWARF sections,
this is because when the __debug_frame section is created, it doesn't
get a `BeginSymName` and so it creates a named symbol, such as `ltmp1`
and emits it when we switch to the section in MCDwarf.cpp.
This patch fixes the above issue.
Differential Revision: https://reviews.llvm.org/D153484
Garvit Gupta [Mon, 26 Jun 2023 18:36:00 +0000 (11:36 -0700)]
[RISCV] Add support for custom instructions for Sifive S76.
Support for below instruction is added
1. CFLUSH.D.L1
2. CDISCARD.D.L1
3. CEASE
Additionally, Zihintpause extension is added to sifive s76 for pause
instruction.
Spec - https://sifive.cdn.prismic.io/sifive/
767804da-53b2-4893-97d5-b7c030ae0a94_s76mc_core_complex_manual_21G3.pdf
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D153370
LLVM GN Syncbot [Mon, 26 Jun 2023 18:22:32 +0000 (18:22 +0000)]
[gn build] Port
5a63b2b3049e
Aiden Grossman [Sat, 20 May 2023 09:50:43 +0000 (09:50 +0000)]
[llvm-exegesis] Introduce SubprocessMemory Utility Class
This patch introduces the SubprocessMemory class to llvm-exegesis. This
class contains several utilities that are needed for managing memory to
set up an execution environment for memory annotations.
Reviewed By: courbet
Differential Revision: https://reviews.llvm.org/D151022
Piotr Zegar [Mon, 26 Jun 2023 18:20:28 +0000 (18:20 +0000)]
[clang-tidy][NFC] Repharse a lite bit documentation for misc-header-include-cycle check
Change documentation, to avoid some duplication,
and make it sound beter.
walter erquinigo [Mon, 26 Jun 2023 18:15:14 +0000 (13:15 -0500)]
[LLDB] Fix
582582fb474b8cd4103e65c3e5a705b3aff61794
This issue has been seen in
- https://lab.llvm.org/buildbot/#/builders/17/builds/39525
- https://lab.llvm.org/buildbot/#/builders/68/builds/55140
The reason is that a new language tag has been added for Mojo, but other recent languages need to be added to the language array so that a name lookup array doesn't have gaps.
`ninja check-lldb-shell-process` now passes.
Alex Langford [Sat, 24 Jun 2023 01:01:26 +0000 (18:01 -0700)]
[lldb][NFCI] Remove ConstString from Process::ConfigureStructuredData
This is a follow-up to
b4827a3c0a7ef121ca376713e115b04eff0f5194.
Differential Revision: https://reviews.llvm.org/D153675
Alex Langford [Sat, 24 Jun 2023 00:27:09 +0000 (17:27 -0700)]
[lldb][NFCI] Remove unneeded ConstString constructions for OptionValueProperties::AppendProperty
I removed ConstString from OptionValueProperties in
643ba926c1f6, but
there are a few call sites that still create a ConstString as an
argument. I did not catch these initially because ConstString has an
implicit conversion method to StringRef.
Differential Revision: https://reviews.llvm.org/D153673
Matt Arsenault [Thu, 22 Jun 2023 11:03:33 +0000 (07:03 -0400)]
SeparateConstOffsetFromGEP: Don't use SCEV
This was only using the SCEV expressions as a map key, which we can do
just as well with the value pointers. This also allows it to handle
vectors.
Matt Arsenault [Sat, 24 Jun 2023 15:58:31 +0000 (11:58 -0400)]
SeparateConstOffsetForGEP: Remove some typed pointer code
Matt Arsenault [Sat, 24 Jun 2023 14:35:17 +0000 (10:35 -0400)]
SeparateConstOffsetForGEP: Fill out some missing test coverage
Try to test several untested paths.
- Test the extension source type check
- Test the programUndefinedIfPoison check
- Test the add/sub with commuted operands
- Test with vectors
- Test multiple uses
- Try to break operand map mismatches
- Add some preparatory tests for zext+nuw support.
Matt Arsenault [Sat, 24 Jun 2023 10:52:51 +0000 (06:52 -0400)]
SeparateConstOffsetFromGEP: Copy a test to AMDGPU
Matt Arsenault [Sat, 24 Jun 2023 10:56:01 +0000 (06:56 -0400)]
SeparateConstOffsetFromGEP: Reorder run lines
Testing codegen in test/Transforms is questionable to begin with, but
it's more reasonable to see failures on the IR half before ISA checks.
Maurice Heumann [Mon, 26 Jun 2023 16:41:31 +0000 (09:41 -0700)]
[ARM] Fix codegen of unaligned volatile load/store of i64
Volatile loads/stores of i64 are lowered to LDRD/STRD on ARMv5TE.
However, these instructions require the addresses to be aligned.
Unaligned loads/stores therefore should be ignored by this handling.
Differential Revision: https://reviews.llvm.org/D152790
Eli Friedman [Wed, 24 May 2023 17:39:43 +0000 (10:39 -0700)]
[SelectionDAG] Improve expansion of wide min/max
The current implementation tries to handle the high and low halves
separately, but that's less efficient in most cases; use a wide SETCC
instead.
Differential Revision: https://reviews.llvm.org/D151358
Eli Friedman [Fri, 16 Jun 2023 23:05:30 +0000 (16:05 -0700)]
[clang codegen] Fix ABI for HVA returns on AArch64 MSVC.
MSVC normally has a bunch of restrictions on returning values directly
which don't apply to passing values directly. (This roughly corresponds
to the definition of a C++14 aggregate.) However, these restrictions
don't apply to HVAs; make sure we check for that.
Fixes https://github.com/llvm/llvm-project/issues/62223
Differential Revision: https://reviews.llvm.org/D153179
Krzysztof Drewniak [Thu, 8 Jun 2023 14:55:03 +0000 (14:55 +0000)]
[mlir] Convert 8-bit float types to i8
Whereas LLVM currently doesn't have any types for 8-bit floats, and
whereas existing 8-bit float APIs (for instance, the AMDGCN
intrinsics) take such floats as (packed) bytes, translate the MLIR
8-bit float types to i8 during LLVM lowering.
In order to not special-case arith.constant for bitcasting constants
to their integer form, amend the MLIR to LLVM translator to turn 8-bit
float constants into i8 constants with the same value (by use of
APFloat's bitcast method).
This change can be reverted once LLVM has 8-bit float types.
Reviewed By: gysit
Differential Revision: https://reviews.llvm.org/D153160
Jonas Devlieghere [Mon, 26 Jun 2023 16:16:23 +0000 (09:16 -0700)]
[lldb] Add `source cache dump` and `source cache clear` subcommand
Add two new source subcommands: source cache dump and source cache
clear. As the name implies the first one dumps the source cache while
the later clears the cache.
This patch was motivated by a handful of (internal) bug reports related
to sources not being available. Right now those issues can be hard to
diagnose. The new commands give users, as well as us as developers, more
insight into and control over the source cache.
Differential revision: https://reviews.llvm.org/D153685
Alex Langford [Sat, 24 Jun 2023 19:33:12 +0000 (12:33 -0700)]
[lldb][NFCI] Timer::DumpCategoryTimes should take a reference instead of a pointer
We are assuming that the pointer is always valid, might as well take a
reference instead.
Differential Revision: https://reviews.llvm.org/D153711
Alex Langford [Sat, 24 Jun 2023 19:23:43 +0000 (12:23 -0700)]
[lldb][NFCI] UUID::Dump should take a reference instead of a pointer
We always assume the Stream pointer is valid, might as well be taking a
reference instead.
Differential Revision: https://reviews.llvm.org/D153710
Joel Dice [Mon, 26 Jun 2023 17:25:45 +0000 (10:25 -0700)]
[clang][WebAssembly] Support wasm32-wasi shared libraries
This adds support for Emscripten-style shared libraries [1] to
non-emscripten targets, such as `wasm32-wasi`. Previously, only static
linking was supported, and the `-shared` and `-fPIC` flags were simply
ignored. Now both flags are honored.
Since WASI runtimes do not necessarily include JavaScript support, we
cannot rely on the JS-based Emscripten linker to link shared libraries.
Instead, we link them using the Component Model proposal [2].
We have prototyped shared library support in `wasi-sdk` [3] and put
together a demo [4] which uses a patched version of `wit-component` [5]
to link libraries using the Component Model. We plan to submit the
required changes upstream to the respective repositories in the next
week or two.
[1] https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md
[2] https://github.com/WebAssembly/component-model/blob/main/design/mvp/examples/SharedEverythingDynamicLinking.md
[3] https://github.com/dicej/wasi-sdk/tree/dynamic-linking
[4] https://github.com/dicej/component-linking-demo
[5] https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wit-component
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Reviewed By: sbc100
Differential Revision: https://reviews.llvm.org/D153293
Jake Egan [Mon, 26 Jun 2023 17:22:10 +0000 (13:22 -0400)]
[AIX][tests] XFAIL input-file-err.test
The test is failing due to D153595, so XFAIL for now to get the bot green. D151567 should fix it.
Argyrios Kyrtzidis [Fri, 23 Jun 2023 22:33:39 +0000 (15:33 -0700)]
[clang/HeaderSearch] Make sure `loadSubdirectoryModuleMaps` doesn't cause loading of regular files
`HeaderSearch::loadSubdirectoryModuleMaps` `stat`s all the files in a directory which causes the dependency scanning
service to load and cache their contents. This is problematic because a file may be in the process of being generated
and could be cached by the dep-scan service while it is still incomplete.
To address this change `loadSubdirectoryModuleMaps` to ignore regular files.
Differential Revision: https://reviews.llvm.org/D153670
Wenlei He [Sun, 25 Jun 2023 23:39:16 +0000 (16:39 -0700)]
[NFC] Generalize llvm-profgen message to cover both AutoFDO and CSSPGO
Update llvm-profgen profile density message to cover both AutoFDO and CSSPGO.
Differential Revision: https://reviews.llvm.org/D153730
Nicolas Vasilache [Wed, 21 Jun 2023 14:35:30 +0000 (14:35 +0000)]
[mlir][Transform] Add support for mma.sync m16n8k16 f16 rewrite.
This PR adds support for the m16n8k16 f16 case.
At this point, the support is mostly mechanical and could be Tablegen'd to all cases.
Until then, this can be populated as needed on a case-by-case basis.
Depends on: D153420
Differential Revision: https://reviews.llvm.org/D153428
Ahmed Bougacha [Mon, 24 Oct 2022 15:33:30 +0000 (08:33 -0700)]
[AArch64][PAC] Select MOVK for ptrauth.blend intrinsic.
Blend combines two discriminator values used by other ptrauth ops.
On AArch64 here, it does that by replacing the high 16 bits of the
LHS with the low 16 bits of the RHS.
Usually the RHS is a constant, which lets us do this efficiently in
a single MOVK. When the RHS isn't constant, we can do a BFI.
In a sense, this is implementing an ABI decision (how to lower the
software construct of "blend"), but if there are interesting variants to
consider, this could be made object-file-format-specific in some way.
Differential Revision: https://reviews.llvm.org/D132384
Sam McCall [Mon, 26 Jun 2023 16:35:39 +0000 (18:35 +0200)]
Revert "[dataflow] avoid more accidental copies of Environment"
This reverts commit
ae54f01dd8c53d18c276420b23f0d0ab7afefff1.
Accidentally committed without review :-(
Nikolas Klauser [Mon, 26 Jun 2023 03:19:01 +0000 (20:19 -0700)]
[clang] __is_trivially_equality_comparable should return false for arrays
When comparing two arrays, their pointers are compared instead of their elements, which means that they are not trivially equality comparable
Fixes #63371
Reviewed By: cor3ntin
Spies: cor3ntin, cfe-commits
Differential Revision: https://reviews.llvm.org/D153737
Nikolas Klauser [Mon, 26 Jun 2023 16:35:34 +0000 (09:35 -0700)]
[NFC] Add clang whitespace removal patch to .git-blame-ignore-revs
Nikolas Klauser [Mon, 26 Jun 2023 01:59:56 +0000 (18:59 -0700)]
[clang][NFC] Remove trailing whitespaces and enforce it in lib, include and docs
A lot of editors remove trailing whitespaces. This patch removes any trailing whitespaces and makes sure that no new ones are added.
Reviewed By: erichkeane, paulkirth, #libc, philnik
Spies: wangpc, aheejin, MaskRay, pcwang-thead, cfe-commits, libcxx-commits, dschuff, nemanjai, arichardson, kbarton, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, Jim, s.egerton, sameer.abuasal, apazos, luismarques, martong, frasercrmck, steakhal, luke
Differential Revision: https://reviews.llvm.org/D151963
walter erquinigo [Thu, 15 Jun 2023 20:57:07 +0000 (15:57 -0500)]
[LLDB] Add DWARF definitions for the new Mojo language
The new language Mojo recently received a proper DWARF code, which can be seen in https://dwarfstd.org/languages.html, and this patch adds the basic definitions for using this language in DWARF.
Differential Revision: https://reviews.llvm.org/D153073