11331 Commits

Author SHA1 Message Date
Rahul Joshi
900ea21ffb
[NFC][CodingStandard] Add additional example for if-else brace rule (#111733)
Add example to document that single statement `else` needs a brace if
the associated `if` needs a brace.
2024-10-11 05:25:12 -07:00
Petar Avramovic
7b0d56be1d
AMDGPU/GlobalISel: Fix inst-selection of ballot (#109986)
Both input and output of ballot are lane-masks:
result is lane-mask with 'S32/S64 LLT and SGPR bank'
input is lane-mask with 'S1 LLT and VCC reg bank'.
Ballot copies bits from input lane-mask for
all active lanes and puts 0 for inactive lanes.
GlobalISel did not set 0 in result for inactive lanes
for non-constant input.
2024-10-11 11:40:27 +02:00
Serge Pavlov
15de239406
[IR] Allow MDString in operand bundles (#110805)
This change implements support of metadata strings in operand bundle
values. It makes possible calls like:

    call void @some_func(i32 %x) [ "foo"(i32 42, metadata !"abc") ]

It requires some extension of the bitcode serialization. As SSA values
and metadata are stored in different tables, there must be a way to
distinguish them during deserialization. It is implemented by putting a
special marker before the metadata index. The marker cannot be treated
as a reference to any SSA value, so it unambiguously identifies
metadata. It allows extending the bitcode serialization without breaking
compatibility.

Metadata as operand bundle values are intended to be used in
floating-point function calls. They would represent the same information
as now is passed by the constrained intrinsic arguments.
2024-10-11 12:09:10 +07:00
Tyler Nowicki
29e192a0bf
[Coroutines] Documentation for custom ABIs (#111781)
Update the llvm/docs/Coroutines.rst docs to include a full description
of Custom ABI objects. This documentation describes the how ABI objects
allow users (plugin libraries) to create custom ABI objects for their
needs.
2024-10-10 15:59:24 -04:00
Harrison Hao
36a0d442eb
[LLVM][DOCS] Add documentation for 'host' and 'Native' options in LLVM_TARGETS_TO_BUILD. (#111382)
From https://github.com/llvm/llvm-project/issues/111356
2024-10-10 20:45:40 +08:00
Nikolas Klauser
e2dc50c929 [docs] Update the libc++ documentation link
The link has changed a while ago, which means that the old link is now a
404. This fixes the link to point to the correct documentation.
2024-10-09 08:53:56 +02:00
Johan Engelen
9e954b2d6a
[docs] Fix llround typo in LangRef (#111426) 2024-10-08 20:30:52 +02:00
Stephen Tozer
84088d3a28
[DLCov 1/5] Add CMake option for enhanced debug line coverage tracking (#107278)
This is part of a series of patches that tries to improve DILocation bug
detection in Debugify. This first patch adds the necessary CMake flag to
LLVM and a variable defined by that flag to LLVM's config header, allowing
the next patch to track information without affecting normal builds.

This series of patches adds a "DebugLoc coverage tracking" feature, that
inserts conditionally-compiled tracking information into DebugLocs (and
by extension, to Instructions), which is used by Debugify to provide
more accurate and detailed coverage reports. When enabled, this features
tracks whether and why we have intentionally dropped a DebugLoc,
allowing Debugify to ignore false positives. An optional additional
feature allows also storing a stack trace of the point where a DebugLoc
was unintentionally dropped/not generated, which is used to make fixing
detected errors significantly easier. The goal of these features is to
provide useful tools for developers to fix existing DebugLoc errors and
allow reliable detection of regressions by either manual inspection or
an automated script.
2024-10-08 18:15:46 +01:00
Steven Perron
5af7ae501a
[SPIRV] Implement handle_fromBinding intrinsic. (#111052)
Implement the intrinsic `llvm.spv.handle.fromBinding`, which returns the
handle for a global resource. This involves creating a global variable
that matches the return-type, set, and binding in the call, and
returning the handle to that resource.

This commit implements the scalar version. It does not handle arrays of
resources yet. It also does not handle storage buffers yet. We do not
have the type for the storage buffers designed yet.

Part of #81036
2024-10-08 12:31:23 -04:00
bigb4ng
baa51ffd9c
[sanitizer] Document AddressSanitizer security considerations (#100937)
Follow-up to #92593.

Also makes #92611, https://github.com/google/sanitizers/issues/1130
obsolete.
2024-10-08 09:22:10 -07:00
Sam Elliott
f93f925d4f
[RISCV][MC] Support Assembling 48- and 64-bit Instructions (#110022)
This adds `.insn` support for assembling instructions of 48- and
64-bits (only when giving an explicit length). Disassembly already
knows to bunch up the instruction bits for these instructions.

This changes some error messages so they are a little clearer.

Co-authored-by: Sudharsan Veeravalli <quic_svs@quicinc.com>
2024-10-08 14:09:07 +01:00
David Spickett
6b4c4d78f0
[llvm][docs] Improve the formatting of the Common Problems section (#108522)
...and add shared libs as a suggestion.

* Mark options, option values and program names as plain text.
* Add a blank line between the option and the explanatory text
  so that it doesn't get printed on the same line.
  (this seems to be the original intent of the rst source anyway)
* Update the phrasing of a couple of the options.
* Add BUILD_SHARED_LIBS to suggestions.
2024-10-08 10:00:31 +01:00
Matt Arsenault
a8e1311a1c
[RFC] IR: Define noalias.addrspace metadata (#102461)
This is intended to solve a problem with lowering atomics in
OpenMP and C++ common to AMDGPU and NVPTX.

In OpenCL and CUDA, it is undefined behavior for an atomic instruction
to modify an object in thread private memory. In OpenMP, it is defined.
Correspondingly, the hardware does not handle this correctly. For
AMDGPU,
32-bit atomics work and 64-bit atomics are silently dropped. We
therefore
need to codegen this by inserting a runtime address space check,
performing
the private case without atomics, and fallback to issuing the real
atomic
otherwise. This metadata allows us to avoid this extra check and branch.

Handle this by introducing metadata intended to be applied to atomicrmw,
indicating they cannot access the forbidden address space.
2024-10-07 23:21:42 +04:00
AidinT
8df6637e84
[doc] Fix Kaleidoscope tutorial chapter 3 code snippet and full listing discrepancies (#111289)
Fix two discrepancies between the cited snippets and the full code.
2024-10-07 12:43:27 +02:00
Pierre van Houtryve
924a64a348
[AMDGPU] Only emit SCOPE_SYS global_wb (#110636)
global_wb with scopes lower than SCOPE_SYS is unnecessary for
correctness.

I was initially optimistic they would be very cheap no-ops but they can
actually be quite expensive so let's avoid them.
2024-10-07 07:35:31 +02:00
Austin Kerbow
c4d89203f3
[AMDGPU] Support preloading hidden kernel arguments (#98861)
Adds hidden kernel arguments to the function signature and marks them
inreg if they should be preloaded into user SGPRs. The normal kernarg
preloading logic then takes over with some additional checks for the
correct implicitarg_ptr alignment.

Special care is needed so that metadata for the hidden arguments is not
added twice when generating the code object.
2024-10-06 17:44:33 -07:00
bd1976bris
097379ac9b
[doc] Fix rendering for objcopy's --remove-symbol-prefix option text (#111131) 2024-10-04 14:04:24 +01:00
bd1976bris
fcdb178bb4
[doc] Add --verify-json to dwarfdump documentation (#110909)
This adds documentation for --verify-json, see:
https://github.com/llvm/llvm-project/pull/81762
2024-10-04 10:14:45 +01:00
bd1976bris
23c02a48f1
[doc] Add llvm --error-display to dwarfdump documentation (#110922)
This adds documentation for --error-display, see:
https://github.com/llvm/llvm-project/pull/79648
2024-10-04 10:14:08 +01:00
Rahul Joshi
876f661dbe
[LIT] Rename substitution %basename_s to %{s:basename} (#111062)
Also added `%{t:stem}` as an alias for `%basename_t` and modified unit
test to test these new substitutions.
2024-10-03 18:18:10 -07:00
Rahul Joshi
6f20c3099e
[LIT] Add support for %basename_s to get base name of source file (#110993)
Add support for `%basename_s` pattern in the RUN commands to get the
base name of the source file, and adopt it in a TableGen LIT test.
2024-10-03 12:29:11 -07:00
Steven Perron
5114758b1c
[SPIRV] Make access qualifier optional for spirv.Image type (#110852)
The SPIRV backend has a special type named `spirv.Image`. This type is
meant to correspond to the OpTypeImage instruction in SPIR-V, but there
is one difference. The access qualifier operand in OpTypeImage is
optional. On top of that, the access qualifiers are only valid for
kernels, and not for shaders.

We want to reuse this type when generating shader from HLSL, but we
can't use the access qualifier. This commit make the access qualifer
optional in the target extension type.

The same is done for `spirv.SampledImage`.

Contributes to #81036
2024-10-03 14:11:06 -04:00
Rahul Joshi
65e69f7436
[NFC][TableGen] Change Record::getSuperClasses to use const Record* (#110845)
Change `Record::getSuperClasses` to return a const pointer to the
superclass records.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-10-02 13:24:46 -07:00
Renato Golin
b468119247 [Docs] Clean leftover 2024-10-02 13:29:30 +01:00
Renato Golin
7cc4aa4a3b [Docs] Update office hours to not conflict with MLGO 2024-10-02 13:08:18 +01:00
Renato Golin
711a0a715d [Docs] Change office hours 2024-10-02 12:57:32 +01:00
Benjamin Maxwell
4f6ad17adc
Fix typo (NFC) (#110817) 2024-10-02 11:23:32 +01:00
Benjamin Maxwell
95f00a63ce
[IR] Allow fast math flags on calls with homogeneous FP struct types (#110506)
This extends FPMathOperator to allow calls that return literal structs
of homogeneous floating-point or vector-of-floating-point types.

The intended use case for this is to support FP intrinsics that return
multiple values (such as `llvm.sincos`).
2024-10-02 10:05:09 +01:00
Henrik G. Olsson
e495231238
Revert "[Utils] Add new --update-tests flag to llvm-lit" (#110772)
Reverts llvm/llvm-project#108425
2024-10-01 17:14:50 -07:00
Henrik G. Olsson
bb8b9ac0ba
[Utils] Add new --update-tests flag to llvm-lit (#108425)
This adds a flag to lit for detecting and updating failing tests when
possible to do so automatically. The flag uses a plugin architecture
where config files can add additional auto-updaters for the types of
tests in the test suite. When a test fails with `--update-tests` enabled
lit passes the test RUN invocation and output to each registered test
updater until one of them signals that it updated the test (or all test
updaters have been run). As such it is the responsibility of the test
updater to only update tests where it is reasonably certain that it will
actually fix the test, or come close to doing so.

Initially adds support for UpdateVerifyTests and UpdateTestChecks. The
flag is currently only implemented for lit's internal shell, so
`--update-tests` implies `LIT_USE_INTERNAL_SHELL=1`.

Builds on work in #97369
Fixes #81320
2024-10-01 15:57:10 -07:00
Vyacheslav Levytskyy
0e3476605f
[SPIR-V] Implement support of the SPV_EXT_arithmetic_fence SPIRV extension (#110500)
This PR implements support of the SPV_EXT_arithmetic_fence SPIRV
extension:
https://htmlpreview.github.io/?https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/EXT/SPV_EXT_arithmetic_fence.html.
2024-10-01 10:48:25 +02:00
Jakub Kuderski
5d45815473
[docs][amdgpu] Update kernarg documentation for gfx90a (#109690)
Update the docs to mention that kernel argument preloading is not
supported on MI210.
2024-09-30 13:51:41 -04:00
Janek van Oirschot
c897c13dde
[AMDGPU] Convert AMDGPUResourceUsageAnalysis pass from Module to MF pass (#102913)
Converts AMDGPUResourceUsageAnalysis pass from Module to MachineFunction
pass. Moves function resource info propagation to to MC layer (through
helpers in AMDGPUMCResourceInfo) by generating MCExprs for every
function resource which the emitters have been prepped for.

Fixes https://github.com/llvm/llvm-project/issues/64863
2024-09-30 11:43:34 +01:00
Alex MacLean
e7621f4199
Reland "[NVVM] Upgrade nvvm.ptr.* intrinics to addrspace cast" (#110262)
Remove the following intrinsics which can be trivially replaced with an
`addrspacecast`

  * llvm.nvvm.ptr.gen.to.global
  * llvm.nvvm.ptr.gen.to.shared
  * llvm.nvvm.ptr.gen.to.constant
  * llvm.nvvm.ptr.gen.to.local
  * llvm.nvvm.ptr.global.to.gen
  * llvm.nvvm.ptr.shared.to.gen
  * llvm.nvvm.ptr.constant.to.gen
  * llvm.nvvm.ptr.local.to.gen

Also, cleanup the NVPTX lowering of `addrspacecast` making it more
concise.

This was reverted to avoid conflicts while reverting #107655. Re-landing
unchanged.
2024-09-28 14:13:17 -07:00
William Huhn
5cc64bf60b
[Nomination] Update Intel representation in the security group (#109281)
I'd like to nominate Sergey Zverev as an Intel representative to replace
Andy Kaylor, who will be leaving the security group. Sergey is the one
of the main security points of contact for the Intel compiler team.
2024-09-27 12:45:17 +02:00
Oliver Stannard
8dd817b25a
[LangRef] Disallow accessing byval arguments from tail-called functions (#110093)
We already disallow accessing the callee's allocas from a tail-called
function, because their stack memory will have been de-allocated before
the tail call. I think this should apply to byval arguments too, as they
also occupy space in the caller's stack frame.

This was originally part of #109943, spilt out for separate review.
2024-09-27 09:08:05 +01:00
Tex Riddell
139688a699
[SPIRV] Add atan2 function lowering (p2) (#110037)
This change is part of this proposal:
https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294

- Add generic opcode for atan2
- Add SPIRV lowering for atan2

Part 2 for Implement the atan2 HLSL Function #70096.
2024-09-26 15:00:59 -07:00
David Spickett
b9f09a43b4
[llvm][docs] Convert LLVM release notes to Markdown (#109107)
* Markdown is the most common format on GitHub and most contributors are
more familiar with it than RST.
* This leads to mistakes in the RST syntax and/or folks just using
Markdown syntax and assuming it works.
* The release notes have a high number of edits and a high number of
views, we should optimise for making the common path easy. That is,
adding a bullet point and a link.
* Though GitHub can render RST and Markdown, its support for Markdown is
more complete (and neither handle the Sphinx directives well).
* We already have some Markdown docs in the llvm docs.

To keep the original formatting we do need some Sphinx directives still,
and those are provided by MyST which is already enabled.

https://myst-parser.readthedocs.io/en/latest/

I did have to enable an extension so we can substitute in the release
version.


https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#substitutions-with-jinja2

Needing to use MyST means there is some special knowledge needed if you
want to do advanced things, but at least the basics remain Markdown.
Even in RST form, you still had to look up Sphinx syntax.

I also make use of a nested directive

https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html#nesting-directives
to implement the prerelease warning.

The note about sections referred to another note that got removed in
4c72deb613d9d8838785b431facb3eb480fb2f51. I presume accidentally, so I
have restored that.

I also removed the "Update on required toolchains to build LLVM" header
because the section is now empty.

The other difference is that the table of contents now has a heading
"Contents". This is the default and I could not find a way to remove
that name. Otherwise it's the same table as you'd get from the RST
document.
2024-09-26 14:15:53 +01:00
Vyacheslav Levytskyy
a059b29930
[SPIR-V] Allow intrinsics with aggregate return type to reach GlobalISel (#108893)
Two main goals of this PR are:
* to support "Arithmetic with Overflow" intrinsics, including the
special case when those intrinsics are being generated by the
CodeGenPrepare pass during translations with optimization;
* to redirect intrinsics with aggregate return type to be lowered via
GlobalISel operations instead of SPIRV-specific unfolding/lowering (see
https://github.com/llvm/llvm-project/pull/95012).

There is a new test case
`llvm/test/CodeGen/SPIRV/passes/translate-aggregate-uaddo.ll` that
describes and checks the general logics of the translation.

This PR continues a series of PRs aimed to identify and fix flaws in
code emission, to improve pass rates for the mode with expensive checks
set on (see https://github.com/llvm/llvm-project/pull/101732,
https://github.com/llvm/llvm-project/pull/104104,
https://github.com/llvm/llvm-project/pull/106966), having in mind the
ultimate goal of proceeding towards the non-experimental status of
SPIR-V Backend.

The reproducers are:

1) consider `llc -O3 -mtriple=spirv64-unknown-unknown ...` with:

```
define spir_func i32 @foo(i32 %a, ptr addrspace(4) %p) {
entry:
  br label %l1

l1:
  %e = phi i32 [ %a, %entry ], [ %i, %body ]
  %i = add nsw i32 %e, 1
  %fl = icmp eq i32 %i, 0
  br i1 %fl, label %exit, label %body

body:
  store i8 42, ptr addrspace(4) %p
  br label %l1

exit:
  ret i32 %i
}
```

2) consider `llc -O0 -mtriple=spirv64-unknown-unknown ...` with:

```
define spir_func i32 @foo(i32 %a, ptr addrspace(4) %p) {
entry:
  br label %l1

l1:                                               ; preds = %body, %entry
  %e = phi i32 [ %a, %entry ], [ %math, %body ]
  %0 = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %e, i32 1)
  %math = extractvalue { i32, i1 } %0, 0
  %ov = extractvalue { i32, i1 } %0, 1
  br i1 %ov, label %exit, label %body

body:                                             ; preds = %l1
  store i8 42, ptr addrspace(4) %p, align 1
  br label %l1

exit:                                             ; preds = %l1
  ret i32 %math
}
```
2024-09-26 10:57:02 +02:00
Rahman Lavaee
7b7747dc1d
Reapply "Deprecate the -fbasic-block-sections=labels option." (#110039)
This reapplies commit 1911a50fae8a441b445eb835b98950710d28fc88 with a
minor fix in lld/ELF/LTO.cpp which sets Options.BBAddrMap when
`--lto-basic-block-sections=labels` is passed.
2024-09-25 22:03:10 -07:00
Kazu Hirata
639a0afa99 Revert "Deprecate the -fbasic-block-sections=labels option. (#107494)"
This reverts commit 1911a50fae8a441b445eb835b98950710d28fc88.

Several bots are failing:

https://lab.llvm.org/buildbot/#/builders/190/builds/6519
https://lab.llvm.org/buildbot/#/builders/3/builds/5248
https://lab.llvm.org/buildbot/#/builders/18/builds/4463
2024-09-25 12:34:43 -07:00
Rahman Lavaee
1911a50fae
Deprecate the -fbasic-block-sections=labels option. (#107494)
This feature is supported via the newer option
`-fbasic-block-address-map`. Using the old option still works by
delegating to the newer option, while a warning is printed to show
deprecation.
2024-09-25 12:03:38 -07:00
Dmitry Chernenkov
4cb61c20ef Revert "[NVPTX] deprecate nvvm.rotate.* intrinsics, cleanup funnel-shift handling (#107655)"
This reverts commit 9ac00b85e05d21be658d6aa0c91cbe05bb5dbde2.
2024-09-25 14:50:26 +00:00
Dmitry Chernenkov
9a0e281e8c Revert "[NVVM] Upgrade nvvm.ptr.* intrinics to addrspace cast (#109710)"
This reverts commit 36757613b73908f055674a8df0b51cc00aa04373.
2024-09-25 14:50:26 +00:00
David Spickett
b7ea2643ce [llvm][docs] Fix RISCVUsage docs build error
After changes in #109651.

Warning, treated as error:
/home/davspi01/work/open_source/llvm-project/llvm/docs/RISCVUsage.rst::Anonymous hyperlink mismatch: 1 references but 0 targets.

In typical RST fashion, all that was missing was a space between
the last word and the opening `<` of the link.
2024-09-25 10:21:45 +01:00
David Spickett
4d459136f5
[llvm][docs] Update the project and runtimes lists (#109788)
And add a note to explain which variable to prefer if the project can go
in both.

---------

Co-authored-by: Nikita Popov <github@npopov.com>
2024-09-25 10:16:58 +01:00
Alex Bradbury
614aeda93b
[RISCV] Mark Zacas as non-experimental (#109651)
The extension has been ratified for some time, but we kept it
experimental (see #99898) due to
<https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/444>. The
ABI issue has been resolved by #101023 so I believe there's no known
barrier to moving Zacas to non-experimental.
2024-09-25 06:14:43 +01:00
Tex Riddell
cfe1adc42a
Reland: [DirectX] Add atan2 intrinsic and expand for DXIL backend (p1) (#109878)
This change is part of this proposal:
https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294

This preliminary work adds the intrinsic to llvm and expands using atan
intrinsic for DXIL backend, since DXIL has no atan2 op.

Part 1 for Implement the atan2 HLSL Function #70096.

(reland #108865 reverted in #109842 due to doc build break)
2024-09-25 00:06:13 -04:00
Farzon Lotfi
6dfeea3f86
Revert "[DirectX] Add atan2 intrinsic and expand for DXIL backend (p1)" (#109842)
Reverts llvm/llvm-project#108865

Broke the Docs build
2024-09-24 14:11:14 -04:00
Tex Riddell
26029d77a5
[DirectX] Add atan2 intrinsic and expand for DXIL backend (p1) (#108865)
This change is part of this proposal:
https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294

This preliminary work adds the intrinsic to llvm and expands using atan
intrinsic for DXIL backend, since DXIL has no atan2 op.

Part 1 for Implement the atan2 HLSL Function #70096.
2024-09-24 13:42:26 -04:00