487592 Commits

Author SHA1 Message Date
Fangrui Song
c663c8b883 [ELF,test] Improve dead-reloc-in-nonalloc.s
Test an absolute relocation referencing a DSO symbol, relocating a
non-SHF_ALLOC section. Also test --gc-sections.
2024-01-23 17:23:52 -08:00
Jeffrey Byrnes
f709fbb1bb
[SROA] Only try additional vector type candidates when needed (#77678)
f9c2a341b9
causes regressions when we have a slice with integer vector type that is
the same size as the partition, and a ptr load/store slice that is not
the size of the element type.

Ref `vector-promotion.ll:ptrLoadStoreTys`. 

Before the patch, we would only consider `<4 x i32>` as a candidate type
for vector promotion, and would find that it is a viable type for all
the slices.

After the patch, we now add `<2 x ptr>` as a candidate type due to slice
with user `store ptr %val0, ptr %obj, align 8` -- and flag that we
`HaveVecPtrTy`. The pre-existing behavior of this flag results in
removing the viable `<4 x i32>` and keeping only the unviable `<2 x
ptr>`, which results in a failure to promote.

The end result is failing to promote an alloca that was previously
promoted -- this does not appear to be the intent of that patch, which
has the goal of increasing promotions by providing more promotion
opportunities.

This PR preserves this behavior via a simple reorganization of the
implemention: try first the slice types with same size as the partition,
then, if there is no promotable type, try the `LoadStoreTys.`
2024-01-23 17:22:49 -08:00
Jinyang He
c51ab483e6
[LoongArch] Insert nops and emit align reloc when handle alignment directive (#72962)
Refer to RISCV, we will fix up the alignment if linker relaxation
changes code size and breaks alignment. Insert enough Nops and emit
R_LARCH_ALIGN relocation type so that linker could satisfy the alignment
by removing Nops.
It does so only in sections with the SHF_EXECINSTR flag.

In LoongArch psABI v2.30, R_LARCH_ALIGN requires symbol index. The
lowest 8 bits of addend represent alignment and the other bits of addend
represent the maximum number of bytes to emit.
2024-01-24 09:17:49 +08:00
Aiden Grossman
c41472dbaf [Github] Only run libclang-python-tests on monorepo main
The libclang python binding test CI job currently doesn't have any
restrictions on what branches it will run on when something is pushed
and also isn't restricted to the monorepo. This patch adds a branch
restriction for the push event, only running the CI job when something
is pushed to the main branch (and the path filter is met), and also adds
a filter to ensure that the job comes from a PR against the monorepo or
a push to a branch in the monorepo.
2024-01-23 16:53:54 -08:00
Aiden Grossman
b1778c7d7b
[AsmPrinter] Remove mbb-profile-dump flag (#76595)
Now that the work embedding PGO information in SHT_LLVM_BB_ADDR_MAP ELF
sections has landed, there is no longer a need to keep around the
mbb-profile-dump flag.
2024-01-23 16:48:10 -08:00
Jeffrey Byrnes
766e645d8d [SROA] NFC: Precommit test for pull/77678
Change-Id: I6b2346301f9bd840a0adceba4a0d03e9932af245
2024-01-23 16:37:35 -08:00
Jeff Niu
df1e01b316
[mlir] Add example of printAlias to test dialect (NFC) (#79232)
Follow-up from previous pull request. Motivate the API change with an
attribute that decides between sugaring a sub-attribute or using an
alias
2024-01-23 16:29:57 -08:00
Paul Kirth
03a61d34eb
[RISCV] Support TLSDESC in the RISC-V backend (#66915)
This patch adds basic TLSDESC support in the RISC-V backend.

Specifically, we add new relocation types for TLSDESC, as prescribed in 
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373, and add a
new pseudo instruction to simplify code generation.

This patch does not try to optimize the local dynamic case, which can be
improved in separate patches. 

Linker side changes will also be handled separately.

The current implementation is only enabled when passing the new
`-enable-tlsdesc` codegen flag.
2024-01-23 16:16:07 -08:00
Pete Lawrence
d657519838
[lldb] Improve maintainability and readability for ValueObject methods (#75865)
As I worked through changes to another PR
(https://github.com/llvm/llvm-project/pull/74912), I couldn't help but
rewrite a few methods for readability, maintainability, and possibly
some behavior correctness too.

1. Exiting early instead of nested `if`-statements, which:
	- Reduces indentation levels for all subsequent lines
	- Treats missing pre-conditions similar to an error
- Clearly indicates that the full length of the method is the "happy
path".
2. Explicitly return empty Value Object shared pointers for those error
(like) situations, which
- Reduces the time it takes a maintainer to figure out what the method
actually returns based on those conditions.

3. Converting a mix of `if` and `if`-`else`-statements around an enum
into one `switch` statement, which:
	- Consolidates the former branching logic
	- Lets the compiler warn you of a (future) missing enum case
- This one may actually change behavior slightly, because what was an
early test for one enum case, now happens later on in the `switch`.

4. Consolidating near-identical, "copy-pasta" logic into one place,
which:
	- Separates the common code to the diverging paths.
	- Highlights the differences between the code paths.



rdar://119833526
2024-01-23 16:07:52 -08:00
Alan Zhao
25e1916d88
[nfc][clang] Fix test in new-array-init.cpp (#79225)
This test was originally introduced in
https://github.com/llvm/llvm-project/pull/76976, but it incorrectly
tests braced-list initialization instead of parenthesized
initialization.
2024-01-23 15:42:49 -08:00
Jeffrey Byrnes
2a61be4e4c [SROA] NFC: Extract code to checkVectorTypesForPromotion
Change-Id: Ib6f237cc791a097f8f2411bc1d6502f11d4a748e
2024-01-23 15:40:20 -08:00
Nick Desaulniers
6a3ace20c8
[libc] remove redundant call_once (#79226)
Missed cleanup from https://reviews.llvm.org/D134716.

Fixes: #79220
2024-01-23 15:38:12 -08:00
Jeremy Morse
22da809602
[Docs][DebugInfo][RemoveDIs] Document some debug-info transition info (#79167)
This is a high level description and FAQ for what we're doing in
RemoveDIs, and how old code should be behave with new debug-info
(exactly the same 99% of the time).
2024-01-23 23:26:52 +00:00
Thurston Dang
a16f81f5e3 Revert "[ASan][libc++] Turn on ASan annotations for short strings (#79049)"
This reverts commit cb528ec5e6331ce207c7b835d7ab963bd5e13af7.

Reason: buildbot breakage (https://lab.llvm.org/buildbot/#/builders/5/builds/40364):
SUMMARY: AddressSanitizer: container-overflow /b/sanitizer-x86_64-linux-fast/build/libcxx_build_asan_ubsan/include/c++/v1/string:1870:29 in __get_long_pointer
2024-01-23 22:56:22 +00:00
Jeremy Morse
7fc2592823 [DebugInfo][RemoveDIs] "Final" cleanup for non-instr debug-info (#79121)
Here's a raft of minor fixes for the RemoveDIs project that's replacing
dbg.value intrinsics with DPValue objects, all IMO trivial:
 * When inserting functions or blocks and calling setIsNewDbgInfoFormat,
   do that after setting the Parent pointer, just in case conversion from
   (or to) dbg.value mode is triggered.
 * When transferring DPValues from an empty range in a splice call, don't
   transfer if there are no DPValues attached to the source block at all.
 * stripNonLineTableDebugInfo should drop DPValues.
 * In insertBefore, don't try to transfer DPValues if there aren't any.
2024-01-23 22:52:47 +00:00
Krzysztof Drewniak
750e90e440
[mlir][ArithToAMDGPU] Add option for saturating truncation to fp8 (#74153)
Many machine-learning applications (and most software written at AMD)
expect the operation that truncates floats to 8-bit floats to be
saturatinng. That is, they expect `truncf 256.0 : f32 to f8E4M3FNUZ` to
yield `240.0`, not `NaN`, and similarly for negative numbers. However,
the underlying hardware instruction that can be used for this truncation
implements overflow-to-NaN semantics.

To enable handling this usecase, we add the saturate-fp8-truncf option
to ArithToAMDGPU (off by default), which causes the requisite clamping
code to be emitted. Said clamping code ensures that Inf and NaN are
passed through exactly (and thus trancate to NaN).

Per review feedback, this commit efactors
createScalarOrSplatConstant() to the Arith dialect utilities and uses
it in this code. It also fixes naming of existing patterns and
switches from vector.extractelement/insertelement to
vector.extract/insert.
2024-01-23 16:52:21 -06:00
Aart Bik
575568de41
[mlir][sparse] adjust compression scheme for example (#79212) 2024-01-23 14:51:46 -08:00
Chris Apple
c28ab62743
[NFCI] Move SANITIZER_WEAK_IMPORT to sanitizer_common (#79208)
SANITIZER_WEAK_IMPORT is useful for any call that needs to be
conditionally linked in. This is currently used for the
tsan_dispatch_interceptors, but can be used for other calls introduced
in newer versions of MacOS. (such as `aligned_alloc` in this PR
https://github.com/llvm/llvm-project/pull/79198).

This PR moves the definition to a higher level so it can be used in
other sanitizers.
2024-01-23 14:42:59 -08:00
Changpeng Fang
1a300d6da3
AMDGPU: Add SourceOfDivergence for int_amdgcn_global_load_tr (#79218) 2024-01-23 14:30:11 -08:00
Shilei Tian
dc410f94f6
[Clang][Driver] Fix --save-temps for OpenCL AoT compilation (#78333)
We can directly call `clang -c -x cl -target amdgcn -mcpu=gfx90a test.cl
-o test.o`
to compile an OpenCL kernel file. However, when `--save-temps` is
enabled, it doesn't
work because the preprocessed file (`.i` file) is taken as C source file
when it
is fed to the front end, thus causing compilation error because those
OpenCL keywords
can't be recognized. This patch fixes the issue.
2024-01-23 17:08:04 -05:00
Utkarsh Saxena
729657d6e1
[misc-coroutine-hostile-raii] Use getOperand instead of getCommonExpr. (#79206)
We were previously allowlisting awaitable types returned by
`await_transform` instead of the type of the operand of the `co_await`
expression.

This previously used to give false positives and not respect the
`AllowedAwaitablesList` flag when `await_transform` is used. See added
test cases for such examples.
2024-01-23 23:07:00 +01:00
Paul Kirth
9d476e1e1a
[clang][FatLTO] Avoid UnifiedLTO until it can support WPD/CFI (#79061)
Currently, the UnifiedLTO pipeline seems to have trouble with several
LTO features, like SplitLTO units, which means we cannot use important
optimizations like Whole Program Devirtualization or security hardening
instrumentation like CFI.

This patch reverts FatLTO to using distinct pipelines for Full LTO and
ThinLTO. It still avoids module cloning, since that was error prone.
2024-01-23 14:04:52 -08:00
Louis Dionne
a829f109ff [libc++] Fix outdated release procedure for release notes 2024-01-23 17:00:11 -05:00
Billy Laws
2227e50c61
[Preprocessor][test] Test ARM64EC definitions (#78916) 2024-01-23 13:57:28 -08:00
Alex Langford
6c98c5bd99
[lldb][NFCI] Remove unused method BreakpointIDList::AddBreakpointID(const char *) (#79189)
This overload is completely unused.
2024-01-23 13:41:36 -08:00
Kunwar Grover
9261ab708e
[mlir][Target] Teach dense_resource conversion to LLVMIR Target (#78958)
This patch adds support for translating dense_resource attributes to
LLVMIR Target.
The support added is similar to how DenseElementsAttr is handled, except
we
don't need to handle splats.

Another possible way of doing this is adding iteration on
dense_resource, but that is
non-trivial as DenseResourceAttr is not meant to be something you should
directly
access. It has subclasses which you are supposed to use to iterate on
it.
2024-01-23 13:30:34 -08:00
William Junda Huang
2b8649fbec
Added feature in llvm-profdata merge to filter functions from the profile (#78378)
`--function=<regex>` Include functions matching regex in the output
`--no-function=<regex>` Exclude functions matching regex from the output

If both are specified, `--no-function` has a higher precedence if a
function name matches both filters
2024-01-23 16:19:45 -05:00
lntue
3a9ff32354
[libc] Fix implicit conversion in FEnvImpl for arm32 targets. (#79210) 2024-01-23 16:14:50 -05:00
Juergen Ributzka
4ad4c8e90e
[clang] Use LazyDetector for all toolchains. (#79073)
Use the LazyDetector also for the remaining toolchains to avoid unnecessarily checking for the Cuda and Rocm installations.

This fixes rdar://121397534.
2024-01-23 13:14:17 -08:00
RolandF77
4beea6b195
[PowerPC] lower partial vector store cost (#78358)
There are matching store opcodes (stfd, stxsiwx) for the load opcodes
that make 32-bit and 64-bit vector operations cheap with VSX, so stores
should also be cheap.
2024-01-23 16:07:18 -05:00
Fangrui Song
4fcd7cf22d [ELF,test] Actually fix defsym.ll 2024-01-23 12:52:36 -08:00
Fangrui Song
16343f0db2 [ELF,test] Fix defsym.ll 2024-01-23 12:49:57 -08:00
Alexey Bataev
bb3e0d7fc3 [SLP]Fix PR79193: skip analysis of gather nodes for minbitwidth.
No need in trying to analyze small graphs with gather node only to avoid
crash.
2024-01-23 12:44:49 -08:00
Florian Hahn
b504e97d92
[IndVars] Add NUW variants to iv-poison.ll and variants with extra uses. 2024-01-23 20:42:50 +00:00
Ben Hamilton (Ben Gertzfield)
d813af73f7
[Format] Fix detection of languages when reading from stdin (#79051)
The code cleanup in #74794 accidentally broke detection of languages by
reading file content from stdin, e.g. via `clang-format -dump-config - <
/path/to/filename`.

This PR adds unit and integration tests to reproduce the issue and adds
a fix.

Fixes: #79023
2024-01-23 13:32:41 -07:00
Louis Dionne
eabddf22e2
[libc++] Run the nightly libc++ build at 03:00 Eastern for real (#79184)
The nightly libc++ build was incorrectly set up to build at 22:00
Eastern when it intended to run at 03:00 Eastern. This patch fixes that.
2024-01-23 15:27:54 -05:00
lntue
d86a6eacf6
[libc] Fix aliasing function name got accidentally deleted in #79128. (#79203) 2024-01-23 14:19:34 -06:00
Craig Topper
f1abe78e6b [RISCV] Move FeatureStdExtH in RISCVFeatures.td. NFC
It was accidentally in the middle of the floating point extensions
after the recent reordering.
2024-01-23 12:18:14 -08:00
Roland McGrath
9122d19de4
Revert "[libc] Fix forward arm32 buildbot" (#79201)
Reverts llvm/llvm-project#79151, necessary to revert #79128, which broke
all production builds and landed without review.
2024-01-23 12:15:22 -08:00
Alex Langford
7ca8feb1b8
[lldb] Include SBFormat.h in LLDB.h (#79194)
This was likely overlooked when SBFormat was added.
2024-01-23 12:14:06 -08:00
Fangrui Song
f7669ba3d9
[ELF] --save-temps --lto-emit-asm: derive ELF/asm file names from bitcode file names
Port COFF's https://reviews.llvm.org/D78221 and
https://reviews.llvm.org/D137217 to ELF. For the in-process ThinLTO
link, `ld.lld --save-temps a.o d/b.o -o out` will create
ELF relocatable files `out.lto.a.o`/`d/out.lto.b.o` instead of
`out1.lto.o`/`out2.lto.o`. Deriving the LTO-generated relocatable file
name from bitcode file names helps debugging.

The relocatable file name from the first regular LTO partition does not
change: `out.lto.o`. The second, if present due to `--lto-partition=`,
changes from `out1.lto.o` to `lto.1.o`.

For an archive member, e.g. `d/a.a(coll.o at 8)`,
the relocatable file is `d/out.lto.a.a(coll.o at 8).o`.

`--lto-emit-asm` file names are changed similarly. `--lto-emit-asm -o
out` now creates `out.lto.s` instead of `out`, therefore the
`--lto-emit-asm -o -` idiom no longer works. However, I think this new
behavior (which matches COFF) is better since keeping or removing
`--lto-emit-asm` will dump different files, instead of overwriting the
`-o` output file from an executable/shared object to an assembly file.

Reviewers: rnk, igorkudrin, xur-llvm, teresajohnson, ZequanWu

Reviewed By: teresajohnson

Pull Request: https://github.com/llvm/llvm-project/pull/78835
2024-01-23 11:38:15 -08:00
Tom Stellard
f6ced3579a
[CMake][Release] Add option for enabling PGO to release cache file. (#78823)
The option is LLVM_RELEASE_ENABLE_PGO and it's turned on by default.

---------

Co-authored-by: Petr Hosek <phosek@google.com>
2024-01-23 11:32:37 -08:00
Fangrui Song
17bc449784 [ELF] Improve thin-archivecollision.ll 2024-01-23 11:26:22 -08:00
AtariDreams
3c20e25b0c
[NFC] Size and element numbers are often swapped when calling calloc (#79081)
gcc-14 will now throw a warning if size and elements are swapped.
2024-01-23 11:13:55 -08:00
Philip Reames
f05dd29cee [RISCV] Regenerate autogen test to remove spurious diff 2024-01-23 10:57:54 -08:00
Philip Reames
bdc41106ee
[RISCV] Recurse on first operand of two operand shuffles (#79180)
This is the first step towards an alternate shuffle lowering design for
the general two vector argument case. The goal is to leverage the
existing lowering for single vector permutes to avoid as many of the
vrgathers as required - even if we do need the other.

This patch handles only the first argument, and is arguably a slightly
weird half-step. However, the test changes from the full two argument
recurse patch are a lot harder to reason about. Taking this half step
gives much more easily reviewable changes, and is thus worthwhile. I
intend to post the patch for the second argument once this has landed.
2024-01-23 10:49:55 -08:00
Martin Storsjö
50d33c62ad
[LLD] [COFF] Fix crashes for cfguard with undefined weak symbols (#79063)
When marking symbols as having their address taken, we can have the
sitaution where we have the address taken of a weak symbol. If there's
no strong definition of the symbol, the symbol ends up as an absolute
symbol with the value null. In those cases, we don't have any Chunk.
Skip such symbols from the cfguard tables.

This fixes https://github.com/llvm/llvm-project/issues/78619.
2024-01-23 20:37:03 +02:00
Philip Reames
bb8a8770e2
[RISCV] Exploit register boundaries when lowering shuffle with exact vlen (#79072)
If we have a shuffle which is larger than m1, we may be able to split it
into a series of individual m1 shuffles. This patch starts with the
subcase where the mask allows a 1-to-1 mapping from source register to
destination register - each with a possible permutation of their own. We
can potentially extend this later, thought in practice this seems to
already catch a number of the most interesting cases.
2024-01-23 10:36:22 -08:00
Schrodinger ZHU Yifan
0cf20c2971
[libc] fix sysconf (#79159)
Apply previously discussed fix for `sysconf`
2024-01-23 13:31:48 -05:00
Tacet
cb528ec5e6
[ASan][libc++] Turn on ASan annotations for short strings (#79049)
Originally merged here: https://github.com/llvm/llvm-project/pull/75882
Reverted here: https://github.com/llvm/llvm-project/pull/78627

Reverted due to failing buildbots. The problem was not caused by the
annotations code, but by code in the `UniqueFunctionBase` class and in
the `JSON.h` file. That code caused the program to write to memory that
was already being used by string objects, which resulted in an ASan
error.

Fixes are implemented in:
- https://github.com/llvm/llvm-project/pull/79065
- https://github.com/llvm/llvm-project/pull/79066

Problematic code from `UniqueFunctionBase` for example:
```cpp
#ifndef NDEBUG
    // In debug builds, we also scribble across the rest of the storage.
    memset(RHS.getInlineStorage(), 0xAD, InlineStorageSize);
#endif
```

---

Original description:

This commit turns on ASan annotations in `std::basic_string` for short
stings (SSO case).

Originally suggested here: https://reviews.llvm.org/D147680

String annotations added here:
https://github.com/llvm/llvm-project/pull/72677

Requires to pass CI without fails:
- https://github.com/llvm/llvm-project/pull/75845
- https://github.com/llvm/llvm-project/pull/75858

Annotating `std::basic_string` with default allocator is implemented in
https://github.com/llvm/llvm-project/pull/72677 but annotations for
short strings (SSO - Short String Optimization) are turned off there.
This commit turns them on. This also removes
`_LIBCPP_SHORT_STRING_ANNOTATIONS_ALLOWED`, because we do not plan to
support turning on and off short string annotations.

Support in ASan API exists since
dd1b7b797a.
You can turn off annotations for a specific allocator based on changes
from
2fa1bec7a2.

This PR 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` and `std::deque` collections. These
enhancements empower ASan to effectively detect instances where the
instrumented program attempts to access memory within a collection's
internal allocation that remains unused. This includes cases where
access occurs before or after the stored elements in `std::deque`, or
between the `std::basic_string`'s size (including the null terminator)
and capacity bounds.

The introduction of these annotations was spurred by a real-world
software bug discovered by Trail of Bits, involving an out-of-bounds
memory access during the comparison of two strings using the
`std::equals` function. This function was taking iterators
(`iter1_begin`, `iter1_end`, `iter2_begin`) to perform the comparison,
using a custom comparison function. When the `iter1` object exceeded the
length of `iter2`, an out-of-bounds read could occur on the `iter2`
object. Container sanitization, upon enabling these annotations, would
effectively identify and flag this potential vulnerability.

If you have any questions, please email:

    advenam.tacet@trailofbits.com
    disconnect3d@trailofbits.com
2024-01-23 19:18:53 +01:00