Commit Graph

504898 Commits

Author SHA1 Message Date
Akiel
3604c23dfc [libc][math] implement signbit and math macro unit tests (#97791)
This PR resolves #96322 and implements the `signbit` macro under a new
header `generic-math-macros.h`. This also removed the `TODO` in
`math-macros.h` and moves `isfinite`, `isinf`, and `isnan` to the same
generic maths header. Finally, a test file
`generic-math-macros_test.cpp` that adds coverage to the above 4 macros.

Fixes #96322.
2024-07-13 23:01:36 -04:00
lntue
8b4251729f [libc] Add libc_include_tests suites to check-libc target. (#98749) 2024-07-13 22:49:52 -04:00
Kazu Hirata
5e22a53698 [Target] Use range-based for loops (NFC) (#98705) 2024-07-13 17:40:51 -07:00
Kazu Hirata
3fa409f231 [ADT] Remove StringRef::equals (#98735)
StringRef::equals has been deprecated since:

  commit de483ad513
  Author: Kazu Hirata <kazu@google.com>
  Date:   Thu May 16 00:38:37 2024 -0700
2024-07-13 17:31:00 -07:00
Kazu Hirata
66cd2e0f9a [CodeGen] Use range-based for loops (NFC) (#98706) 2024-07-13 13:29:47 -07:00
Florian Hahn
a4f8705b05 [LAA] Precommit test with loops where indices are loaded in each iter.
Add tests which are not safe to vectorize because %indices are loaded in
the loop and the same indices could be loaded in later iterations.

Tests for https://github.com/llvm/llvm-project/issues/87189.
2024-07-13 21:25:32 +01:00
Helena Kotas
f4254f3f51 [HLSL] Add test for export function redeclaration (#97370)
Related to llvm/llvm-project#92812
2024-07-13 11:39:51 -08:00
Petr Hosek
b2468d7ec2 [libc] Mark all __llvm_libc_errno definitions as noexcept (#98762)
The definitions must match the previous declaration in errno.h.
2024-07-13 11:40:33 -07:00
Petr Hosek
8802c9fd73 [libc] Mark internal __llvm_libc_errno as noexcept (#98760)
The declaration must match the previous declaration in errno.h.
2024-07-13 11:29:12 -07:00
Petr Hosek
4a68654ad6 [libc] Remove src/errno/errno.h (#98759)
This addresses the build error introduced in #98287 where
src/errno/errno.h is included instead of the system errno.h.

We instead move the declaration to libc_errno.h.
2024-07-13 11:23:32 -07:00
Schrodinger ZHU Yifan
f96e4e8c10 [libc] fix dependencies for fprintf (#98752) 2024-07-13 12:53:44 -05:00
Petr Hosek
69258491d2 [libc] Support configurable errno modes (#98287)
Rather than selecting the errno implementation based on the platform
which doesn't provide the necessary flexibility, make it configurable.

The errno value location is returned by `int *__llvm_libc_errno()` which
is a common design used by other C libraries.
2024-07-13 10:52:42 -07:00
Chris B
d91ff3f240 [HLSL] Rework implicit conversion sequences (#96011)
This PR reworks HLSL's implicit conversion sequences. Initially I was
seeking to match DXC's behavior more closely, but that was leading to a
pile of special case rules to tie-break ambiguous cases that should
really be left as ambiguous. We've decided that we're going to break
compatibility with DXC here, and we may port this new behavior over to
DXC instead.

This change is a bit closer to C++'s overload resolution rules, but it
does have a bit of nuance around how dimension adjustment conversions
are ranked. Conversion sequence ranks for HLSL are:

* Exact match
* Scalar Widening (i.e. splat)
* Promotion
* Scalar Widening with Promotion
* Conversion
* Scalar Widening with Conversion
* Dimension Reduction (i.e. truncation)
* Dimension Reduction with Promotion
* Dimension Reduction with Conversion

In this implementation I've folded the disambiguation into the
conversion sequence ranks which does add some complexity as compared to
C++, however this avoids needing to add special casing in
`CompareStandardConversionSequences`. I believe the added conversion
rank values provide a simpler approach, but feedback is appreciated.

The HLSL language spec updates are in the PR here:
https://github.com/microsoft/hlsl-specs/pull/261
2024-07-13 12:23:22 -05:00
Schrodinger ZHU Yifan
2d2893d7b1 [libc] always compile hash_test with -O3 (#98718) 2024-07-13 09:48:26 -07:00
AtariDreams
60e90a1929 [InstCombine] Check for undef first before freeze (#96769)
All of these insert freeze due to multi-use, which is only
relevant for undef values, not poison.
2024-07-13 18:39:41 +02:00
mskamp
949bbdc923 [InstCombine] Fold Minimum over Trailing/Leading Bits Counts (#90402)
The new transformation folds `umin(cttz(x), c)` to `cttz(x | (1 << c))`
and `umin(ctlz(x), c)` to `ctlz(x | ((1 << (bitwidth - 1)) >> c))`. The
transformation is only implemented for constant `c` to not increase the
number of instructions.
    
The idea of the transformation is to set the c-th lowest (for `cttz`) or
highest (for `ctlz`) bit in the operand. In this way, the `cttz` or
`ctlz` instruction always returns at most `c`.
    
Alive2 proofs: https://alive2.llvm.org/ce/z/y8Hdb8

Fixes #90000
2024-07-13 16:55:11 +02:00
Timm Bäder
b22adf02a2 [clang][Interp] Clear pointers pointing to dead blocks
before free()ing the dead blocks. Otherwise, we might end up with
dangling Pointers to those dead blocks.
2024-07-13 15:55:55 +02:00
Renato Golin
80e61e3842 Remove redundant linalg.matmul_signed (#98615)
`linalg.matmul` already has an attribute for casts, defaults to signed
but allowed unsigned, so the operation `linalg.matmul_unsigned` is
redundant. The generalization test has an example on how to lower to
unsigned matmul in linalg.

This is the first PR in a list of many that will simplify the linalg
operations by using similar attributes.

Ref:
https://discourse.llvm.org/t/rfc-transpose-attribute-for-linalg-matmul-operations/80092
2024-07-13 14:46:44 +01:00
Marius Brehler
a5cf99d02c [mlir][EmitC] Add member access ops (#98460)
This adds an `emitc.member` and `emitc.member_of_ptr` operation for the
corresponding member access operators. Furthermore, `emitc.assign` is
adjusted to be used with the member access operators.
2024-07-13 14:43:07 +02:00
NAKAMURA Takumi
c8f2ee77d2 Fix a warning in #98362 [-Wunused-but-set-variable] 2024-07-13 20:57:09 +09:00
Joseph Huber
aee553e366 [libc] Stop using LLVM's stdout in overlay mode tests
Summary:
This causes errors when running unit tests when it tries to use an
invalid stdio handle.

Fixes https://github.com/llvm/llvm-project/issues/98711
2024-07-13 06:24:31 -05:00
Jay Foad
ae63db7882 [AMDGPU] Re-enable atomic optimization of uniform fadd/fsub with result (#97604)
Fix various problems to do with the first active lane of the result of
optimized fp atomics, as explained in the comment.

Fixes #97554
2024-07-13 11:18:45 +01:00
Ilya Leoshkevich
3b7a7f4cc4 [sanitizer] Add missing newlines to __sanitizer_set_report_path() error messages (#98626)
"Can't open file:" and "Can't create directory:" are lacking a newline.
2024-07-13 10:31:03 +02:00
Ilya Leoshkevich
7232763a96 [sanitizer] Suggest checking ulimit -d in addition to ulimit -v (#98625)
Since Linux 4.7, RLIMIT_DATA may result in mmap() returning ENOMEM.
Example:

    $ clang -fsanitize=address -o hello hello.c
    $ ulimit -d 100000
    $ ./hello
==3349007==ERROR: AddressSanitizer failed to allocate 0x10000000
(268435456) bytes at address 7fff7000 (errno: 12)
==3349007==ReserveShadowMemoryRange failed while trying to map
0x10000000 bytes. Perhaps you're using ulimit -v

Suggest checking ulimit -d in addition to ulimit -v.
2024-07-13 10:30:51 +02:00
Nikolas Klauser
69fecaa1a4 [libc++] Clean up some now dead code with the upgrade to GCC 14 (#97746) 2024-07-13 09:41:36 +02:00
Samira Bazuzi
3fed312d2b [clang][dataflow]Propagate the result object location for CXXDefaultInitExpr. (#98490)
These are not "original initializers"; the single node underneath
represents the initializing node.
2024-07-13 00:38:49 -07:00
cor3ntin
1fe406fffe [Clang] Fix parsing of reversible type traits in template arguments (#95969)
Constructs like `__is_pointer(Foo)` are never considered to be functions
declarations.

This matches usages in libstdc++, and we can hope
no one else redefine these reserved identifiers.

Fixes #95598
2024-07-13 08:53:02 +02:00
Haojian Wu
40ed1946f2 [bazel] Fix the bazel build after 40effc7af5 2024-07-13 07:52:29 +02:00
Brad Smith
14b9d12039 [docs] Remove the History section (#98715)
This does not really serve any purpose nowadays.
2024-07-13 01:38:39 -04:00
Timm Bäder
66e6df22b5 [clang][Interp] Fix one-past-end pointers going back into the block 2024-07-13 07:25:47 +02:00
Timm Bäder
634128be46 [clang][Interp][NFC] Remove some unused includes 2024-07-13 07:25:47 +02:00
Timm Bäder
7d5902025d [clang][Interp][NFC] Remove unused include 2024-07-13 07:25:47 +02:00
Schrodinger ZHU Yifan
0ecb98397b [libc] suppress uninitialized werrors (#98710)
suppress uninitialized werrors when building with gcc
2024-07-12 21:14:50 -07:00
Younan Zhang
fb19649535 [Clang][NFCI] Remove records of unsatisfied atomic expressions in ConstraintSatisfaction (#98654)
This expression doesn't appear to be ever used, so let's remove it from
the data structure.

Fixed some spelling issues as well.
2024-07-13 11:49:21 +08:00
Vitaly Buka
873578057d [Pattern] Disable a new buggy test
Introduced with #98282
2024-07-12 20:46:15 -07:00
Vitaly Buka
bfdad9ff1d [Pattern] Disabled new buggy test
Introduced with #98282
2024-07-12 20:30:56 -07:00
Joseph Huber
594989918b [libc] Fix missing printf dependencies 2024-07-12 20:42:09 -05:00
Brian Cain
71c5453fa9 [compiler-rt] Add hexagon architecture to cmake (#98650)
Add hexagon to detect_target_arch, test_target macros.
2024-07-12 20:10:03 -05:00
Joseph Huber
bb46c0b224 [libc] Remove warnings on default values
Summary:
These cause issues because we compile with `-Wno-error`. Remove them for
now. @SchrodingerZhu.
2024-07-12 19:39:46 -05:00
Joseph Huber
40effc7af5 [libc] Implement (v|f)printf on the GPU (#96369)
Summary:
This patch implements the `printf` family of functions on the GPU using
the new variadic support. This patch adapts the old handling in the
`rpc_fprintf` placeholder, but adds an extra RPC call to get the size of
the buffer to copy. This prevents the GPU from needing to parse the
string. While it's theoretically possible for the pass to know the size
of the struct, it's prohibitively difficult to do while maintaining ABI
compatibility with NVIDIA's varargs.

Depends on https://github.com/llvm/llvm-project/pull/96015.
2024-07-12 19:36:13 -05:00
Ahmed Bougacha
ee4661e0f8 [AArch64][PAC] Emit auth call for Darwin tlv access thunk. (#97658)
With ptrauth-calls, function pointers are supposed to be signed.
On Darwin that includes the TLS indirection accessor (`_tlv_get_addr`).
We simply sign it with the plain function-pointer schema (IA,0), which
lets us do a `blraaz` when calling it.

Note that this doesn't have any kind of diversity, even when function
pointer diversity is enabled in the frontend.  On arm64e this accessor
is never signed that way, but the obvious alternative where this (or
another backend-generated) function pointer needs to be diversified
would need more than the "ptrauth-calls" attribute as it exists today.
2024-07-12 16:49:27 -07:00
yozhu
7b135f7c08 [MachineSink] Check predecessor/successor relationship between two basic blocks involved in critical edge splitting (#98540)
Fix an issue in #97618 - if the two basic blocks involved are not
predecessor / successor to each other, treat the candidate as illegal
for critical edge splitting.

Closes #98477 (checked in test copied from its comment).
2024-07-13 01:39:27 +02:00
Xiang Li
76e37b1a08 [DirectX] fix illegal behavior flag in module flags. (#96577)
For DXIL which is based on llvm 3.7, max supported behavior flag for
module flags is 6.

The commit will check all module flags, for behavior flag > 6, change it
to 2 (Warning).
    
This is to fix the behavior flag part for #96912.
2024-07-12 18:46:22 -04:00
RoseZhang03
0870afaaac [libc] newheadergen: created sys folder for yaml files, make appropriate updates to CMake file for sys folder (#98693)
Moved sys yaml files into the sys folder.
After CMake patch lands, will make appropriate changes to account for
yaml, header, and .h.def files that are located within the sys folder in
a separate patch.
2024-07-12 22:33:37 +00:00
Joseph Huber
486d00eca6 [NVPTX] Implement variadic functions using IR lowering (#96015)
Summary:
This patch implements support for variadic functions for NVPTX targets.
The implementation here mainly follows what was done to implement it for
AMDGPU in https://github.com/llvm/llvm-project/pull/93362.

We change the NVPTX codegen to lower all variadic arguments to functions
by-value. This creates a flattened set of arguments that the IR lowering
pass converts into a struct with the proper alignment.

The behavior of this function was determined by iteratively checking
what the NVCC copmiler generates for its output. See examples like
https://godbolt.org/z/KavfTGY93. I have noted the main methods that
NVIDIA uses to lower variadic functions.

1. All arguments are passed in a pointer to aggregate.
2. The minimum alignment for a plain argument is 4 bytes.
3. Alignment is dictated by the underlying type
4. Structs are flattened and do not have their alignment changed.
5. NVPTX never passes any arguments indirectly, even very large ones.

This patch passes the tests in the `libc` project currently, including
support for `sprintf`.
2024-07-12 17:09:48 -05:00
PiJoules
2ad7b4af95 [cmake][Fuchsia] armv8m -> armv8m.main (#98695)
armv8m builtins aren't being built because `armv8m` doesn't match any of
the arm cpu strings in compiler-rt cmake files. Instead there's
`armv8m.main` and `armv8m.base`. We want to use the `armv8m.main`
version.
2024-07-12 13:55:25 -07:00
Joseph Huber
1ccd8756f1 [NVPTX] Disable all RTLib libcalls (#98672)
Summary:
This patch explicitly disables runtime calls to be emitted from the
NVPTX backend. This allows other utilities to know that we do not need
to worry about emitting these.
2024-07-12 15:46:51 -05:00
Volodymyr Vasylkun
afb584a562 [SelectionDAG] Ensure that we don't create UCMP/SCMP nodes with operands being scalars and result being a 1-element vector during scalarization (#98687)
This patch fixes a problem that existed before where in some situations
a `UCMP`/`SCMP` node which operated on 1-element vectors had a legal
result type (i.e. `v1i64` on AArch64), but illegal operands (i.e.
`v1i65`). This meant that operand scalarization was performed on the
node and the operands were changed to a legal scalar type, but the
result wasn't. This then led to `UCMP`/`SCMP` nodes with different
vector-ness of operands and result appearing in the SDAG. This patch
addresses this issue by fully scalarizing the `UCMP`/`SCMP` node and
then turning its result back into a 1-element vector using a
`SCALAR_TO_VECTOR` node.

It also adds several assertions to `SelectionDAG::getNode()` to avoid
this or a similar issue arising in the future. I wasn't sure if these
two changes are unrelated enough to warrant two small separate PRs, but
I'm happy to split this PR into two if that's deemed more appropriate.
2024-07-12 21:41:49 +01:00
Florian Hahn
bee240367c Revert "[TBAA] Emit distinct TBAA tags for pointers with different depths,types. (#76612)"
This reverts commit 038c48c1f4.

This is causing test failures in some configurations, reverted while I
investigate.

Failures include

 http://lab.llvm.org/buildbot/#/builders/11/builds/1623
 http://lab.llvm.org/buildbot/#/builders/108/builds/1172
2024-07-12 21:32:00 +01:00
Yingwei Zheng
99685a54d1 [MemCpyOpt] Use dyn_cast to fix assertion failure in processMemCpyMemCpyDependence (#98686)
Fixes https://github.com/llvm/llvm-project/issues/98675.
2024-07-13 04:27:07 +08:00