15908 Commits

Author SHA1 Message Date
Matt Arsenault
843fb7be38
llvm-reduce: Fix overly conservative operands-to-args user restriction (#133854)
I assume this was a leftover from typed pointers. It's easier to replace
the non-callee uses, they are just replacable pointer values.
2025-04-10 07:10:25 +02:00
Matt Arsenault
5587932e20
llvm-reduce: Use simpleSimplifyCFG in block reduction (#135028) 2025-04-10 06:12:24 +02:00
Matt Arsenault
2828328611
llvm-reduce: Link to command guide in help like bugpoint does (#134810) 2025-04-10 06:11:19 +02:00
Matt Arsenault
989bc69ceb
llvm-reduce: Trim includes in ReduceInstructions (#135022) 2025-04-09 21:14:42 +02:00
Mircea Trofin
6d4d017fd2
[llvm-extract] Delete dead CG Profile edges (#134940)
When `llvm-extract`-ing a function, and the `CG Profile` flag is present in the original module, we end up with lots of `!{null, null, i64 1234}` entries for call edges that have disappeared as result of the removed functions.

This patch fixes that by adding a pass to `llvm-extract` that finds `CG Profile` edges with one or both operands `null` and removes them. This results in a cleaner output.
2025-04-09 10:36:12 -07:00
Jeremy Morse
40f9bb9e25
[DebugInfo][RemoveDIs] Eliminate another debug-info variation flag (#133917)
The "preserve input debug-info format" flag allowed some tooling to opt
into not seeing the new debug records yet, and to not autoupgrade. This
was good at the time, but un-necessary now that we'll be ditching
intrinsics shortly.

It also hides errors now: verify-uselistorder was hardcoding this flag
to on, and as a result it hasn't seen debug records before. Thus, we
missed a uselistorder variation: constant-expressions such as GEPs can
be contained within debug records and completely isolated from the value
hierachy, see the metadata-use-uselistorder.ll test. These Values didn't
get ordered, but were legitimate uses of constants like "i64 0", and we
now run into difficulty handling that. The patch to AsmWriter seeks
Values to order even through debug-info now.

Finally there are a few intrinsics-tests relying on this flag that we
can just delete, such as one in llvm-reduce and another few in the
LocalTest unit tests. For the fast-isel test, it was added in
https://reviews.llvm.org/D67703 explicitly for checking the size of
blocks without debug-info and in 1525abb9c94 the codepath it tests moved
towards being sunsetted. It'll be totally redundant once RemoveDIs is on
permanently.

Note that there's now no explicit test for the textual-IR autoupgrade
path. I submit that we can rely on the thousands of .ll files where
we've only been bothered to update the outputs, not the inputs, to debug
records.
2025-04-09 18:00:28 +01:00
Matt Arsenault
f0131c327e
llvm-reduce: Avoid reallocating per chunk iteration (#135029) 2025-04-09 18:57:53 +02:00
Matt Arsenault
1e9f46c1b3
llvm-reduce: Fix taking wrong error before exit (#135020) 2025-04-09 18:11:08 +02:00
Matt Arsenault
b6f4ec72f9
llvm-reduce: Add scope braces (#135025) 2025-04-09 18:10:13 +02:00
Madhur Amilkanthwar
a54ad59113
Revert "[llvm-exegesis][AArch64] Disable pauth and ldgm as unsupporte… (#134971)
…d instructions (#132346)"

This reverts commit 559540dc2738af0ab3f0b48eb4993095b8a8c627 as it has
cause build failures in llvm-clang-x86_64-gcc-ubuntu
2025-04-09 12:00:34 +05:30
Lakshay Kumar
559540dc27
[llvm-exegesis][AArch64] Disable pauth and ldgm as unsupported instructions (#132346)
[llvm-exegesis][AArch64] Disable pauth and ldgm as unsupported
instructions.
Skipping AUT and LDGM opcode variants which currently throws "illegal
instruction".
- Checking opcodes specifically for LDGM and AUT opcode instruction
variants.
- Gracefully exiting with " : Unsupported opcode:
isPointerAuth/isUncheckedAccess"
- Added corresponding test cases to check exit message.
2025-04-09 09:41:43 +05:30
Fangrui Song
02b377d8f7
[llc] Add -M for InstPrinter options
For many targets, llvm-objdump and llvm-mc
(https://reviews.llvm.org/D103004) support -M no-aliases (e.g.
`RISCVInstPrinter::applyTargetSpecificCLOption`).

This patch implements -M for llc.

While here, rename "DisassemblerOptions" in llvm-mc to the more
appropriate "InstPrinterOptions". For llvm-mc --assemble, there is no
disassembler involved.

Pull Request: https://github.com/llvm/llvm-project/pull/121078
2025-04-08 19:34:03 -07:00
Adrian Prantl
320c13e09a [dsymutil] Add missing dependency 2025-04-08 13:16:02 -07:00
Adrian Prantl
96f95c9d89 [dsymutil] Avoid copying binary swiftmodules built from textual
.swiftinterface files into the dSYM bundle. These typically come only
from the SDK (since textual interfaces require library evolution) and
thus are a waste of space to copy into the bundle.

The information about this is being parsed out of the control block,
which means duplicating 5 constants from the Swift frontend. If a file
cannot be parsed, dsymutil errs on the side of copying the file
anyway.

rdar://138186524

Relanding with additional linker dependency and moving the test into
the right target subdirectory.
2025-04-08 12:37:27 -07:00
Adrian Prantl
2721d50d87 Revert "[dsymutil] Avoid copying binary swiftmodules built from textual"
This reverts commit 39ace8a63012af7d6ad7bf065c233fd3d5df44a3.

while investigating Linux bot failures.
2025-04-08 09:49:36 -07:00
Adrian Prantl
5615061445
[dsymutil] Avoid copying binary swiftmodules built from textual (#134719)
.swiftinterface files into the dSYM bundle. These typically come only
from the SDK (since textual interfaces require library evolution) and
thus are a waste of space to copy into the bundle.

The information about this is being parsed out of the control block,
which means duplicating 5 constants from the Swift frontend. If a file
cannot be parsed, dsymutil errs on the side of copying the file anyway.

rdar://138186524
2025-04-08 08:03:32 -07:00
Michael Kruse
8b11c39a0f
[llvm-mt] Do not build llvm-mt if not functional (#134631)
llvm-mt requires libxml2 to work, so do not even build it without
libxml2.

CMake 3.31 and later prefer llvm-mt.exe over Microsoft's mt.exe if
available and using clang-cl.exe as CMAKE_CXX_COMPILER. When CMake picks
up llvm-mt.exe without libxml2, any build will fail with the message
```
llvm-mt: error: no libxml2
```

Any test except `--help` already uses `REQUIRES: libxml2`. There is no
point in having a non-functional executable. Not building llvm-mt.exe
will force CMake to use Microsoft's `mt.exe` instead.

Fixes: #134237
2025-04-08 16:16:53 +02:00
Matt Arsenault
3a0c95fb50
llvm-reduce: Fix introducing unreachable code in simplify conditionals (#133842)
After replacing the branch condition, this was calling simplifyCFG to
perform the cleanups of the branch. This is far too heavy of a hammer.
We do not want all of the extra optimizations in simplifyCFG, and
this could also leave behind dead code. Instead, minimally fold the
terminator and try to delete the newly dead code.

This is pretty much a direct copy of what bugpoint does.
2025-04-08 08:51:20 +07:00
Linux User
0a35dd7e99
[llvm-ar] --help: fix unquoted angle bracket (#101364)
Changes the argument in llvm-ar help message from `-M [<mri-script]` to
`-M [< mri-script]`
2025-04-07 17:12:50 +01:00
Alexander Yermolovich
4f902d2425
[llvm-dwarfdump] Make --verify for .debug_names multithreaded. (#127281)
This PR makes verification of .debug_names acceleration table
multithreaded. In local testing it improves verification of clang
.debug_names from four minutes to under a minute.
This PR relies on a current mechanism of extracting DIEs into a vector. 
Future improvements can include creating API to extract one DIE at a
time, or grouping Entires into buckets by CUs and extracting before
parallel step.

Single Thread
4:12.37 real,   246.88 user,    3.54 sys,       0 amem,10232004 mmem
Multi Thread
0:49.40 real,   612.84 user,    515.73 sys,     0 amem, 11226292 mmem
2025-04-03 14:02:27 -07:00
Joseph Huber
e5809f0172
[LLVM] Only build the GPU loader utility if it has LLVM-libc (#134141)
Summary:
There were some discussions about this being included by default. I need
to fix this up and codify the use of LLVM libc inside of LLVM. For now,
just turn it off unless the user requested the `libc` GPU stuff. This
matches the old behavior.
2025-04-02 19:26:19 -05:00
Matt Arsenault
efca37fda5
llvm-reduce: Change exit code for uninteresting inputs (#134021)
This makes it easier to reduce llvm-reduce with llvm-reduce to filter
cases where the input reduced too much.

Not sure if it's possible to test the exit code in lit.
2025-04-02 23:43:06 +07:00
Matt Arsenault
2b7fe90a01
llvm-reduce: Avoid worklist in simplify-instruction (#134066) 2025-04-02 22:21:28 +07:00
Miro Hrončok
e0f8898e1d
Avoid a race condition in opt-viewer/optrecord (#131214)
See https://bugzilla.redhat.com/2336915
See https://reviews.llvm.org/D41784?id=
See
https://github.com/androm3da/optviewer-demo/issues/4#issuecomment-718787822

Fixes https://github.com/llvm/llvm-project/issues/62403.

The race condition happened when the demangler_proc was being set. The
locking mechanism itself happened too late.

This way, the lock always exists (to avoid a race when creating it) and
is always used when *creating* demangler_proc.
2025-04-02 11:52:41 +02:00
Matt Arsenault
cde2ea377d
llvm-reduce: Defer a shouldKeep call in operand reduction (#133387)
Ideally shouldKeep is only called in contexts that will successfully
do something.
2025-04-02 15:00:41 +07:00
Matt Arsenault
09e19cfacf
llvm-reduce: Do not reduce alloca array sizes to 0 (#132864)
Fixes #64340
2025-04-02 13:44:45 +07:00
Matt Arsenault
964650b69e
llvm-reduce: Add reduceOperandsToPoison reduction (#132862)
For now use it only for TargetExtTypes, which do not always support
zero initializers.
2025-04-02 13:38:46 +07:00
Matt Arsenault
23d894e0a3 llvm-reduce: Fix comment typo 2025-04-02 11:43:09 +07:00
Matt Arsenault
adbe9e20bf
llvm-reduce: Skip setting br conditions on already constant branches (#133841)
If we are trying to simplify branch conditions to true, ignore branches
already set to a constant true. If we are simplifying to constant false,
ignore the already constant false cases. This saves steps in this edge
case, and avoids the side effect of running simplifycfg on blocks we
did not intend to modify.
2025-04-02 11:41:47 +07:00
Matt Arsenault
55ac652745
llvm-reduce: Do not delete convergencectrl in operand-bundles (#133858)
The IR verifier will fail if there are any convergent calls without
a convergencectrl bundle, if there are any convergencectrl bundles.

With the current verifier rules, we would need to drop all the instances
of convergencectrl in the function as a set, and strip all the
convergence
token intrinsics. As such, I think it would be more appropriate to have
a
separate convergence reduction pass.
2025-04-02 08:48:02 +07:00
Matt Arsenault
f60eed9344
llvm-reduce: Add target-features-attr reduction (#133887)
Try to reduce individual subtarget features in the "target-features"
attribute. This attempts a textual removal of the fields in the string,
not a semantic removal. Typically there's a lot of redundant feature spam
in the feature list implied by the target-cpu (which I really wish clang
would stop emitting). If we could parse these out, we could easily drop
the fields without testing anything.
2025-04-02 00:03:43 +07:00
Matt Arsenault
5c4302442b
llvm-reduce: Reduce global variable code model (#133865)
The current API doesn't have a way to unset it. The query returns
an optional, but the set doesn't. Alternatively I could switch the
set to also use optional.
2025-04-01 23:54:10 +07:00
Matt Arsenault
ec290a43f6
llvm-reduce: Reduce externally_initialized (#133859)
Not sure this is the right place to put it. This is a property
of GlobalVariable, not GlobalValue. But the ReduceGlobalVars
reduction tries to delete the value entirely.
2025-04-01 23:51:45 +07:00
Matt Arsenault
664e847916
llvm-reduce: Fix invalid reduction on tokens in operands-to-args (#133855) 2025-04-01 22:14:47 +07:00
Jeremy Morse
1ebc308bba
[DebugInfo][RemoveDIs] Remove debug-intrinsic printing cmdline options (#131855)
During the transition from debug intrinsics to debug records, we used
several different command line options to customise handling: the
printing of debug records to bitcode and textual could be independent of
how the debug-info was represented inside a module, whether the
autoupgrader ran could be customised. This was all valuable during
development, but now that totally removing debug intrinsics is coming
up, this patch removes those options in favour of a single flag
(experimental-debuginfo-iterators), which enables autoupgrade, in-memory
debug records, and debug record printing to bitcode and textual IR.

We need to do this ahead of removing the
experimental-debuginfo-iterators flag, to reduce the amount of
test-juggling that happens at that time.

There are quite a number of weird test behaviours related to this --
some of which I simply delete in this commit. Things like
print-non-instruction-debug-info.ll , the test suite now checks for
debug records in all tests, and we don't want to check we can print as
intrinsics. Or the update_test_checks tests -- these are duplicated with
write-experimental-debuginfo=false to ensure file writing for intrinsics
is correct, but that's something we're imminently going to delete.

A short survey of curious test changes:
* free-intrinsics.ll: we don't need to test that debug-info is a zero
cost intrinsic, because we won't be using intrinsics in the future.
* undef-dbg-val.ll: apparently we pinned this to non-RemoveDIs in-memory
mode while we sorted something out; it works now either way.
* salvage-cast-debug-info.ll: was testing intrinsics-in-memory get
salvaged, isn't necessary now
* localize-constexpr-debuginfo.ll: was producing "dead metadata"
intrinsics for optimised-out variable values, dbg-records takes the
(correct) representation of poison/undef as an operand. Looks like we
didn't update this in the past to avoid spurious test differences.
* Transforms/Scalarizer/dbginfo.ll: this test was explicitly testing
that debug-info affected codegen, and we deferred updating the tests
until now. This is just one of those silent gnochange issues that get
fixed by RemoveDIs.

Finally: I've added a bitcode test, dbg-intrinsics-autoupgrade.ll.bc,
that checks we can autoupgrade debug intrinsics that are in bitcode into
the new debug records.
2025-04-01 14:27:11 +01:00
Matt Arsenault
290d7b82cb
llvm-reduce: Prune some unneeded includes and forward declares (#133883) 2025-04-01 18:23:27 +07:00
Matt Arsenault
14c5098640
llvm-reduce: Use takeName when moving arguments in operands-to-args (#133851) 2025-04-01 14:48:14 +07:00
Matt Arsenault
f77f2b9c56
llvm-reduce: Try to preserve instruction metadata as argument attributes (#133557)
Fixes #131825
2025-04-01 07:34:31 +07:00
AnastasiyaChernikova
5a3079421b
Add RISC-V support information to readme (#132699) 2025-03-31 22:13:46 +03:00
Aiden Grossman
980d66caae
[llvm-exegesis] Error Out If Perf Counter is Not Fully Enabled (#132892)
Perf counters can be multiplexed if there are too many that need to be
scheduled on a core at the same time (and they exceed the available
PMUs). Other processes (especially system ones in certain environments,
not commonly on Desktop Linux from what I've seen) can also interfere.
This will impact the measurement fidelity as the counter is not actually
counting cycles/uops the entire time. This patch makes it so that we
error out in these cases so the user gets a visible indication things
have gone wrong rather than things failing silently.
2025-03-31 10:58:24 -07:00
Matt Arsenault
f82283a84e
llvm-reduce: Use 80 dashes for section separator in status printing (#133686) 2025-03-31 18:06:37 +07:00
Matt Arsenault
057b3c2452 llvm-reduce: Trim unnecessary includes 2025-03-30 14:59:43 +07:00
Matt Arsenault
a03367fd01 llvm-reduce: Remove trailing whitespace 2025-03-30 12:44:14 +07:00
Kazu Hirata
8db434a481
[bugpoint] Avoid repeated hash lookups (NFC) (#133616) 2025-03-29 22:40:05 -07:00
YLChenZ
fea6b38805
[llvm-reduce]: print short form, actionable names in the log (#133561)
Closes #132696

before the patch like this:
```
----------------------------
*** Reducing GlobalObjects...
----------------------------
*** Reducing GV Initializers...
----------------------------
*** Reducing GlobalVariables...
----------------------------
```
after the patch like this:
```
----------------------------
*** Reducing GlobalObjects (global-objects)...
----------------------------
*** Reducing GV Initializers (global-initializers)...
----------------------------
*** Reducing GlobalVariables (global-variables)...
----------------------------
```
2025-03-30 12:37:48 +07:00
Shilei Tian
847cdd46e5 [NFC][llvm-reduce] Fix an used variable warning in ReduceOperandsToArgs.cpp 2025-03-29 11:39:05 -04:00
Tim Gymnich
0bed72160c
Revert "[NFC] LLVM reduce: remove unused variable" (#133586)
Reverts llvm/llvm-project#133584
2025-03-29 14:59:56 +01:00
Tim Gymnich
9451617d56
[NFC] LLVM reduce: fix unused variable (#133584) 2025-03-29 14:50:55 +01:00
Matt Arsenault
d852cc5311
llvm-reduce: Fix losing call metadata in operands-to-args (#133422) 2025-03-29 16:20:49 +07:00
Matt Arsenault
d3d4a242de
llvm-reduce: Fix losing fast math flags in operands-to-args (#133421) 2025-03-29 16:17:43 +07:00