15613 Commits

Author SHA1 Message Date
Teresa Johnson
bb3915149a
[MemProf] Support for random hotness when writing profile (#113998)
Add support for generating random hotness in the memprof profile writer,
to be used for testing. The random seed is printed to stderr, and an
additional option enables providing a specific seed in order to
reproduce a particular random profile.
2024-10-29 22:10:33 -07:00
tf2spi
f23bdbbaff
Add DILabel functions for LLVM-C (#112840)
Addresses #112799
2024-10-28 10:59:53 -07:00
Fangrui Song
92412c106f
[llvm-objdump] Handle -M for --macho
--macho -d uses the `parseInputMachO` code path, which does not handle
-M. Add -M handling for --macho as well.

Close #61019

Pull Request: https://github.com/llvm/llvm-project/pull/113795
2024-10-28 09:40:15 -07:00
Edd Dawson
d4dd770289
[llvm-cxxfilt] De-emphasize "function" in llvm-cxxfilt docs and --help (#113309)
llvm-cxxfilt can demangle names of data symbols, in addition to function
names.

    $ llvm-cxxfilt _ZN6garden5gnomeE
    garden::gnome

And type names too, on request:

    $ llvm-cxxfilt -t i
    int

Update some overly specific the wording in the --help and documentation
that suggests otherwise.
2024-10-23 13:03:30 +01:00
Mészáros Gergely
7ab6d39a4d
[LLVM][CMake][MSVC] Wrap linker flags for ICX on Windows (#112680)
The Intel C++ Compiler (ICX) passes linker flags through the driver
unlike MSVC and clang-cl, and therefore needs them to be prefixed with
`/Qoption,link` (the equivalent of `-Wl,` for gcc on *nix).

Use `LINKER:` prefix wherever supported by cmake, when that's not
possible fall-back to `${CMAKE_CXX_LINKER_WRAPPER_FLAG}`. CMake replaces
these with `/Qoption,link` for ICX and with the empty string for MSVC
and clang-cl.

For `target_link_libraries` neither `LINKER:` (not supported prior to
CMake 3.32) nor `${CMAKE_CXX_LINKER_WRAPPER_FLAG}` (does not begin with
`-` would be taken as a library name) works, use `-Qoption,link`
directly within a conditional generator expression that we're linking
with ICX.

For MSVC and clang-cl no functional change is intended.

Tested by compiling with ICX and setting
`CMAKE_(EXE|SHARED|STATIC|MODULE)_LINKER_FLAGS_INIT` to
`-Werror=unknown-argument`.

RFC:
https://discourse.llvm.org/t/rfc-cmake-linker-flags-need-wl-equivalent-for-intel-c-icx-on-windows/82446
2024-10-23 13:03:25 +02:00
Carl Ritson
076aac59ac
[AMDGPU] Add a new target for gfx1153 (#113138) 2024-10-23 12:56:58 +09:00
Jinsong Ji
d985197156
[NFC][Fuzzer] Refactor to avoid a false warning from gcc (#112944)
This is one of the many PRs to fix errors with LLVM_ENABLE_WERROR=on.
Built by GCC 11.

Refactor the code to avoid the false warning

llvm-project/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
llvm-project/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp: In
function ‘int LLVMFuzzerInitialize(int*, char***)’:
llvm-project/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp:141:43:
error: ISO C++ forbids zero-size array ‘argv’ [-Werror=pedantic]
  141 |   ExitOnError ExitOnErr(std::string(*argv[0]) + ": error:");
      |
2024-10-22 17:39:05 -04:00
Jonas Devlieghere
5886454669
[dsymutil] Provide an option to ignore object timestamp mismatches (#113238)
Provide a option (--no-object-timestamp) to ignore object file timestamp
mismatches. We already have a similar option for Swift modules
(--no-swiftmodule-timestamp).

rdar://123975869
2024-10-22 09:48:02 -07:00
Jonas Devlieghere
2ccbea1d73
[dsymutil] Share one BinaryHolder between debug map parsing & linking (#113234)
I (re)discovered that dsymutil was instantiating two BinaryHolders: one
for parsing the debug map and one for linking. That really defeats the
purpose of the BinaryHolder as it serves as a cache. Fix the issue and
remove an old FIXME.
2024-10-22 09:40:34 -07:00
Kazu Hirata
da66f6a280
[llvm-jitlink] Use heterogenous lookups with std::map (NFC) (#113245) 2024-10-22 07:58:50 -07:00
Kazu Hirata
61a286ac08
[tools] Don't call StringRef::str() when calling StringMap::find (NFC) (#113119)
StringMap::find takes StringRef.  We don't need to create an instance
of std::string from StringRef only to convert it right back to
StringRef.
2024-10-21 06:50:34 -07:00
Ronan Keryell
d582442bec
[llvm-cxxfilt] Add --quote option to quote demangled function names (#111871)
This is useful when looking at LLVM/MLIR assembly produced from C++
sources. For example
 cir.call @_ZN3aie4tileILi1ELi4EE7programIZ4mainE3$_0EEvOT_(%2, %7) :
will be translated to
cir.call @"void aie::tile<1, 4>::program<main::$_0>(main::$_0&&)"(%2,
%7) : which can be parsed as valid MLIR by the right mlir-lsp-server.

If a symbol is already quoted, do not quote it more.

---------

Co-authored-by: James Henderson <jh7370@my.bristol.ac.uk>
2024-10-21 08:54:04 +01:00
Kazu Hirata
3bddf85e52
[sancov] Avoid repeated map lookups (NFC) (#113026) 2024-10-20 10:41:42 -07:00
NAKAMURA Takumi
4a011ac84f
[Coverage] Introduce "partial fold" on BranchRegion (#112694)
Currently both True/False counts were folded. It lost the information,
"It is True or False before folding." It prevented recalling branch
counts in merging template instantiations.

In `llvm-cov`, a folded branch is shown as:

- `[True: n, Folded]`
- `[Folded, False n]`

In the case If `n` is zero, a branch is reported as "uncovered". This is
distinguished from "folded" branch. When folded branches are merged,
`Folded` may be dissolved.

In the coverage map, either `Counter` is `Zero`. Currently both were
`Zero`.

Since "partial fold" has been introduced, either case in `switch` is
omitted as `Folded`.

Each `case:` in `switch` is reported as `[True: n, Folded]`, since
`False` count doesn't show meaningful value.

When `switch` doesn't have `default:`, `switch (Cond)` is reported as
`[Folded, False: n]`, since `True` count was just the sum of `case`(s).
`switch` with `default` can be considered as "the statement that doesn't
have any `False`(s)".
2024-10-20 12:30:35 +09:00
Kazu Hirata
f4136b3265
[llvm-diff] Avoid repeated hash lookups (NFC) (#113025) 2024-10-19 14:42:25 -07:00
Kazu Hirata
a99bf0f6c9
[llvm-readtapi] Simplify code with StringMap::operator[] (NFC) (#112824) 2024-10-18 08:40:05 -07:00
Shimin Cui
0205667010
[LTO] Add function alias as function instead of data (#112599)
On AIX, for undefined functions, only the dotnamed symbols (the address
of the function) are generated after linking (i.e., no named function
symbol is generated).
 
Currently, all alias symbols are added as defined data symbols when
parsing symbols in LTOModule (the Link Time Optimization library used by
linker to optimization code at link time). On AIX, if the function alias
is used in the native object, and only its dotnamed symbol is generated,
the linker will have problem to match the dotnamed symbol from the
native object and the defined symbol marked as data from the bitcode at
LTO linktime.
 
This patch is to add function alias as function instead of data.
2024-10-17 12:10:05 -04:00
Lang Hames
7937fe1a17 [ORC][llvm-jitlink] Add support for forced loading of archive members.
This patch adds support for forced loading of archive members, similar to the
behavior of the -all_load and -ObjC options in ld64. To enable this, the
StaticLibraryDefinitionGenerator class constructors are extended with a
VisitMember callback that is called on each member file in the archive at
generator construction time. This callback can be used to unconditionally add
the member file to a JITDylib at that point.

To test this the llvm-jitlink utility is extended with -all_load (all platforms)
and -ObjC (darwin only) options. Since we can't refer to symbols in the test
objects directly (these would always cause the member to be linked in, even
without the new flags) we instead test side-effects of force loading: execution
of constructors and registration of Objective-C metadata.

rdar://134446111
2024-10-16 15:21:51 +11:00
Tyler Kenney
1b6a46ab8e
[ORC][COFF] Remove the ExecutionSession& argument to COFFPlatform factory & constructor (#112419)
We can get a reference to the `ExecutionSession` from the
`ObjectLinkingLayer` argument, so there's no need to pass it in
separately.

This mirrors recent changes to `ElfNixPlatform` and `MachOPlatform` by
@lhames in
3dba4ca155
and
cc20dd285a.
2024-10-16 10:57:58 +11:00
Sunho Kim
04af63b267 [ORC] Introduce IRPartitionLayer for common partition functionality. 2024-10-12 01:21:05 +09:00
Kazu Hirata
75774c1c36
[llvm-profdata] Default to MemProf version 3 (#108863)
It's very confusing to have support for Verion 3 but not default to
it.  This patch teaches llvm-profdata to use MemProf version 3 by
default.
2024-10-11 08:56:45 -07:00
Rahul Joshi
fa789dffb1
[NFC] Rename Intrinsic::getDeclaration to getOrInsertDeclaration (#111752)
Rename the function to reflect its correct behavior and to be consistent
with `Module::getOrInsertFunction`. This is also in preparation of
adding a new `Intrinsic::getDeclaration` that will have behavior similar
to `Module::getFunction` (i.e, just lookup, no creation).
2024-10-11 05:26:03 -07:00
Lang Hames
cc20dd285a [ORC][ELF] Remove the ExecutionSession& argument to ELFNixPlatform::Create.
We can get a reference to the ExecutionSession from the ObjectLinkingLayer
argument, so there's no need to pass it in separately.
2024-10-11 10:23:33 +11:00
Matt Arsenault
9839b8cfb4
llvm-reduce: Fix assert on invokes with catchswitch (#111838)
This is the minimal change to avoid the assert. There's an API flaw in
invoke instructions where getLandingPad assumes all invoke unwind
blocks have landingpads, when some have catchswitch instead.

Fixes #111817
2024-10-10 19:32:02 +04:00
Matt Arsenault
1731bb79a9
llvm-reduce: Fix not checking shouldKeep in special-globals reduction (#111647) 2024-10-09 19:13:06 +04:00
Kazu Hirata
55dd29c61d
[llvm-profdata] Avoid repeated hash lookups (NFC) (#111629) 2024-10-08 23:02:04 -07:00
Lang Hames
c6d6da4659 [ORC][MachO] Remove the ExecutionSession& argument to MachOPlatform::Create.
We can get a reference to the ExecutionSession from the ObjectLinkingLayer
argument, so there's no need to pass it in separately.
2024-10-09 08:46:44 +11:00
Kazu Hirata
1ad3180b4a
[llvm-remarkutil] Simplify code with std::map::operator[] (NFC) (#111407) 2024-10-07 21:46:41 -07:00
Paul Kirth
fabe7e39df
[llvm][gold] Fix syntax error (#111412)
This seems to have been overlooked in #109847, probably because most
bots don't build w/ gold enabled.
2024-10-07 10:56:52 -07:00
Nuri Amari
2edd897a42
Make WriteIndexesThinBackend multi threaded (#109847)
We've noticed that for large builds executing thin-link can take on the
order of 10s of minutes. We are only using a single thread to write the
sharded indices and import files for each input bitcode file. While we
need to ensure the index file produced lists modules in a deterministic
order, that doesn't prevent us from executing the rest of the work in
parallel.

In this change we use a thread pool to execute as much of the backend's
work as possible in parallel. In local testing on a machine with 80
cores, this change makes a thin-link for ~100,000 input files run in ~2
minutes. Without this change it takes upwards of 10 minutes.

---------

Co-authored-by: Nuri Amari <nuriamari@fb.com>
2024-10-07 08:16:46 -07:00
Peter Waller
e0b24d9475
[llvm-dis] Fix non-deterministic disassembly across multiple inputs (#110988)
Prior to this patch, the LLVMContext was shared across inputs to
llvm-dis.

Consequently, NamedStructTypes was shared across inputs, which impacts
StructType::setName - if a name was reused across inputs, it would get
renamed during construction of the struct type, leading to tricky to
diagnose confusion.
2024-10-07 11:23:30 +01:00
Stephen Tozer
d826b0c90f
[LLVM] Add HasFakeUses to MachineFunction (#110097)
Following the addition of the llvm.fake.use intrinsic and corresponding
MIR instruction, two further changes are planned: to add an
-fextend-lifetimes flag to Clang that emits these intrinsics, and to
have -Og enable this flag by default. Currently, some logic for handling
fake uses is gated by the optdebug attribute, which is intended to be
switched on by -fextend-lifetimes (and by extension -Og later on).
However, the decision was made that a general optdebug attribute should
be incompatible with other opt_ attributes (e.g. optsize, optnone),
since they all express different intents for how to optimize the
program. We would still like to allow -fextend-lifetimes with optsize
however (i.e. -Os -fextend-lifetimes should be legal), since it may be a
useful configuration and there is no technical reason to not allow it.

This patch resolves this by tracking MachineFunctions that have fake
uses, allowing us to run passes that interact with them and skip passes
that clash with them.
2024-10-04 13:13:30 +01:00
Kazu Hirata
9cd5e5c270 [llvm-debuginfod-find] Fix a warning
This patch fixes:

  llvm/tools/llvm-debuginfod-find/llvm-debuginfod-find.cpp:70:19:
  error: unused variable 'ToolName' [-Werror,-Wunused-variable]
2024-10-01 21:10:51 -07:00
Prabhuk
ab83d31bbd
[llvm-debuginfod-find] Fix help text regression (#110752)
While porting the tool from using cl:opt to OptTable, I had mistakenly
deleted the help text header that was originally part of the tool.
Bringing it back in this patch.
2024-10-01 18:57:39 -07:00
Cyndy Ishida
5134048066
[readtapi] Add option to ignore architecture slices to ignore (#110615)
For qualification purposes, it's helpful to ignore certain slices that
can be expected to differ.
2024-10-01 14:31:22 -07:00
Corentin Kerisit
01135de401
[llvm-profdata] Fix typo in usage (#110434)
From `profata` to `profdata`
2024-09-30 11:15:29 -04:00
Amr Hesham
3e0d31c97c
[llvm-dis][NFC] Avoid unnecessary copies while iterating (#109860)
Avoid unnecessary copies while iterating on input files
2024-09-26 16:39:59 +02:00
Fangrui Song
abe0dd195a
[llvm-objdump] Print ... even if a data mapping symbol is active
Swap `!DisassembleZeroes` and `if (DumpARMELFData)` conditions so that
in the false DisassembleZeroes case (default), `...` will be printed for
long consecutive zeroes, even when a data mapping symbol is active.

This is especially useful for certain lld tests that insert a huge
padding within a code section. Without `...` the output will be huge.

Pull Request: https://github.com/llvm/llvm-project/pull/109553
2024-09-25 10:32:40 -07:00
Abhina Sree
74dcf0b595
[SystemZ][z/OS] Open text files in text mode (#109972)
This patch continues the work that was started here
https://reviews.llvm.org/D99426 to correctly open text files in text
mode.
2024-09-25 10:49:45 -04:00
Kazu Hirata
a36aca5e18
[sancov] Avoid repeated map lookups (NFC) (#109906) 2024-09-25 01:32:31 -07:00
Kazu Hirata
74d9f7ce80
[llvm] Use std::optional::value_or (NFC) (#109890) 2024-09-24 21:49:06 -07:00
Kazu Hirata
4c3fccdd88
[llvm-ifs] Avoid repeated map lookups (NFC) (#109750) 2024-09-24 16:40:54 -07:00
Kazu Hirata
2f9c9ff789
[llvm-extract] Avoid repeated hash lookups (NFC) (#109749) 2024-09-24 16:40:16 -07:00
Kazu Hirata
9a99e55932
[gold-plugin] Avoid repeated hash lookups (NFC) (#109748) 2024-09-24 16:39:47 -07:00
Kazu Hirata
96eff99e64
[llvm-reduce] Avoid repeated hash lookups (NFC) (#109747) 2024-09-24 16:37:44 -07:00
Matt Arsenault
71ca9fcb8d
llvm-reduce: Don't print verifier failed machine functions (#109673)
This produces far too much terminal output, particularly for the
instruction reduction. Since it doesn't consider the liveness of of
the instructions it's deleting, it produces quite a lot of verifier
errors.
2024-09-24 22:32:53 +04:00
Zibi Sarbinowski
0de1e3e787
[;SystemZ][z/OS] Fix llvm-ctxprof to open input files in text mode (#109691)
Reading text files on z/OS relies on auto conversion to handle
ASCII/EBCDIC correctly. For this to work files need to be opened in text
mode is that is the type of the file. This PR fixes `llvm-ctxprof`
utility in this regards which in turn fixes the following LIT failure on
z/OS:

`FAIL: LLVM :: Analysis/CtxProfAnalysis/flatten-zero-path.ll`
2024-09-24 09:43:02 -04:00
Aiden Grossman
e093bb9e5a
Reland "[llvm-exegesis] Add support for pinning benchmarking process to a CPU (#85168)" (#109688)
This reverts commit 2cd20c255684257b86940bdda6861897f0bf3c00.

This relands commit 9886788a8a500a1b429a6db64397c849b112251c.

This was causing more buildbot failures due to getcpu not being
available with glibc <=2.29. This patch fixes that by directly making
the syscall, assuming the syscall number macro is available.
2024-09-23 11:32:19 -07:00
Aiden Grossman
8e8a0724c2
[llvm-debuginfod-find] Remove old parameter comment (#109637)
This patch removes a comment in llvm-debuginfod-find containing all the
cl::opt entries, which are redundant after the conversion to using
optTable. These seem to have been introduced in #108082 along with a
conversion to optTable.
2024-09-23 10:16:58 -07:00
Aiden Grossman
2cd20c2556 Revert "[llvm-exegesis] Add support for pinning benchmarking process to a CPU (#85168)"
This reverts commit 6fc2451167ec991361dd0568de9a9fa2926f8da8.

This broke some more buildbots.
2024-09-23 16:08:14 +00:00