Commit Graph

506252 Commits

Author SHA1 Message Date
Amir Ayupov
83ea7ce3a1 [BOLT][NFC] Track fragment relationships using EquivalenceClasses
Three-way splitting can create references between split fragments (warm
to cold or vice versa) that are not handled by
`isChildOf/isParentOf/isChildOrParentOf`. Generalize fragment
relationships to allow checking if two functions belong to one group,
potentially in presence of ICF which can join multiple groups.

Test Plan: NFC for existing tests

Reviewers: maksfb, ayermolo, rafaelauler, dcci

Reviewed By: rafaelauler

Pull Request: https://github.com/llvm/llvm-project/pull/99979
2024-07-24 07:15:10 -07:00
Utkarsh Saxena
1feef92a77 Fix lifetimebound for field access (#100197)
Fixes: https://github.com/llvm/llvm-project/issues/81589

There is no way to switch this off without  `-Wno-dangling`.
2024-07-24 15:58:52 +02:00
OverMighty
557a7b8ae3 [libc][math][c23] Fix totalorder and totalordermag smoke tests (#100354)
FPBits::signaling_nan() defaults to setting the MSB of the payload to 1.
The tests also used signaling NaNs with a payload of 0x123. With
float16, the 1 in 0x123 aligns to the MSB of the payload, therefore
0x123 is greater than the default payload. However, that is not the case
with more precise floating-point types.
2024-07-24 15:58:18 +02:00
Jan Leyonberg
5b15d9c441 [clang][OpenMP] Propoagate debug location to OMPIRBuilder reduction codegen (#100358)
This patch propagates the debug location from Clang to the
OpenMPIRBuilder.

Fixes https://github.com/llvm/llvm-project/issues/97458
2024-07-24 08:57:39 -05:00
Andrzej Warzyński
1f5807eb35 [mlir][vector][nfc] Simplify in_bounds attr update (#100334)
Since the `in_bounds` attribute is mandatory, there's no need for logic
like this (`readOp.getInBounds()` is guaranteed to return a non-empty
ArrayRef):

```cpp
ArrayAttr inBoundsAttr = readOp.getInBounds()
    ? rewriter.getArrayAttr( readOp.getInBoundsAttr().getValue().drop_back(dimsToDrop))
    : ArrayAttr();
```

Instead, we can do this:
```cpp
ArrayAttr inBoundsAttr = rewriter.getArrayAttr(
    readOp.getInBoundsAttr().getValue().drop_back(dimsToDrop));
```

This is a small follow-up for #97049 - this change should've been
included there.
2024-07-24 14:40:19 +01:00
Kai Luo
de8c4bef33 [tsan] Include unistd.h to declare gettid()
Try to fix https://lab.llvm.org/buildbot/#/builders/176/builds/14400.
2024-07-24 21:34:22 +08:00
Simon Pilgrim
0b36144aba [X86] Add 'clamp out of range index' variable shuffles test coverage from #96754 2024-07-24 14:33:37 +01:00
Florian Hahn
07688d1341 Revert "[LV] Add option to still enable the legacy cost model. (#99536)"
This reverts commit 9ba5244273.

Remove the recently added temporary option vectorize-use-legacy-cost-model
as discussed on the PR adding it, now that we branched for 19.x.
2024-07-24 14:32:36 +01:00
Kerry McLaughlin
6da6772bf0 [AArch64][SME] Rewrite __arm_get_current_vg to preserve required registers (#100143)
The documentation for the __arm_get_current_vg support routine specifies
that the following registers are call-preserved:
 - X1-X15, X19-X29 and SP
 - Z0-Z31
 - P0-P15

This patch rewrites the implementation of this routine in compiler-rt,
as the current version does not guarantee that these registers will be
preserved.
2024-07-24 14:30:25 +01:00
Jay Foad
b9995a14f5 [MachineLoopInfo] Fix assertion failure on undef use operands (#100137)
Fixes #100115
2024-07-24 14:27:12 +01:00
LLVM GN Syncbot
2bb18e27b6 [gn build] Port e6c20e11e7 2024-07-24 13:10:14 +00:00
Dmitry Chestnykh
558a895368 [compiler-rt] Move endif to correct place (#100342)
A couple of previous commits leaded to wrong endif placement inside the
source that caused build problem in
https://lab.llvm.org/buildbot/#/builders/13/builds/1020

See #99613 #99049
2024-07-24 16:02:28 +03:00
Qiu Chaofan
20957d2091 [AIX] Add -msave-reg-params to save arguments to stack (#97524)
In PowerPC ABI, a few initial arguments are passed through registers,
but their places in parameter save area are reserved, arguments passed
by memory goes after the reserved location.

For debugging purpose, we may want to save copy of the pass-by-reg
arguments into correct places on stack. The new option achieves by
adding new function level attribute and make argument lowering part
aware of it.
2024-07-24 20:58:37 +08:00
Chris Copeland
4bb3a1e16f [clang] Define ATOMIC_FLAG_INIT correctly for C++. (#97534) 2024-07-24 08:53:39 -04:00
Joseph Huber
550b83d658 Revert "[libc] Remove 'packaged' GPU build support (#100208)"
Summary:
I forgot that the OpenMP tests still look for this, reverting for now
until I can make a fix.

This reverts commit c1c6ed83e9.
2024-07-24 07:51:47 -05:00
Joseph Huber
9914609468 Revert "[libc] Enable 'sscanf' on the GPU (#100211)"
Summary:
This fails tests in some situations, revert until it can be fixed.
This reverts commit 445bb35f95.
2024-07-24 07:46:39 -05:00
David Spickett
929b474991 [libcxx][test] Explain picolib unsupported in sort.pass.cpp
This is not a hidden bug, it's just a very slow test under emulation.
2024-07-24 12:43:07 +00:00
Matt Davis
404071b059 [SelectionDAG] Preserve volatile undef stores. (#99918)
This patch preserves `undef` SDNodes that are `volatile` qualified.
Previously, these nodes would be discarded. The motivation behind this
change is to adhere to the
[LangRef](https://llvm.org/docs/LangRef.html#volatile-memory-accesses),
even though that doc is mostly in terms of LLVM-IR, it seems reasonable
to imply that the volatile constraints also imply to SDNodes.

> Certain memory accesses, such as
[load](https://llvm.org/docs/LangRef.html#i-load)’s,
[store](https://llvm.org/docs/LangRef.html#i-store)’s, and
[llvm.memcpy](https://llvm.org/docs/LangRef.html#int-memcpy)’s may be
marked volatile. The optimizers must not change the number of volatile
operations or change their order of execution relative to other volatile
operations. The optimizers may change the order of volatile operations
relative to non-volatile operations. This is not Java’s “volatile” and
has no cross-thread synchronization behavior.

Source: https://llvm.org/docs/LangRef.html#volatile-memory-accesses
2024-07-24 08:41:56 -04:00
Joseph Huber
445bb35f95 [libc] Enable 'sscanf' on the GPU (#100211)
Summary:
We can enable the `sscanf` function on the GPU now.
2024-07-24 07:41:32 -05:00
Ivan Kosarev
e1052faaf8 [AMDGPU][MC][NFC] Drop remaining -wavesize32/64 attributes in tests. (#100339)
Those are not needed now that
<https://github.com/llvm/llvm-project/pull/98400> is submitted.
2024-07-24 13:41:00 +01:00
Chaitanya
e6c20e11e7 [AMDGPU] Move AMDGPUAsanInstrumentation outside of utils (#100323)
#98863 merged AMDGPUAsanInstrumentation module which missed
TransformUtils to be linked to AMDGPUUtils.
This PR moves AMDGPUAsanInstrumentation files outside utils folder and
adds them to AMDGPUCodegen lib.
2024-07-24 18:06:10 +05:30
LLVM GN Syncbot
48e1eb4e6b [gn build] Port ddb75ca606 2024-07-24 12:23:42 +00:00
LLVM GN Syncbot
99c5140bb2 [gn build] Port 2ca300f914 2024-07-24 12:23:41 +00:00
Joseph Huber
c1c6ed83e9 [libc] Remove 'packaged' GPU build support (#100208)
Summary:
Previously, the GPU built the `libc` in a fat binary version that was
used to pass this to the link job in offloading languages like CUDA or
OpenMP. This was mostly required because NVIDIA couldn't consume the
standard static library version. Recent patches have now created the
`clang-nvlink-wrapper` which lets us do that. Now, the C library is just
included implicitly by the toolchain (or passed with -Xoffload-linker
-lc).

This code can be fully removed, which will heavily simplify the build
(and removed some bugs and garbage files I've encoutnered).
2024-07-24 07:22:49 -05:00
Yingwei Zheng
59eae919c9 [ValueTracking] Don't use CondContext in dataflow analysis of phi nodes (#100316)
See the following case:
```
define i16 @pr100298() {
entry:
  br label %for.inc

for.inc:
  %indvar = phi i32 [ -15, %entry ], [ %mask, %for.inc ]
  %add = add nsw i32 %indvar, 9
  %mask = and i32 %add, 65535
  %cmp1 = icmp ugt i32 %mask, 5
  br i1 %cmp1, label %for.inc, label %for.end

for.end:
  %conv = trunc i32 %add to i16
  %cmp2 = icmp ugt i32 %mask, 3
  %shl = shl nuw i16 %conv, 14
  %res = select i1 %cmp2, i16 %conv, i16 %shl
  ret i16 %res
}
```

When computing knownbits of `%shl` with `%cmp2=false`, we cannot use
this condition in the analysis of `%mask (%for.inc -> %for.inc)`.
 
Fixes https://github.com/llvm/llvm-project/issues/100298.
2024-07-24 20:06:36 +08:00
DianQK
559be8e2b5 Reapply "[FunctionAttrs] Determine underlying object by getUnderlyingObjectAggressive (#100102)"
Added handling for `AllocaInst`.

This reverts commit 1ee686a55a.
2024-07-24 20:01:22 +08:00
Nico Weber
a5bc549c50 [gn] port 73ac953626 2024-07-24 07:58:51 -04:00
Kareem Ergawy
68a0d0c762 [flang][OpenMP] Handle common blocks in delayed privatization (#100317)
Adds proper mapping of common block elements to block arguments in
parallel regions when delayed privatization is enabled.
2024-07-24 13:48:47 +02:00
Matt Arsenault
2ce865d490 ARM: Avoid using MachineFunction::getMMI 2024-07-24 15:21:14 +04:00
Mitch Phillips
1031335f2e Revert "[libc++][math] Fix undue overflowing of std::hypot(x,y,z) (#93350)"
This reverts commit 9628777479.

More details in https://github.com/llvm/llvm-project/pull/93350, but
this broke the PowerPC sanitizer bots.
2024-07-24 13:18:27 +02:00
Pavel Skripkin
893a303962 [clang][analyzer] Support ownership_{returns,takes} attributes (#98941)
Add support for checking mismatched ownership_returns/ownership_takes attributes.

Closes #76861
2024-07-24 13:15:08 +02:00
Luke Lau
05e95067ee [RISCV] Update combine-vmv.ll to have more foldable cases. NFC
A lot of cases have differing AVLs which aren't foldable, update them so the peephole triggers on them and add explicit cases for non-foldable AVLs.

Also rename it to vmv.v.v-peephole.ll since it's not actually a DAG combine.

And remove a TODO, it's correct to fold if the two passthrus are the same.
2024-07-24 19:04:45 +08:00
Sergio Afonso
cba63c0f92 [MLIR][OpenMP] Keep -verify-openmp-ops output as dependency (#99638)
Currently, the `mlir-tblgen -verify-openmp-ops` pseudo-backend, which
only performs an OpenMP dialect-specific set of checks and produces no
output, is prevented from being added as a dependency to the
`MLIROpenMPOpsIncGen` tablegen target.

However, a consequence of this is that it is not triggered with every
modification of the OpenMPOps.td file it's intended to check, although
it should. This patch fixes the issue by letting the empty output file
to be added to the `TABLEGEN_OUTPUT` CMake variable used by the
`add_public_tablegen_target` command below to set up dependencies.
2024-07-24 11:38:34 +01:00
Brandon Wu
aa53f0d6fd [ASTContext] Make the end of the switch case unreachable in encodeTypeForFunctionPointerAuth (#99763)
This prevent the warning from compiler.
2024-07-24 18:38:03 +08:00
Timm Bäder
d36edf8146 [clang][Interp] Bail out on value dependent variable initializers 2024-07-24 12:11:06 +02:00
John Brawn
f0bd705c9b [CodeGen] Restore MachineBlockPlacement block ordering (#99351)
PR #91843 changed the algorithm used to find the next unplaced block so
that it iterates through the blocks in BlockFilter instead of iterating
through the blocks in the function and checking if they are in the block
filter. Unfortunately this sometimes results in a different block
ordering being chosen, as the order of blocks in BlockFilter comes from
the order in MachineLoopInfo, and in some cases this differs from the
order they are in the function. This can also give an end result that
has worse performance.

Fix this by making collectLoopBlockSet place blocks in its output in the
order that they are in the function.
2024-07-24 10:49:50 +01:00
David Spickett
71a848632e [libcxx][test] Update picolib xfails (#99631)
clang_modules_include.gen.py works now, and I added some background to
classic_table.pass.cpp.

Opened https://github.com/picolibc/picolibc/issues/778 to see if that
one is possible to fix.
2024-07-24 10:45:00 +01:00
Dmitry Chestnykh
cd82fee391 [nsan] Fix Wstring-conversion error (#100328)
Fix error: implicit conversion turns string literal into bool: 'const
char[46]' to 'bool' [-Werror,-Wstring-conversion]
2024-07-24 12:35:56 +03:00
Matt Arsenault
3cb5604d2c MachineOutliner: Use PM to query MachineModuleInfo (#99688)
Avoid getting this from the MachineFunction
2024-07-24 13:22:56 +04:00
Benjamin Maxwell
7fad04e94b [LSR] Fix matching vscale immediates (#100080)
Somewhat confusingly a `SCEVMulExpr` is a `SCEVNAryExpr`, so can have
> 2 operands. Previously, the vscale immediate matching did not check
the number of operands of the `SCEVMulExpr`, so would ignore any
operands after the first two.

This led to incorrect codegen (and results) for ArmSME in IREE
(https://github.com/iree-org/iree), which sometimes addresses things
that are a `vscale * vscale` multiple away. The test added with this
change shows an example reduced from IREE. The second write should
be offset from the first `16 * vscale * vscale` (* 4 bytes), however,
previously LSR dropped the second vscale and instead offset the write by
`#4, mul vl`, which is an offset of `16 * vscale` (* 4 bytes).
2024-07-24 10:06:34 +01:00
Jessica Del
6a1b119035 [AMDGPU] Add intrinsics for atomic struct buffer loads (#100140)
Mark these intrinsics as atomic loads within LLVM to prevent hoisting
out of loops in cases where
the load is considered invariant.

Similar to https://github.com/llvm/llvm-project/pull/97707, but for
struct buffer loads.
2024-07-24 11:05:28 +02:00
Akira Hatanaka
666e3326fe [PAC] Define __builtin_ptrauth_type_discriminator (#100204)
The builtin computes the discriminator for a type, which can be used to
sign/authenticate function pointers and member function pointers.

If the type passed to the builtin is a C++ member function pointer type,
the result is the discriminator used to signed member function pointers
of that type. If the type is a function, function pointer, or function
reference type, the result is the discriminator used to sign functions
of that type. It is ill-formed to use this builtin with any other type.

A call to this function is an integer constant expression.

Co-Authored-By: John McCall rjmccall@apple.com
2024-07-24 02:04:37 -07:00
Matt Arsenault
eff6250494 M68k: Remove hasDebugInfo check
Follow up to a03935b984
2024-07-24 12:59:33 +04:00
Florian Hahn
ba8126b6fe [LV] Mark dead instructions in loop as free.
Update collectValuesToIgnore to also ignore dead instructions in the
loop. Such instructions will be removed by VPlan-based DCE and won't be
considered by the VPlan-based cost model.

This closes a gap between the legacy and VPlan-based cost model. In
practice with the default pipelines, there shouldn't be any dead
instructions in loops reaching LoopVectorize, but it is easy to generate
such cases by hand or automatically via fuzzers.

Fixes https://github.com/llvm/llvm-project/issues/99701.
2024-07-24 09:31:32 +01:00
Matt Arsenault
9a25866402 CodeGen: Avoid using MachineFunction::getMMI in MachineModuleSlotTracker (#100310) 2024-07-24 12:27:00 +04:00
jeanPerier
1ead51a86c [flang] fix C_PTR function result lowering (#100082)
Functions returning C_PTR were lowered to function returning intptr (i64
on 64bit arch). This caused conflicts when these functions were defined
as returning !fir.ref<none>/llvm.ptr in other compiler generated
contexts (e.g., malloc).

Lower them to return !fir.ref<none>.

This should deal with https://github.com/llvm/llvm-project/issues/97325
and https://github.com/llvm/llvm-project/issues/98644.
2024-07-24 10:24:04 +02:00
Sam Parker
a3de21cac1 [WebAssembly] Ofast pmin/pmax pattern matchers (#100107)
With fast-math, the ordered setcc nodes are converted to setcc nodes
which do not care about NaNs, so add patterns that use setlt, setle,
setgt and setge.
2024-07-24 09:23:49 +01:00
Dmitry Chestnykh
ddf5725ef1 [nsan] Emit calls to optimized functions (#98900)
As previously noted in nsan.cpp we can implement
optimized variants of `__nsan_copy_values` and
`__nsan_set_value_unknown` if a memory operation
size is known.
Now the instrumentation creates calls to optimized functions if there is
4, 8 or 16-byte memory operation like
`memset(X, value, 4/8/16)` or `memcpy(dst, src, 4/8/16)`
nsan.cpp provides definitions of the optimized functions.
2024-07-24 11:20:36 +03:00
Edd Dawson
3993a47bb5 [PS4/PS5][Driver][DWARF] Always emit .debug_aranges for SCE tuning (#100160)
Some of SIE's post-mortem analysis infrastructure currently makes use of
.debug_aranges, so we'd like to ensure the section's presence in
PlayStation binaries. The simplest way to do this is to force emission
when the debugger tuning is set to SCE (which is in turn typically
initialized from the target triple). This also simplifies the driver.

llvm/test/DebugInfo/debuglineinfo-path.ll has been marked as UNSUPPORTED
on PlayStation. When aranges are emitted, the DWARF in the test case is
such that relocations need to be applied to the aranges section in order
for symbolization to work. An alternative approach would be to implement
the application of relocations in DWARFDebugArangeSet. While experiments
show that this can be made to work with a modest patch, the test cases
would be rather contrived. Since I expect the only utility for such a
change would be to make this test case pass for PlayStation targets, and
few - if any - outside of PlayStation care about aranges, UNSUPPORTED
would seem to be a more practical option.

This was originally commited as 22eb290a96 (#99629) and later reverted
at 84658fb82b (#99711) due to test failures on SIE built bots. These
failures shouldn't recur due to 3b24e5d450 (#99897) and the
aforementioned change to debuglineinfo-path.ll.

SIE tracker: TOOLCHAIN-16951
2024-07-24 09:07:25 +01:00
Rainer Orth
c34d673b02 [asan][cmake][test] Fix finding dynamic asan runtime lib (#100083)
In a `runtimes` build on Solaris/amd64, there are two failues:
```
  AddressSanitizer-Unit :: ./Asan-i386-calls-Dynamic-Test/failed_to_discover_tests_from_gtest
  AddressSanitizer-Unit :: ./Asan-i386-inline-Dynamic-Test/failed_to_discover_tests_from_gtest
```
This happens when `lit` enumerates the tests with `--gtest_list_tests
--gtest_filter=-*DISABLED_*`. The error is twofold:

- The `LD_LIBRARY_PATH*` variables point at the 64-bit directory
(`lib/clang/19/lib/x86_64-pc-solaris2.11`) for a 32-bit test:
  ``` 
ld.so.1: Asan-i386-calls-Dynamic-Test: fatal:
/var/llvm/local-amd64-release-stage2-A-flang-clang18-runtimes/tools/clang/stage2-bins/./lib/../lib/clang/19/lib/x86_64-pc-solaris2.11/libclang_rt.asan.so:
wrong ELF class: ELFCLASS64
  ```
- While the tests are linked with `-Wl,-rpath`, that path always is the
64-bit directory again.

Accordingly, the fix consists of two parts:
- The code in `compiler-rt/test/asan/Unit/lit.site.cfg.py.in` to adjust
the `LD_LIBRARY_PATH*` variables is guarded by a `config.target_arch !=
config.host_arch` condition. This is wrong in two ways:
- The adjustment is always needed independent of the host arch. This is
what `compiler-rt/test/lit.common.cfg.py` already does.
- Besides, `config.host_arch` is ultimately set from
`CMAKE_HOST_SYSTEM_PROCESSOR`. On Linux/x86_64, this is `x86_64` (`uname
-m`) while on Solaris/amd64 it's `i386` (`uname -p`), explaining why the
transformation is skipped on Solaris, but not on Linux.
- Besides, `RPATH` needs to be set to the correct subdirectory, so
instead of using the default arch in `compiler-rt/CMakeLists.txt`, this
patch moves the code to a function which takes the test's arch into
account.

Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.
2024-07-24 10:03:47 +02:00