504293 Commits

Author SHA1 Message Date
Petr Hosek
cfa2d7df11
[libc] Provide baremetal implementation of getchar (#98059)
This introduces opaque type `struct __llvm_libc_stdin` and a symbol
`__llvm_libc_stdin_read` that's intended to be provided by the vendor.

`__llvm_libc_stdin_read` intentionally has the same signature as
`cookie_read_function_t` so it can be used with `fopencookie` to
represent `stdin` as `FILE *` in the future.
2024-07-09 01:45:27 -07:00
Timm Bäder
dd2bf3b840 [clang][Interp] Redo variable (re)visiting
Depending on the circumstances we visit variables in, we need to
be careful about when to destroy their temporaries and whether to
emit a Ret op at all or not.
2024-07-09 10:43:35 +02:00
Yupei Liu
f0c7505f59
[Clang] Fix the order of addInstantiatedParameters in LambdaScopeForCallOperatorInstantiationRAII (#97215)
Currently, `addInstantiatedParameters` is called from the innermost
lambda outward. However, when the function parameters of an inner lambda
depend on the function parameters of an outer lambda, it can lead to a
crash due to the inability to find a mapping for the instantiated decl.

This PR corrects this behavior by calling `addInstantiatedParameters`
from the outside in.

repro code: https://godbolt.org/z/KbsxWesW6

```cpp
namespace dependent_param_concept {
template <typename... Ts> void sink(Ts...) {}
void dependent_param() {
  auto L = [](auto... x) {
    return [](decltype(x)... y) { // `y` depends on `x`
      return [](int z)
        requires requires { sink(y..., z); }
      {};
    };
  };
  L(0, 1)(1, 2)(1);
}
} // namespace dependent_param_concept
```

This PR is a prerequisite for implmenting #61426
2024-07-09 16:39:50 +08:00
runseny
e5865ec93c
[MLIR][LLVM] Add ftz and fuse FP ops related function attribute support (#97812)
Adds `denormal-fp-math-f32`, `denormal-fp-math`, `fp-contract` to
llvmFuncOp attributes.

`denormal-fp-math-f32` and `denormal-fp-math` can enable the ftz, that
is , flushing denormal to zero.

`fp-contract` can enable the fma fusion such as `mul + add -> fma`
2024-07-09 09:34:43 +01:00
Alex Langford
cd89d926ae
[lldb] Correct invalid format style (#98089)
Fixes https://github.com/llvm/llvm-project/issues/97511
2024-07-09 09:34:06 +01:00
Ramkumar Ramachandra
f1eed011b4
MathExtras: add overflow query for signed-div (#97901)
5221634 (Do not trigger UB during AffineExpr parsing) noticed that
divideCeilSigned and divideFloorSigned would overflow when Numerator =
INT_MIN, and Denominator = -1. This observation has already been made by
DynamicAPInt, and it has code to check this. To avoid checks in multiple
callers, centralize this query in MathExtras, and change
divideCeilSigned/divideFloorSigned to assert on overflow.
2024-07-09 09:33:46 +01:00
Timm Bäder
ad82d1c53f [clang][Interp][NFC] Move a lambda declaration into its closest scope 2024-07-09 10:12:53 +02:00
Timm Bäder
4f68d20d87 [clang][Interp][NFC] Simplify Pointer Block accessing code
Try to get PointeeStorage.BS.Pointee only once and reuse that.
2024-07-09 10:12:53 +02:00
Cullen Rhodes
8011a23948
[mlir][linalg] Support scalable vectorization of linalg.index operations (#96778)
The vectorization of linalg.index operations doesn't support scalable
vectors when computing the index vector. This patch fixes this with the
vector.step operation.

Depends on #96776
2024-07-09 09:06:58 +01:00
Cullen Rhodes
1e7d6d3455
[mlir][vector] Propagate scalability to gather/scatter ptrs vector (#97584)
In convert-vector-to-llvm the first operand (vector of pointers holding
all memory addresses to read) to the masked.gather (and scatter)
intrinsic has a fixed vector type.

This may result in intrinsics where the scalable flag has been dropped:
```
  %0 = llvm.intr.masked.gather %1, %2, %3 {alignment = 4 : i32}
    : (!llvm.vec<4 x ptr>, vector<[4]xi1>, vector<[4]xi32>) -> vector<[4]xi32>
```
Fortunately the operand is overloaded on the result type so we end up
with the correct IR when lowering to LLVM, but this is still incorrect.
This patch fixes it by propagating scalability.
2024-07-09 09:06:25 +01:00
Timm Bäder
efc5a6aa82 [clang][Interp][NFC] Print Block descriptor in ::dump() 2024-07-09 09:59:52 +02:00
Timm Bäder
3655de7380 [clang][Interp] Avoid a dangling pointer
We've just moved all the pointers from the Block to the DeadBlock,
so make sure the old Block doesn't point to a linked list of Pointers
that don't even point to it anymore.
2024-07-09 09:59:51 +02:00
Pavel Labath
58e750bfd6
[lldb] Put the new debugger in synchronous mode in TestGlobalModuleCache (#98041)
In async mode, the test terminates sooner than it should
(`run_to_source_breakpoint` does not work in this mode), and then the
test crashes due to #76057. Most of the time, the test does not fail
because its already XFAILed, but the crash still registers as a failure.
2024-07-09 09:59:49 +02:00
Timm Bäder
93869dfd89 [clang][Interp][NFC] Simplify a test case 2024-07-09 09:23:14 +02:00
Timm Bäder
eee9efb09c [clang][Interp][NFC] Add empty initializer list to test decl
This was missing in the test.
2024-07-09 09:23:14 +02:00
Mariya Podchishchaeva
a1e1f31570
[NFC][clang] Add a release note for #embed (#97997) 2024-07-09 09:15:46 +02:00
v01dXYZ
cff8d716bd
[SCEV] forgetValue: support (with-overflow-inst op0, op1) (#98015)
The use-def walk in forgetValue() was skipping instructions with
non-SCEVable types. However, SCEV may look past with.overflow
intrinsics returning aggregates.

Fixes #97586.
2024-07-09 09:14:33 +02:00
Yingwei Zheng
be7239e5a6
[Inline] Remove bitcast handling in CallAnalyzer::stripAndComputeInBoundsConstantOffsets (#97988)
As we are now using opaque pointers, bitcast handling is no longer
needed.

Closes https://github.com/llvm/llvm-project/issues/97590.
2024-07-09 15:08:04 +08:00
Luke Lau
ed51908cec
[RISCV] Emit VP strided load in mgather combine. NFCI (#98112)
This combine is a duplication of the transform in
RISCVGatherScatterLowering but at the SelectionDAG level, so similarly
to #98111 we can replace the use of riscv_masked_strided_load with a VP
strided load.

Unlike #98111 we don't require #97800 or #97798 since it only operates
on fixed vectors with a non-zero stride.
2024-07-09 14:57:21 +08:00
Fangrui Song
2abe53a17f Revert "[llvm-objcopy] Remove empty SHT_GROUP sections (#97141)"
This reverts commit 359c64f314ad568e78ee9a3723260286e3425c2d.

This caused heap-use-after-free. See #98106.
2024-07-08 23:47:28 -07:00
Petr Hosek
f3fe14fabc
[libc] puts implementation for baremetal (#98051)
This is a simple baremetal implementation of puts akin to putchar.
2024-07-08 23:38:30 -07:00
Yingwei Zheng
9acaccbaee
[RISCV][Driver] Refactor riscv::getRISCVArch to return std::string. NFC. (#97965)
See the discussion in
https://github.com/llvm/llvm-project/pull/94352#discussion_r1657074801
2024-07-09 14:34:37 +08:00
Jianjian Guan
3259768557
[RISCV] Remove experimental for bf16 extensions (#97996)
They are already ratified now.
2024-07-09 14:34:03 +08:00
Zhaoxin Yang
626c7ce33f
[LoongArch][clang] Add support for option -msimd= and macro __loongarch_simd_width. (#97984) 2024-07-09 14:13:19 +08:00
Craig Topper
bb8998dd3b [RISCV] Don't custom legalize vXf16 SPLAT_VECTOR with Zvfhmin without Zfhmin.
Marking SPLAT_VECTOR as Custom enables generic DAGCombine to turn
BUILD_VECTOR into SPLAT_VECTOR. We need to custom type legalize BUILD_VECTOR
without Zfhmin since we don't have the scalar f16 type. If we allow
SPLAT_VECTOR to be formed, we'll need to custom type legalize it too.

Easiest fix is to only enable SPLAT_VECTOR with Zvfhmin+Zfhmin. There's
still an issue that we need to properly support BUILD_VECTOR with Zvfhmin+Zfhmin.

Should fix the new case reported in #97849.

I've also changed the predicates to Zfhmin instead of ZfhminOrZhinxmin
since Zhinx isn't compatible with Zvfhmin.
2024-07-08 22:44:58 -07:00
Carl Ritson
7eb1a320cc
[AMDGPU] Update EXECZ retention in SIPreEmitPeephole for GFX10/12 (#97676)
The check to maintain EXECZ branches only checks S_WAITCNT.
Add handling for new waitcnt instructions in GFX10 and GFX12.
2024-07-09 14:44:31 +09:00
Christian Sigg
2217933c6d [bazel][libc] Fix BUILD after 0182f5174f7cab31f8275718ae0aca7e9ac6fcd2. 2024-07-09 07:30:05 +02:00
Mingming Liu
50fea9943f
Reland "[ThinLTO][Bitcode] Generate import type in bitcode" (#97253)
https://github.com/llvm/llvm-project/pull/87600 was reverted in order to
revert
6262763341.
Now https://github.com/llvm/llvm-project/pull/95482 is fix forward for
6262763341.
This patch is a reland for
https://github.com/llvm/llvm-project/pull/87600

**Changes on top of original patch**
In `llvm/include/llvm/IR/ModuleSummaryIndex.h`, make the type of
`GVSummaryPtrSet` an `unordered_set` which is more memory efficient when
the number of elements is smaller than 128 [1]

**Original commit message**

For distributed ThinLTO, the LTO indexing step generates combined
summary for each module, and postlink pipeline reads the combined
summary which stores the information for link-time optimization.

This patch populates the 'import type' of a summary in bitcode, and
updates bitcode reader to parse the bit correctly.

[1]
393eff4e02/llvm/lib/Support/SmallPtrSet.cpp (L43)
2024-07-08 22:20:33 -07:00
Craig Topper
84741940f2
[RISCV] Remove unused RequiredFeatures argument from RVVIntrinsic constructor. NFC (#98067)
Looks like the usage was removed by
7a5cb15ea6facd82756adafae76d60f36a0b60fd
2024-07-08 21:48:29 -07:00
Luke Lau
3f83a69bcb
[RISCV] Allow folding vmerge into masked ops when mask is the same (#97989)
We currently only fold a vmerge into a masked true operand if the vmerge
has an all-ones mask, since we end up keeping the mask from the true
operand.

But if the masks are the same then we can still fold, because vmerge and
true have the same passthru. If an element was masked off in the
original vmerge, it will also be masked off in the resulting true, and
will have the same passthru value.

The motivation for this is to lower masked VP loads and stores with
passthrus to masked RVV instructions. Normally you can express a masked
RVV instruction with a mask undisturbed passthru via a combination of a
VP op with an all-ones mask and a vp.merge. But for loads and stores you
need the same mask on the VP op as well as the vp.merge.
2024-07-09 12:12:02 +08:00
Luke Lau
d0f3943a02
[RISCV] Remove -riscv-disable-insert-vsetvl-phi-opt flag (#97991)
This flag was added in https://reviews.llvm.org/D103277 out of
precaution, but it's been enabled by default for 3 years now and I
haven't seen any miscompiles upstream stemming from needVSETVLIPHI. This
would remove it just to simplify the number of configurations.
2024-07-09 12:11:08 +08:00
paperchalice
4010f894a1
[CodeGen][NewPM] Port SlotIndexes to new pass manager (#97941)
- Add `SlotIndexesAnalysis`.
- Add `SlotIndexesPrinterPass`.
- Use `SlotIndexesWrapperPass` in legacy pass.
2024-07-09 12:09:11 +08:00
PeterChou1
87d58ab22a
[clang-doc] fix paths by hard coding path to share (#98099) 2024-07-08 23:48:34 -04:00
Amir Ayupov
1d5ac72cd2
[MC][NFC] Fix typo in MCPseudoProbeFrameLocation (#98090) 2024-07-08 20:40:07 -07:00
vporpo
50881d03fc
[SandboxIR] Add BasicBlock and adds functionality to Function and Context (#97637)
We can now create SandboxIR from LLVM IR using the Context::create*
functions.
2024-07-08 20:10:28 -07:00
Joseph Huber
28695dd104 [libc] Disable block test on NVPTX
Summary:
We already disable the freelist, the block test also causes issues. We
don't use this code at all on the GPU so we can disable this test for
now.
2024-07-08 21:59:34 -05:00
paperchalice
ac0b2814c3
[CodeGen][NewPM] Port LiveVariables to new pass manager (#97880)
- Port `LiveVariables` to new pass manager.
- Convert to `LiveVariablesWrapperPass` in legacy pass manager.
2024-07-09 10:50:43 +08:00
Fangrui Song
366eb8f025 [Object] Fix IsRela typo after #91280 2024-07-08 19:10:59 -07:00
Joseph Huber
0182f5174f [libc][fix] Use off_t libc type directly
Summary:
Including stdio here caused some multiple definitions on overlay mode.
Just include `off_t` directly.

Is this correct for 32-bit targets? Will investigate further after
fixing bots.
2024-07-08 20:21:23 -05:00
Sudharsan Veeravalli
d65f423202
[RISCV] Handle empty structs/unions passing in C++ (#97315)
According to RISC-V integer calling convention empty structs or union
arguments or return values are ignored by C compilers which support them
as a non-standard extension. This is not the case for C++, which
requires them to be sized types.

Fixes #97285
2024-07-08 18:17:51 -07:00
Aiden Grossman
f1905f0644 Revert "[compiler-rt][X86] Use functions in cpuid.h instead of inline assembly (#97877)"
This reverts commit f6616e99c71c15d530060346ec29c3246d7fc235.

Was causing buildbot failures on Windows. I also remember seeing a
AMDGPU buildbot failing somewhere on a warning as they have -Werror
enabled.
2024-07-09 01:14:02 +00:00
Joseph Huber
673b6cd104
[libc] Use stdio.h for off_t instead of unistd.h (#98093)
Summary:
The `stdio.h` header should define `off_t` as defined for the platform.
This will use the system's in overlay mode, or what the llvm-libc-types
deems correct. If this `off_t` is incorrect it should be changed in
`llvm-libc-types`. This fixes the GPU build.
2024-07-08 20:12:34 -05:00
paperchalice
79d0de2ac3
[CodeGen][NewPM] Port machine-loops to new pass manager (#97793)
- Add `MachineLoopAnalysis`.
- Add `MachineLoopPrinterPass`.
- Convert to `MachineLoopInfoWrapperPass` in legacy pass manager.
2024-07-09 09:11:18 +08:00
Joseph Huber
afa6bed8af
[libc] Fix integer rint variants on the GPU (#98095)
Summary:
Currently these are implemented as a static cast on `__builtin_rint()`
to a long. Howver, this is not strictly correct. The standard states
that the output is unspecified, but most implementations, and the LLVM
libc implementation, do some kind of guarantee on this beahvior. This is
not guaranteed by just doing a cast. This patch just uses the generic
versions until we implement `__builitin_lrint` correctly.
2024-07-08 20:07:45 -05:00
Kevin Frei
b2fd1ebc35
Revert "[LLDB] DebugInfoD tests: attempt to fix Fuchsia build" (#98101)
Reverts llvm/llvm-project#96802

Attempt #5 fails. It's been 6 months. I despise Makefile.rules and have
no ability to even *detect* these failures without _landing_ a diff. In
the mean time, we have no testing for DWP files at all (and a regression
that was introduced, that I fix with this diff) so I'm going to just
remove some of the tests and try to land it again, but with less testing
I guess.
2024-07-08 17:59:00 -07:00
Mikhail R. Gadelha
c1f1aab5d5
[libc] Fix statfs_to_statvfs conversion function on rv32 (#98098) 2024-07-08 17:08:28 -07:00
Caslyn Tonelli
f6eda6fb7a
[libc] Fix for unused variable warning (#98086)
This fixes the `unused variable 'new_inner_size'` warning that arises
when `new_inner_size` is only used by `LIBC_ASSERT` by performing the
calculation directly in the macro.
2024-07-08 16:56:28 -07:00
Kevin Frei
2a7abb04e2
[LLDB] DebugInfoD tests: attempt to fix Fuchsia build (#96802)
This is the same diff I've put up at many times before. I've been trying
to add some brand new functionality to the LLDB test infrastucture
(create split-dwarf files!), and we all know that no good deed goes
unpunished. The last attempt was reverted because it didn't work on the
Fuchsia build.

There are no code differences between this and
[the](https://github.com/llvm/llvm-project/pull/90622)
[previous](https://github.com/llvm/llvm-project/pull/87676)
[four](https://github.com/llvm/llvm-project/pull/86812)
[diffs](https://github.com/llvm/llvm-project/pull/85693) landed &
reverted (due to testing infra failures). The only change in this one is
the way `dwp` is being identified in `Makefile.rules`.

Thanks to @petrhosek for helping me figure out how the fuchsia builders
are configured. I now prefer to use llvm-dwp and fall back to gnu's dwp
if the former isn't found. Hopefully this will work everywhere it needs
to.
2024-07-08 16:44:16 -07:00
Tom Stellard
4f3c9dabec
[mlir] Exclude CAPI test targets from default build target (#96545)
This helps reduce the build time for users that want to build MLIR, but
don't want to run the tests.
2024-07-08 16:37:05 -07:00
Paul Kirth
46a2abb91c
[clang-doc][nfc] Avoid constructing SmallString in ToString method (#96921)
This patch updates the return type of HTMLTag::toString from
SmallString<16> to StringRef, since this API only returns string
literals. As a result, there is no need to construct a full heap
allocated or owned string.

Additionally, this patch renames ToString to toString to match the LLVM
style guide.
2024-07-08 16:30:18 -07:00