7016 Commits

Author SHA1 Message Date
Wu Yingcong
5ed09d552d
[Support] Check zstd decompress result before msan unpoison (#117276)
We should check the zstd decompress result before doing the msan
unpoison. If the res is abnormal, then it would be a huge number, which
will cause undesired msan unpoison behavior and will run for a long
time.
2024-11-25 08:59:17 +08:00
Abhina Sreeskantharajan
9cada10911 [SystemZ][z/OS] Add back removed AutoConvert.h headers that were incorrectly identified as unused to fix a build error on z/OS 2024-11-21 08:23:45 -05:00
Florian Hahn
5174d00365
[llvm] Add back Allocator.h include to RWMutex.cpp.
This unbreaks the build on macOS.

Without the include, the build fails with

llvm/lib/Support/RWMutex.cpp:47:36: error: use of undeclared identifier 'safe_malloc'
   47 |
   static_cast<pthread_rwlock_t*>(safe_malloc(sizeof(pthread_rwlock_t)));
         |                                    ^
2024-11-20 15:00:11 +00:00
Kazu Hirata
d44ea7186b
[Support] Remove unused includes (NFC) (#116752)
Identified with misc-include-cleaner.
2024-11-20 06:51:43 -08:00
Matthias Springer
309c890921
[llvm] APFloat: Add helpers to query NaN/inf semantics (#116315)
`APFloat` changes extracted from #116176 as per reviewer comments.
2024-11-16 11:48:05 +09:00
Matthias Springer
2f55de4e31
[llvm] APFloat: Query hasNanOrInf from semantics (#116158)
Whether a floating point type supports NaN or infinity can be queried
from its semantics. No need to hard-code a list of types.
2024-11-15 09:29:54 +09:00
Kazu Hirata
4048c64306
[llvm] Remove redundant control flow statements (NFC) (#115831)
Identified with readability-redundant-control-flow.
2024-11-12 10:09:42 -08:00
goldsteinn
877cb9a2ed
[KnownBits] Make {s,u}{add,sub}_sat optimal (#113096)
Changes are:
    1) Make signed-overflow detection optimal
    2) For signed-overflow, try to rule out direction even if we can't
       totally rule out overflow.
    3) Intersect add/sub assuming no overflow with possible overflow
       clamping values as opposed to add/sub without the assumption.
2024-11-05 09:03:37 -06:00
Daniel Sanders
5b356f27a0 Trivial change llvm::CreateInfoOutputFile() to return raw_ostream. NFC
This is NFC w.r.t upstream but allows us to return raw_null_ostream in our
downstream fork without changing the interface.
2024-10-31 11:22:22 -07:00
Simon Pilgrim
03948882d3 Fix MSVC "32-bit shift implicitly converted to 64 bits" warning. NFC
NumBits should be less than 20 so using an unsigned instead of size_t should be OK
2024-10-30 10:12:57 +00:00
Steven Wu
ba8d9ce8d4
[ADT] Fix unused variable from #69528 (#114114)
Remove unused variable to fix build failures from bot.
2024-10-29 13:00:59 -07:00
Steven Wu
b510cdb895
[ADT] Add TrieRawHashMap (#69528)
Implement TrieRawHashMap can be used to store object with its associated
hash. User needs to supply a strong hashing function to guarantee the
uniqueness of the hash of the objects to be inserted. A hash collision
is not supported and will lead to error or failed to insert.

TrieRawHashMap is thread-safe and lock-free and can be used as
foundation data structure to implement a content addressible storage.
TrieRawHashMap owns the data stored in it and is designed to be:
* Fast to lookup.
* Fast to "insert" if the data has already been inserted.
* Can be used without lock and doesn't require any knowledge of the
participating threads or extra coordination between threads.

It is not currently designed to be used to insert unique new data with
high contention, due to the limitation on the memory allocator.
2024-10-29 10:29:39 -07:00
Kazu Hirata
ec2da0ca19
[ADT] Use data() and size() within StringRef (NFC) (#113657)
This patch uses data() and size() within StringRef instead of Data and
Length.  This makes it easier to replace Data and Length with
std::string_view in the future, which in turn allows us to forward
most of StringRef functions to the counterparts in std::string_view.
2024-10-25 19:37:55 -07:00
Kazu Hirata
141574bacb
[llvm] Remove redundant calls to std::unique_ptr<T>::get (NFC) (#113415) 2024-10-23 10:44:09 -07:00
Mészáros Gergely
7ab6d39a4d
[LLVM][CMake][MSVC] Wrap linker flags for ICX on Windows (#112680)
The Intel C++ Compiler (ICX) passes linker flags through the driver
unlike MSVC and clang-cl, and therefore needs them to be prefixed with
`/Qoption,link` (the equivalent of `-Wl,` for gcc on *nix).

Use `LINKER:` prefix wherever supported by cmake, when that's not
possible fall-back to `${CMAKE_CXX_LINKER_WRAPPER_FLAG}`. CMake replaces
these with `/Qoption,link` for ICX and with the empty string for MSVC
and clang-cl.

For `target_link_libraries` neither `LINKER:` (not supported prior to
CMake 3.32) nor `${CMAKE_CXX_LINKER_WRAPPER_FLAG}` (does not begin with
`-` would be taken as a library name) works, use `-Qoption,link`
directly within a conditional generator expression that we're linking
with ICX.

For MSVC and clang-cl no functional change is intended.

Tested by compiling with ICX and setting
`CMAKE_(EXE|SHARED|STATIC|MODULE)_LINKER_FLAGS_INIT` to
`-Werror=unknown-argument`.

RFC:
https://discourse.llvm.org/t/rfc-cmake-linker-flags-need-wl-equivalent-for-intel-c-icx-on-windows/82446
2024-10-23 13:03:25 +02:00
Sergey Kozub
7b308b18c3
Fix bitcasting E8M0 APFloat to APInt (#113298)
Fixes a bug in APFloat handling of E8M0 type (zero mantissa).

Related PRs:
- https://github.com/llvm/llvm-project/pull/107127
- https://github.com/llvm/llvm-project/pull/111028
2024-10-22 19:15:29 +02:00
Abhina Sree
46dc91e7d9
[SystemZ][z/OS] Add new openFileForReadBinary function, and pass IsText parameter to getBufferForFile (#111723)
This patch adds an IsText parameter to the following getBufferForFile,
getBufferForFileImpl. We introduce a new virtual function
openFileForReadBinary which defaults to openFileForRead except in
RealFileSystem which uses the OF_None flag instead of OF_Text.

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. Setting this
parameter correctly is required to open files on z/OS in the correct
encoding. The IsText parameter is based on the context of where we open
files, for example, in the ASTReader, HeaderMap requires that files
always be opened in binary even though they might be tagged as text.
2024-10-21 08:20:22 -04:00
Kazu Hirata
d1401822e2
[Support] Use a hetrogenous lookup with std::map (NFC) (#113075) 2024-10-20 10:42:53 -07:00
Luke Drummond
b55c52c047 Revert "Renormalize line endings whitespace only after dccebddb3b80"
This reverts commit 9d98acb196a40fee5229afeb08f95fd36d41c10a.
2024-10-18 21:16:50 +01:00
Luke Drummond
9d98acb196 Renormalize line endings whitespace only after dccebddb3b80
Line ending policies were changed in the parent, dccebddb3b80. To make
it easier to resolve downstream merge conflicts after line-ending
policies are adjusted this is a separate whitespace-only commit. If you
have merge conflicts as a result, you can simply `git add --renormalize
-u && git merge --continue` or `git add --renormalize -u && git rebase
--continue` - depending on your workflow.
2024-10-17 14:49:26 +01:00
NAKAMURA Takumi
83953c7df1 APInt.cpp: Prune a stray semicolon. 2024-10-17 20:04:00 +09:00
David Blaikie
f796a0c7c9
[formatv] Leave format parameters unstripped (#112625)
This is consistent with std::formatv and allows formatters to support a
wider variety of use cases (like having a bare string in their formatter
if that's useful, etc).

Came up in the context of some Carbon diagnostic work here:
https://github.com/carbon-language/carbon-lang/pull/4411#discussion_r1803688859
2024-10-16 15:53:52 -07:00
Thomas Fransham
9093ba9f7e
[Support] Include Support/thread.h before api implementations (#111175)
This header was included after the implementations to work around an
issue with FreeBSD, however, , this causes some issues when
dllexport\explicit visibility
attributes will be added to the headers on Windows, since the
definitions need to see the declarations for the attributes to apply.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on
windows.

---------

Co-authored-by: Tom Stellard <tstellar@redhat.com>
2024-10-10 07:45:29 +03:00
Ariel-Burton
3b7091bcf3
[APFloat] add predicates to fltSemantics for hasZero and hasSignedRepr (#111451)
We add static methods to APFloatBase to allow the hasZero and
hasSignedRepr properties of fltSemantics to be obtained.
2024-10-09 08:37:40 -04:00
Yingwei Zheng
6004f5550c
[ADT][APFloat] Make sure EBO is performed on APFloat (#111641)
Since both APFloat and (Double)IEEEFloat inherit from APFloatBase, empty
base optimization is not performed by GCC/Clang (Minimal reproducer:
https://godbolt.org/z/dY8cM3Wre). This patch removes inheritance
relation between (Double)IEEEFloat and APFloatBase to make sure EBO is
performed on APFloat. After this patch, the size of `ConstantFPRange`
will be reduced from 72 to 56.

Address comment
https://github.com/llvm/llvm-project/pull/111544#discussion_r1792398427.
2024-10-09 16:39:02 +08:00
Timm Baeder
a579782a77
[llvm] Add serialization to uint32_t for FixedPointSemantics (#110288)
FixedPointSemantics is exactly 32bits and this static_assert'ed after
its declaration. Add support for converting it to and from a uint32_t.
2024-10-09 05:44:19 +02:00
ivanaivanovska
871f69f0b6
[TimeProfiler] Added instant events to llvm TimeProfiler. (#103039)
This adds support for adding instant events to the TimeProfiler. Later we plan to use it to record deferring of template instantiations.
2024-10-08 13:04:39 +02:00
Craig Topper
bcb15d0059
[APInt] Slightly simplify APInt::ashrSlowCase. NFC (#111220)
Use an arithmetic shift for the last word copy when BitShift!=0. This
avoids an explicit sign extend after the shift.
2024-10-05 10:25:50 -07:00
Kyungwoo Lee
ed59d571f2
[ThinLTO][NFC] Refactor FileCache (#110463)
This is a prep for https://github.com/llvm/llvm-project/pull/90933.
 
  - Change `FileCache` from a function to a type.
  - Store the cache directory in the type, which will be used when creating additional caches for two-codegen round runs that inherit this value.
2024-10-04 07:50:28 -07:00
William Moses
8bcf79914b
Fix have pthread_getname for some system (#110854)
I'm on a system that has have_pthread_getname_np defined but set to 0.
The correct behavior here is not to use the function, but presently the
macros will attempt to use a non-existing function.

This previously worked before
https://github.com/llvm/llvm-project/pull/106486/files
2024-10-03 08:13:53 -05:00
Durgadoss R
99f527d280
[APFloat] Add APFloat support for E8M0 type (#107127)
This patch adds an APFloat type for unsigned E8M0 format. This format is
used for representing the "scale-format" in the MX specification:
(section 5.4)

https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf

This format does not support {Inf, denorms, zeroes}. Like FP32, this
format's exponents are 8-bits (all bits here) and the bias value is 127.
However, it differs from IEEE-FP32 in that the minExponent is -127
(instead of -126). There are updates done in the APFloat utility
functions to handle these constraints for this format.

* The bias calculation is different and convertIEEE* APIs are updated to
handle this.
* Since there are no significand bits, the isSignificandAll{Zeroes/Ones}
methods are updated accordingly.
* Although the format does not have any precision, the precision bit in
the fltSemantics is set to 1 for consistency with APFloat's internal
representation.
* Many utility functions are updated to handle the fact that this format
does not support Zero.
* Provide a separate initFromAPInt() implementation to handle the quirks
of the format.
* Add specific tests to verify the range of values for this format.

Signed-off-by: Durgadoss R <durgadossr@nvidia.com>
2024-10-02 23:04:21 +05:30
Jay Foad
5cabf1505d
[KnownBits] Make avg{Ceil,Floor}S optimal (#110688)
Rewrite the signed functions in terms of the unsigned ones which are
already optimal.
2024-10-01 19:34:50 +01:00
Ramkumar Ramachandra
3fee3e83a8
KnownBits: refine srem for high-bits (#109121)
KnownBits::srem does not correctly set the leader zero-bits, omitting
the fact that LHS may be known-negative or known-non-negative. Fix this.

Alive2 proof: https://alive2.llvm.org/ce/z/Ugh-Dq
2024-09-27 12:00:50 +01:00
Yingwei Zheng
fa824dc0dd
[LLVM][IR] Add constant range support for floating-point types (#86483)
This patch adds basic constant range support for floating-point types to enable range-based optimizations.
2024-09-25 13:58:23 +08:00
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