534051 Commits

Author SHA1 Message Date
Reid Kleckner
0a27c4e318
[StrTable] Use string literal emission for intrinsics on non-MSVC platforms (#124856)
This mainly transitions the LLVM intrinsic string table from character
emission to string literal emission, which I confirmed happens for me
locally.

I moved the guts of StringToOffsetTable to a cpp file so I could move
the `EmitLongStrLiterals` cl::opt global to a non-vague linkage home in
the `TableGen` library. I had to add missing FormatVariadic.h includes
to account for moving other includes to a cpp file.
2025-04-13 17:58:53 +02:00
Matt Arsenault
30ae47eeef SCEVExpander: Don't look at uses of constants (#134691)
This could be more relaxed, and look for uses of globals in
the same function but no tests apparently depend on that.
2025-04-13 17:17:33 +02:00
Matt Arsenault
393c783a10 LICM: Avoid looking at use list of constant data (#134690)
The codegen test changes seem incidental. Either way,
sms-grp-order.ll seems to already not hit the original issue.
2025-04-13 17:06:38 +02:00
Matt Arsenault
b37476f99c PHITransAddr: Avoid looking at constant use lists (#134689)
Avoids asserts in GVN
2025-04-13 16:58:57 +02:00
Matt Arsenault
a24ef4b07e SimplifyLibCalls: Skip sincospi optimization for ConstantData (#134688)
Avoids looking at the uselist, and it would probably be more
productive to constant fold this.
2025-04-13 16:47:07 +02:00
Matt Arsenault
db20b0d4ec ObjCARC: Add regressed testcase from #134275 2025-04-13 16:34:11 +02:00
Shilei Tian
ce01e4e2f6
[Clang][OpenCL][AMDGPU] Use byref for aggregate OpenCL kernel arguments (#134892)
Due to a previous workaround allowing kernels to be called from other
functions,
Clang currently doesn't use the `byref` attribute for aggregate kernel
arguments. The issue was recently resolved in
https://github.com/llvm/llvm-project/pull/115821. With that fix, we can
now
enable the use of `byref` consistently across all languages.

Co-authored-by: Matt Arsenault <Matthew.Arsenault@amd.com>

Fixes SWDEV-247226.

Co-authored-by: Matt Arsenault <Matthew.Arsenault@amd.com>
2025-04-13 10:17:55 -04:00
Timm Baeder
578ca5e469
[clang][bytecode] Print jump lines in Function::dump() (#135482)
E.g. for
```c++
constexpr int foo(int b) {
  int a = 1+1;

  for (int i = 0; i < b; ++i) {
    ++a;
  }
  return a;
}
```

we now print:
```
foo 0x7cc8d4bf0580
frame size: 128
arg size:   8
rvo:        0
this arg:   0
0      InitScope         0
16     ConstSint32       1
32     ConstSint32       1
48     AddSint32
56     SetLocalSint32    40
72     ConstSint32       0
88     SetLocalSint32    104
104    GetPtrLocal       104         <-+
120    LoadPopSint32                   |
128    GetPtrParam       0             |
144    LoadPopSint32                   |
152    LTSint32                        |
160    Jf                80     --+    |
176    GetPtrLocal       40       |    |
192    IncPopSint32      1        |    |
208    GetPtrLocal       104      |    |
224    IncPopSint32      1        |    |
240    Jmp               -152     |  --+
256    GetPtrLocal       40     <-+
272    LoadPopSint32
280    Destroy           0
296    RetSint32
304    Destroy           0
320    NoRet
```
2025-04-13 15:46:01 +02:00
Daniel Chen
1264d7a53a
[driver] Generalize the code that adds the path of libflang_rt.runtime.a. (#134362)
The PR is to generalize the re-use of the `compilerRT` code of adding
the path of `libflang_rt.runtime.a (so)` from AIX and LoP only to all
platforms via a new function `addFlangRTLibPath`.

It also added `-static-libflangrt` and `-shared-libflangrt` compiler
options to allow users choosing which `flang-rt` to link to. It defaults
to shared `flang-rt`, which is consistent with the linker behavior,
except on AIX, it defaults to static.

Also, PR #134320 exposed an issue in PR #131041 that the the overriding
`addFortranRuntimeLibs` is missing the link to `libquadmath`. This PR
also fixed that and restored the test case that PR #131041 broke.
2025-04-13 09:22:31 -04:00
Matt Arsenault
ccfb97b421 Revert "clang/AMDGPU: Stop looking for oclc_daz_opt_* control libraries (#134805)"
This reverts commit 028429ac452acde227ae0bfafbfe8579c127e1ea and
1004fae222efeee215780c4bb4e64eb82b07fb4f.

These really need to be part of the compiler distribution. Bots are
relying on a nearly year old version to provide bitcode.
2025-04-13 14:47:39 +02:00
Kazu Hirata
d1d5f00a8e
[Passes] Avoid repeated hash lookups (NFC) (#135542) 2025-04-13 05:46:29 -07:00
Kazu Hirata
4b4cd645a8
[ExecutionEngine] Avoid repeated map lookups (NFC) (#135541) 2025-04-13 05:46:15 -07:00
Kazu Hirata
62d2cc84ac
[CodeGen] Avoid repeated hash lookups (NFC) (#135540) 2025-04-13 05:45:53 -07:00
Peng Liu
703cfe745b
[libc++] Replace __libcpp_popcount by __builtin_popcountg (#133937)
`__libcpp_popcount` was previously used as a fallback for `__builtin_popcountg` to ensure compatibility with older compilers (Clang 18 and earlier), as `__builtin_popcountg` became available in Clang 19. Now that support for Clang 18 has been officially dropped in #130142, we can now safely  replace all instances of `__libcpp_popcount` with `__builtin_popcountg` and eliminate the fallback logic.
2025-04-13 08:40:21 -04:00
Florian Hahn
5550d30228
[VPlan] Check captured operand when simplifying redundant OR.
Follow-up to 0f607f to actually use the captured operand X instead of Y.
2025-04-13 13:23:27 +01:00
Yingwei Zheng
bb9580a02b
[SCEV] Use ashr to adjust constant multipliers (#135534)
SCEV converts "-2 *nsw (i32 V)" into "2148473647 *nsw (i32 V)". But we
cannot preserve the nsw flag when the constant multiplier is negative.
This patch changes lshr to ashr so that we can preserve both nsw and nuw
flags.

Alive2 proof: https://alive2.llvm.org/ce/z/LZVSEa
Closes https://github.com/llvm/llvm-project/issues/135531.
2025-04-13 20:22:48 +08:00
Kazu Hirata
77fcdb9f26
[Scalar] Avoid repeated hash lookups (NFC) (#132660) 2025-04-13 04:35:20 -07:00
Andreas Jonson
ed43207306
[SimplifyCFG] Handle trunc condition in foldBranchToCommonDest. (#135490)
proof: https://alive2.llvm.org/ce/z/v32Aof
2025-04-13 13:16:15 +02:00
Florian Hahn
0f607f3df5
[VPlan] Simplify 'or x, true' -> true.
Add additional OR simplification to fix a divergence between legacy and
VPlan-based cost model.

This adds a new m_AllOnes matcher by generalizing specific_intval to
int_pred_ty, which takes a predicate to check to support matching both
specific APInts and other APInt predices, like isAllOnes.

Fixes https://github.com/llvm/llvm-project/issues/131359.
2025-04-13 12:09:40 +01:00
Timm Baeder
09588e93bb
[clang][bytecode] Fix an inconsistency with loop condition jumps (#135530)
When emitting the jump for e.g. a for loop condition, we used to jump
out of the CondScope, leaving the scope initialized, because we skipped
the corresponding Destroy opcode. If that loop was in a loop itself,
that outer loop could then iterate once more, leading to us initializing
a scope that was still initialized.
Fix this by also destroying the scope after the EndLabel.
2025-04-13 12:25:29 +02:00
Matt Arsenault
beac727e48
IROutliner: Do not look at use lists of constant phi inputs (#135019)
Theoretically this does a worse job with globals but this is not
covered by existing tests
2025-04-13 12:12:46 +02:00
Sean Perry
84666d6874
Add back include for AutoConvert.h as it's needed for z/OS (#135430)
The commit
a1935fd380
removed an include that is needed when building on z/OS.
2025-04-13 03:04:58 -07:00
Luke Lau
3bebda0758
[VPlan] Mark VPWidenCallRecipe as a VPRecipeWithIRFlags (#135373)
I noticed VPWidenCallRecipe was missing here, it looks like it should be
handled in VPRecipeWithIRFlags::classof
2025-04-13 10:59:15 +01:00
Nikolas Klauser
4e0876ee43
[libc++] Use __underlying_type directly in underyling_type_t (#135423)
This avoids instantiating multiple classes, reducing compile times. This
patch also introduces `__underyling_type_t` for internal use, similar to
other type traits.
2025-04-13 11:01:17 +02:00
Matt Arsenault
1004fae222 flang: Try to update test for oclc_daz_opt removal
Try to fix bot failure after 028429ac452acde227ae0bfafbfe8579c127e1ea
2025-04-13 10:01:49 +02:00
Fangrui Song
ca5b3a0f51 [MC] Remove SetUsed on isUndefined and getFragment
Due to the known limitations of .set reassignment (see
https://sourceware.org/PR288), we use diagnostics to reject patterns
that could lead to errors (ae7ac010594f693fdf7b3ab879e196428d961e75 2009-06)).

This code gets refined multiple times, see:

* 9b4a824217f1fe23f83045afe7521acb791bc2d0 (2010-05) `IsUsedInExpr`
* 46c79ef1132607aead144dfda0f26aa8b065214f (2010-11) renamed `IsUsedInExpr` to `IsUsed`

The related `SetUsed` bit seems unnecessary nowadays.
2025-04-13 00:53:29 -07:00
Pavel Labath
1c5ce2d74f Reapply "[lldb] ProcessGdbRemote header gardning"
This reverts commit 68ab45f0533f3bbfc1c96bddd53de7e769180219, reapplying
2fd860c1f559c0b0be66cc000e38270a04d0a1a3. The only change is keeping
"lldb/Host/Config.h", which I believe was the cause of the failures.
2025-04-13 09:52:30 +02:00
Matt Arsenault
028429ac45
clang/AMDGPU: Stop looking for oclc_daz_opt_* control libraries (#134805)
These have been empty since July 2023
2025-04-13 09:48:21 +02:00
A. Jiang
5c45e239e8
[libc++][test][NFC] Remove unused inclusions of <iostream> (#134776)
Some test files for flat container adaptors redundantly include
`<iostream>` and, surprisingly, `<cstddef>`. This patch removes the
redundant inclusions.

Inclusions of `<vector>` is also removed since a sane implementation is
expected to make instantiation of `flat_(multi)map<K, V>` or
`flat_(multi)set<K>` valid when only `<flat_map>` or `<flat_set>` is
included.
2025-04-13 15:17:58 +08:00
Christian Sigg
12a7155ee2 [mlir][bazel] Port mlir-translate bits of acf964b95f54. 2025-04-13 09:13:17 +02:00
Thurston Dang
d6e2aee9b1
Revert "[tosa]: canonicalize dynamic size of tosa.slice to static output shape" (#135525)
Reverts llvm/llvm-project#135429 due buildbot breakage:
https://lab.llvm.org/buildbot/#/builders/169/builds/10405

Based on the ASan output, I think after the replaceOp on line 775, it's
no longer valid to do getSize() on sliceOp:
```
   775      rewriter.replaceOp(sliceOp, newSliceOp.getResult());
   776
   777      // Remove const_shape size op when it no longer has use point.
   778      Operation *sizeConstShape = sliceOp.getSize().getDefiningOp();
```
2025-04-13 00:07:28 -07:00
Pavel Labath
f4fba20726
[lldb] Remove vestigial remnants of reproducers (#135361)
Not touching the SB API.
2025-04-13 08:55:24 +02:00
Kazu Hirata
7940b0546b [BOLT] Fix warning
This patch fixes:

  bolt/lib/Core/BinaryContext.cpp:582:8: error: unused variable
  'printEntryDiagnostics' [-Werror,-Wunused-variable]

  bolt/lib/Core/BinaryContext.cpp:842:10: error: unused variable
  'isSibling' [-Werror,-Wunused-variable]
2025-04-12 23:35:49 -07:00
Fangrui Song
6196379baf [PowerPC] Fix -Wunused-variable 2025-04-12 23:24:47 -07:00
Fangrui Song
19730e37ec ELFObjectWriter: Make .reloc test generic
Move `Fixup.getKind() >= FirstLiteralRelocationKind` from target hooks
to ELFObjectWriter::recordRelocation.

Currently, getRelocType cannot be skipped for LoongArch due to #135519
2025-04-12 23:02:24 -07:00
Fangrui Song
734660b6dd ELFObjectWriter: Simplify STT_SECTION adjustment 2025-04-12 21:34:57 -07:00
Congcong Cai
06814834a6
[clang-tidy] treat unsigned char and signed char as char type by default in bugprone-unintended-char-ostream-output (#134870)
Add `AllowedTypes` options to support custom defined char like type.
treat `unsigned char` and `signed char` as char like type by default.
The allowed types only effect when the var decl or explicit cast to this
non-canonical type names.

Fixed: #133425
2025-04-13 12:09:50 +08:00
Congcong Cai
302bc41410
[clang-tidy] matchesAnyListedTypeName support non canonical types (#134869) 2025-04-13 12:06:48 +08:00
Fangrui Song
3ff634dee8 Revert "ELFObjectWriter: Disable STT_SECTION adjustment for .reloc"
This reverts commit 1c5961c0481b9c7421d38e3141d3c5a1e6084234.
Inadvertently pushed.
2025-04-12 21:02:27 -07:00
Fangrui Song
1c5961c048 ELFObjectWriter: Disable STT_SECTION adjustment for .reloc
to match GNU Assembler. This generalizes the SHT_LLVM_CALL_GRAPH_PROFILE
(which uses BFD_RELOC_NONE https://reviews.llvm.org/D104080) special case.
2025-04-12 21:00:25 -07:00
Fangrui Song
329a675006 ELFObjectWriter: Simplify STT_SECTION adjustment. NFC 2025-04-12 20:54:05 -07:00
A. Jiang
3e7be494f8
[libc++][test] Test nasty_string in C++20 (#135338)
It seems that we can only rely on C++20 features and make `nasty_string`
also tested for MSVC STL.
2025-04-13 11:23:13 +08:00
Fangrui Song
39662922e1 MCObjectStreamer: Refine absoluteSymbolDiff condition
The function is called to test the fast path - when Lo/Hi are within the
same fragment. This is unsafe - Lo/Hi at the begin and end of a
relaxable fragment should not evaluate to a constant. However, we don't
have tests that exercise the code path.

Nevertheless, make the check safer and remove the now unnecessary
isRISCV check (from https://reviews.llvm.org/D103539).
2025-04-12 19:02:07 -07:00
Jakub Kuderski
b0acbbee88
[mlir][vector] Fix deprecation warning for .isa. NFC. (#135512)
This was introduced in: https://github.com/llvm/llvm-project/pull/135371
2025-04-12 21:49:40 -04:00
A. Jiang
cfa322fa9a
[libc++][NFC] Reuse __bit_log2 for sort (#135303)
The `__log2i` function template in `<algorithm/sort.h>` is basically
equivalent to `__bit_log2` in `<__bit/bit_log2.h>`. It seems better to
avoid duplication.
2025-04-13 09:45:18 +08:00
Sayan Saha
60b1d44d70
[tosa]: canonicalize dynamic size of tosa.slice to static output shape (#135429)
Addresses https://github.com/llvm/llvm-project/issues/135389
2025-04-12 18:24:07 -04:00
Shilei Tian
b0fede358f
[ThinLTO] Don't convert functions to declarations if force-import-all is enabled (#134541)
On one hand, we intend to force import all functions when the option is
enabled.
On the other hand, we currently drop definitions of some functions and
convert
them to declarations, which contradicts this intent.

With this PR, functions will no longer be converted to declarations when
`force-import-all` is enabled.
2025-04-12 18:22:22 -04:00
Owen Pan
5f744cc630
[clang-format] Wrap and indent lambda braces in GNU style (#135479)
Fix #133135
2025-04-12 15:06:21 -07:00
Owen Pan
09c8cfe219
[clang-format][NFC] Add isJava() and isTextProto() in FormatStyle (#135466)
Also remove redundant name qualifiers format::, FormatStyle::, and
LanguageKind::.
2025-04-12 15:04:29 -07:00
Jan Patrick Lehr
bbc5d205d4
[MLIR] Fix build after #131492 (#135502)
After #131492 is appears that linking MLIRAritDialect was missing.
2025-04-12 23:22:42 +02:00