6982 Commits

Author SHA1 Message Date
Rahul Joshi
f5eaadc38b
[NFC] Fix line endings for ModRef.cpp/OptionStrCmp.cpp (#109712) 2024-09-23 21:17:04 -07:00
Fangrui Song
b84d773fd0 [Parallel] Revert sequential task changes
https://reviews.llvm.org/D148728 introduced `bool Sequential` to unify
`execute` and the old `spawn` without argument. However, sequential
tasks might be executed by any worker thread (non-deterministic),
leading to non-determinism output for ld.lld -z nocombreloc (see
https://reviews.llvm.org/D133003).

In addition, the extra member variables have overhead.
This sequential task has only been used for lld parallel relocation
scanning.

This patch restores the behavior before https://reviews.llvm.org/D148728 .

Fix #105958

Pull Request: https://github.com/llvm/llvm-project/pull/109084
2024-09-20 21:15:42 -07:00
Abhina Sreeskantharajan
efdb3ae232 Revert "[SystemZ][z/OS] Propagate IsText parameter to open text files as text (#107906)"
This reverts commit edf3b277a5f2ebe144827ed47463c22743cac5f9.
2024-09-20 08:18:16 -04:00
Abhina Sreeskantharajan
d6f91200fe Revert "[SystemZ][z/OS] Propagate IsText flag continuation"
This reverts commit 3b3accb598ec87a6a30b0e18ded06071030bb78f.
2024-09-20 08:17:45 -04:00
Abhina Sreeskantharajan
3b3accb598 [SystemZ][z/OS] Propagate IsText flag continuation 2024-09-19 15:16:08 -04:00
Abhina Sree
edf3b277a5
[SystemZ][z/OS] Propagate IsText parameter to open text files as text (#107906)
This patch adds an IsText parameter to the following functions
openFileForRead, getBufferForFile, getBufferForFileImpl and determines
whether a file is text by querying the file tag on z/OS. The default is
set to OF_Text instead of OF_None, this change in value does not affect
any other platforms other than z/OS.
2024-09-19 14:30:10 -04:00
Jay Foad
e03f427196
[LLVM] Use {} instead of std::nullopt to initialize empty ArrayRef (#109133)
It is almost always simpler to use {} instead of std::nullopt to
initialize an empty ArrayRef. This patch changes all occurrences I could
find in LLVM itself. In future the ArrayRef(std::nullopt_t) constructor
could be deprecated or removed.
2024-09-19 16:16:38 +01:00
Rahul Joshi
2f7ffbaad3
[Support] Fix bugs in formatv automatic index assignment (#108384)
Fix bugs found when actually trying to use formatv() automatic index
assignment in IntrinsicEmitter.cpp:
- Assign automatic index only for `ReplacementType::Format`.
- Make the check for all replacement indices being either automatic orexplicit more accurate.
  The existing check fails for formatv("{}{0}{}", 0, 1) (added as a unit test). Explicitly track if we
  have seen any explicit and any automatic index instead.
2024-09-16 21:48:05 -07:00
Rahul Joshi
d3cdf0f222
[LLVM][Option] Refactor option name comparison (#108219)
Move common functions shared by TableGen Option Emitter
and Options library to Support:
- Move `StrCmpOptionName` and base it on the existing version
  in OptTable.cpp, with an additional mode to control fall back to
  case insensitive comparison.
- Add `StrCmpOptionPrefixes` to compare prefixes and use zip() to
  iterate through lists of prefixes.
- Rename `CompareOptionRecords` to less ambiguous name 
  `IsOptionRecordLess`.
- Merge 2 back-to-back ifs with same condition in
  `IsOptionRecordLess`.

Fixes https://github.com/llvm/llvm-project/issues/107723
2024-09-13 17:30:19 -07:00
Rahul Joshi
d5d6b44784
[Support] Add automatic index assignment in formatv (#107459)
Make index in replacement field optional. It will be automatically
assigned in incremental order by formatv.

Make mixed use of automatic and explicit indices an error that will fail
validation.
Adopt uses of formatv() within FormatVariadic to use automatic index.
2024-09-12 04:38:36 -07:00
Brad Smith
1c334debec
[llvm][Support] Determine the max thread length on Haiku (#107801)
Haiku has pthread_setname_np() / pthread_getname_np().
2024-09-10 03:12:38 -04:00
Abhina Sree
eec1ee8ef1
[SystemZ][z/OS] Enable lit testing for z/OS (#107631)
This patch fixes various errors to enable llvm-lit to run on z/OS
2024-09-09 14:37:53 -04:00
Samuel Thibault
620b8d994b
[hurd] Fix accessing f_type field of statvfs (#71851)
f4719c4d2cda ("Add support for GNU Hurd in Path.inc and other places")
made llvm use an internal __f_type name for the f_type field (which it
is not supposed to since accessing double-underscore names is explicitly
not supported by standards). In glibc 2.39 this field was renamed to
f_type so application can now access the field as the standard says.
2024-09-09 06:53:33 -07:00
Jan Svoboda
70fcdb3d52
[llvm][support] Implement tracing virtual file system (#88326)
LLVM-based tools often use the `llvm::vfs::FileSystem` instrastructure
to access the file system. This patch adds new kind of a VFS that
performs lightweight tracing of file system operations on an underlying
VFS. This is supposed to aid in investigating file system traffic
without resorting to instrumentation on the operating system level.
There will be follow-up patches that integrate this into Clang and its
dependency scanner.
2024-09-06 14:14:44 -07:00
Kazu Hirata
169d453429
[ADT] Declare replaceAllocation in SmallVector.cpp (NFC) (#107469)
This patch changes replaceAllocation to a static function while moving
the declaration to SmallVector.cpp.  Note that:

- replaceAllocation is used only within SmallVector.cpp.
- replaceAllocation doesn't access any class members.
2024-09-05 15:47:28 -07:00
Abhina Sree
311ac63816
[NFC][SystemZ][z/OS] Rename autoconversion-related functions to be less generic (#107399)
This patch renames the functions in AutoConvert.h/cpp to have a less
generic name because they are z/OS specific.
2024-09-05 13:25:06 -04:00
Rahul Joshi
c2018fa40f
[NFC][Support] Refactor FormatVariadic code. (#106610)
- Rename `Align` field in ReplacementItem/FmtAlign to `Width` to 
  accurately reflect its use.
- Change both `Width` and `Index` in ReplacementItem to 32-bit int 
  instead of size_t (as 64-bits seems excessive in this context).
- Eliminate the use of `Empty` ReplacementType, and use the
  existing std::optional<> instead to indicate that.
- Eliminate some boilerplate type code in formatv().
- Eliminate the loop in `splitLiteralAndReplacement`. The existing
  code will never loop back.
- Directly use constructor instead of std::make_pair.
2024-09-05 09:01:19 -07:00
Princeton Ferro
427e202a40
[APInt] improve initialization performance (#106945)
The purpose is to save an extra memset in both cases:

1. When `int64_t(val) < 0`, zeroing out is redundant as the subsequent
for-loop will initialize to `val .. 0xFFFFF ....`. Instead we should
only create an uninitialized buffer, and transform the slow for-loop
into a memset to initialize the higher words to `0xFF`.
2. In the other case, first we create an uninitialized array (`new
int64_t[]`) and _then_ we zero it out with `memset`. But this can be
combined in one operation with `new int64_t[]()`, which
default-initializes the array.

On one example where use of APInt was heavy, this improved compile time
by 1%.
2024-09-04 08:54:36 +02:00
Brad Smith
1e65b76587
[llvm][Support] Add support for thread naming under DragonFly BSD and Solaris/illumos (#106944) 2024-09-02 06:17:40 -04:00
Brad Smith
d7100111f4
[llvm][Support] Adjust maximum thread name length to the right value for OpenBSD (#106956)
The thread name length is derived from _MAXCOMLEN which is 24.
2024-09-02 06:02:24 -04:00
Nikita Popov
30cc198c2d
[APInt] Add default-disabled assertion to APInt constructor (#106524)
If the uint64_t constructor is used, assert that the value is actually a
signed or unsigned N-bit integer depending on whether the isSigned flag
is set. Provide an implicitTrunc flag to restore the previous behavior,
where the argument is silently truncated instead.

In this commit, implicitTrunc is enabled by default, which means that
the new assertions are disabled and no actual change in behavior occurs.
The plan is to flip the default once all places violating the assertion
have been fixed. See #80309 for the scope of the necessary changes.

The primary motivation for this change is to avoid incorrectly specified
isSigned flags. A recurring problem we have is that people write
something like `APInt(BW, -1)` and this works perfectly fine -- until
the code path is hit with `BW > 64`. Most of our i128 specific
miscompilations are caused by variants of this issue.

The cost of the change is that we have to specify the correct isSigned
flag (and make sure there are no excess bits) for uses where BW is
always <= 64 as well.
2024-09-02 09:48:54 +02:00
Brad Smith
d2ce9dc85e
Add support for retrieving the thread ID on DragonFly BSD (#106938) 2024-09-02 02:38:23 -04:00
Brad Smith
647f892a72
[llvm][Support] Simplify HAVE_PTHREAD_GETNAME/SETNAME_NP handling. NFCI (#106486) 2024-09-02 00:29:24 -04:00
Matt Bolitho
bec1d86516
[CMake][Support] Use /nologo when compiling BLAKE3 assembly sources on Windows (#106794)
Suppresses the copyright banner for `ml64` compiling BLAKE3 assembly
sources with MSVC and Ninja on Windows:

```
[157/3758] Building ASM_MASM object lib\Support\BLAKE3\CMa...upportBlake3.dir\blake3_avx512_x86-64_windows_msvc.asm.obj
Microsoft (R) Macro Assembler (x64) Version 14.41.34120.0
Copyright (C) Microsoft Corporation.  All rights reserved.

 Assembling: C:\path\to\llvm-project\llvm\lib\Support\BLAKE3\blake3_avx512_x86-64_windows_msvc.asm
```

is now just:

```
 Assembling: C:\path\to\llvm-project\llvm\lib\Support\BLAKE3\blake3_avx512_x86-64_windows_msvc.asm
```

We can suppress that last line with `/quiet` in more recent versions of
`ml64` (from MSVC 2022 17.6) but it is not supported by all potential
MASM compilers.
2024-09-01 12:51:44 +03:00
Daniil Fukalov
89e6a28867
[NFC] Add explicit #include llvm-config.h where its macros are used. (#106621)
Without these explicit includes, removing other headers, who implicitly
include llvm-config.h, may have non-trivial side effects.
2024-08-30 09:35:06 +02:00
Rahul Joshi
9ce4af5cad
Revert "Revert "[Support] Validate number of arguments passed to formatv()"" (#106592)
Reverts llvm/llvm-project#106589
The fix for bot failures caused by the reverted commit was committed
already, so this revert is not needed.
2024-08-29 10:39:40 -07:00
Mehdi Amini
ed37b5f6c3
Revert "[Support] Validate number of arguments passed to formatv()" (#106589)
Reverts llvm/llvm-project#105745

Some bots are broken apparently.
2024-08-29 10:30:11 -07:00
Rahul Joshi
115b87636b
[NFC][Support] Eliminate ',' at end of MemoryEffects print (#106545)
- Eliminate comma at end of a MemoryEffects print.
- Added basic unit test to validate that.
2024-08-29 09:28:45 -07:00
Rahul Joshi
fc110202df
[Support] Validate number of arguments passed to formatv() (#105745)
Change formatv() to validate that the number of arguments passed matches
number of replacement fields in the format string, and that the replacement
indices do not contain holes.

To support cases where this cannot be guaranteed, introduce a formatv()
overload that allows disabling validation with a bool flag as its first argument.
2024-08-29 08:00:25 -07:00
Luke Shingles
fcb3a04858
[analyzer] Add missing include <unordered_map> to llvm/lib/Support/Z3Solver.cpp (#106410)
Resolves #106361. Adding #include <unordered_map> to
llvm/lib/Support/Z3Solver.cpp fixes compilation errors for homebrew
build on macOS with Xcode 14.
https://github.com/Homebrew/homebrew-core/actions/runs/10604291631/job/29390993615?pr=181351
shows that this is resolved when the include is patched in (Linux CI
failure is due to unrelated timeout).
2024-08-29 06:09:07 -04:00
Kazu Hirata
33e7cd6ff2
[llvm] Prefer StringRef::substr to StringRef::slice (NFC) (#105943)
S.substr(N) is simpler than S.slice(N, StringRef::npos) and
S.slice(N, S.size()). Also, substr is probably better recognizable
than slice thanks to std::string_view::substr.
2024-08-25 11:30:49 -07:00
NAKAMURA Takumi
3ef64f7ab5 Revert "Enable logf128 constant folding for hosts with 128bit long double (#104929)"
ConstantFolding behaves differently depending on host's `HAS_IEE754_FLOAT128`.
LLVM should not change the behavior depending on host configurations.

This reverts commit 14c7e4a1844904f3db9b2dc93b722925a8c66b27.
(llvmorg-20-init-3262-g14c7e4a18449 and llvmorg-20-init-3498-g001e423ac626)
2024-08-25 08:30:23 +09:00
Matthew Devereau
14c7e4a184
Enable logf128 constant folding for hosts with 128bit long double (#104929)
This is a reland of (#96287). This patch attempts to reduce the reverted
patch's clang compile time by removing #includes of float128.h and
inlining convertToQuad functions instead.
2024-08-22 10:12:59 +01:00
Rahul Joshi
0cff3e85db
[NFC][Support] Move ModRef/MemoryEffects printers to their own file (#105367)
- Move raw_ostream << operators for `ModRef` and `MemoryEffects` to a
new ModRef.cpp file under llvm/Support (instead of AliasAnalysis.cpp)

- This enables calling these operators from `Core` files like
Instructions.cpp (for instance for debugging). Currently, they live in
`LLVMAnalysis` which cannot be linked with `Core`.
2024-08-21 04:26:34 -07:00
Fangrui Song
7c06786479
[CMake] Remove HAVE_LINK_H
We can remove the variable from https://reviews.llvm.org/D5610 since
link.h is available on Linux (glibc/musl/Bionic), FreeBSD, and NetBSD.
Use `__has_include(<link.h>)` before including it.

Pull Request: https://github.com/llvm/llvm-project/pull/104893
2024-08-20 08:50:24 -07:00
Rahul Joshi
f5664f585b
[Support] Do not ignore unterminated open { in formatv (#104688)
- When an unterminated open { is detected in the format string, instead
of asserting and ignoring the error, replace that string with another to
indicate the error, and remove the assert as well.
- This will make the error evident in both assert and release builds and
make observing the error more convenient (as several uses of this
function are in TableGen and it is often built in release mode even in
debug builds)
2024-08-19 15:31:24 -07:00
Fangrui Song
a3fea0643d
[SmallPtrSet] Optimize find/erase
Port #100517 for DenseMap.

Pull Request: https://github.com/llvm/llvm-project/pull/104740
2024-08-19 09:42:14 -07:00
Jacques Pienaar
0d150db214
[llvm][clang] Move RewriterBuffer to ADT. (#99770)
These classes are not specific to clang and useful for other rewriter
tools (flagged in previous review).
2024-08-18 09:46:51 -07:00
Nikita Popov
6300233de1 Revert "Reland logf128 constant folding (#103217)"
This reverts commit 3cab7c555ad6451f2b1b4dc918a4b4f4e4a3e45d.

The modified test fails on ppc64le buildbots.
2024-08-14 12:30:33 +02:00
Matthew Devereau
3cab7c555a
Reland logf128 constant folding (#103217)
This is a reland of #96287. This change makes tests in logf128.ll ignore
the sign of NaNs for negative value tests and moves an #include <cmath>
to be blocked behind #ifndef _GLIBCXX_MATH_H.
2024-08-14 08:55:52 +01:00
Craig Topper
cbd306806a
[APInt] Correct backwards static_assert condition. (#103641)
In order to guarantee that extracting 64 bits doesn't require more than
2 words, the word size would need to be 64 bits or more. If the word
size was smaller than 64, like 32, you may need to read 3 words to get
64 bits.
2024-08-14 00:28:24 -07:00
Craig Topper
7f1f3afd37 [APInt] Use APINT_BITS_PER_WORD instead of recomputing it. NFC 2024-08-13 22:12:37 -07:00
Fangrui Song
a3cba6b5db [Support] ThreadPoolExecutor: remove unused default argument 2024-08-13 17:49:57 -07:00
Fangrui Song
9487cf97e3
[Support] Restrict ManagedStatic ThreadPoolExecutor to Windows
https://reviews.llvm.org/D70447 switched to `ManagedStatic` to work
around race conditions in MSVC runtimes and the MinGW runtime.
However, `ManagedStatic` is not suitable for other platforms.

However, this workaround is not suitable for other platforms (#66974).
lld::fatal calls exitLld(1), which calls `llvm_shutdown` to destroy
`ManagedStatic` objects. The worker threads will finish and invoke TLS
destructors (glibc `__call_tls_dtors`). This can lead to race conditions
if other threads attempt to access TLS objects that have already been
destroyed.

While lld's early exit mechanism needs more work, I believe Parallel.cpp
should avoid this pitfall as well.

Pull Request: https://github.com/llvm/llvm-project/pull/102989
2024-08-13 17:02:03 -07:00
Rahul Joshi
136e5f4850
[NFC][Support] Create helper function to parse bool (#102818)
Create a helper template function to parse bool, to eliminate code
duplication.
2024-08-12 20:49:18 -07:00
Nikita Popov
a15de17772 Revert "Enable logf128 constant folding for hosts with 128bit floats (#96287)"
This reverts commit ccb2b011e577e861254f61df9c59494e9e122b38.

Causes buildbot failures, e.g. on ppc64le builders.
2024-08-09 15:12:11 +02:00
Matthew Devereau
ccb2b011e5
Enable logf128 constant folding for hosts with 128bit floats (#96287)
Hosts which support a float size of 128 bits can benefit from constant
fp128 folding.
2024-08-09 11:12:43 +01:00
David Tenty
899f648866
[NFC][llvm][support] rename INFINITY in regcomp (#101758)
since C23 this macro is defined by float.h, which clang implements in
it's float.h since #96659 landed.

However, regcomp.c in LLVMSupport happened to define it's own macro with
that name, leading to problems when bootstrapping. This change renames
the offending macro.
2024-08-08 11:16:18 -04:00
Kazu Hirata
7df9da7d78
[llvm] Construct SmallVector with ArrayRef (NFC) (#101872) 2024-08-04 08:54:23 -07:00
Piotr Fusik
1c1b8c20c2
[ELFAttributeParser][NFC] Make string arrays const (#101460) 2024-08-02 18:37:05 +02:00