[AMDGPU] Remove AMDGPUArgumentUsageInfo pass (#182490)
`AMDGPUArgumentUsageInfo` provided a per-function map that
`lowerFormalArguments` would write each function's implicit argument
register layout into, and `passSpecialInputs` would read back when
lowering calls to look up the callee's layout. This per-function map is
redundant for all non-entry callees, which already use the same
`FixedABIFunctionInfo` register layout.
GlobalISel already used `FixedABIFunctionInfo` unconditionally. This
change makes SelectionDAG do the same.
[libc] Update the GPU allocator to work under post-Volta ITS
Summary:
There were several gaps that caused the allocator not to work under
NVIDIA's independent thread scheduling model. The problems (I know of)
are fixed in this commit. Generally this required using correct masks,
synchronizing before a few dependent operations, and overhauling the
allocate function to stick with the existing mask instead of querying
it.
The general idiom here is that at the start we obtain a single mask and
opportunistically use it. Every use must specifically sync this subset.
I.e. query a single time and never change it.
This passes most tests, however I have encountered two issues.
1. A bug in `nvlink` failing to link symbols called in 'free'
2. A deadlock under heavy divergence caused by IPSCCP altering control
flow.
[2 lines not shown]
[OMPIRBuilder] Add support for explicit deallocation points
In this patch, some OMPIRBuilder codegen functions and callbacks are updated to
work with arrays of deallocation insertion points. The purpose of this is to
enable the replacement of `alloca`s with other types of allocations that
require explicit deallocations in a way that makes it possible for
`CodeExtractor` instances created during OMPIRBuilder finalization to also use
them.
The OpenMP to LLVM IR MLIR translation pass is updated to properly store and
forward deallocation points together with their matching allocation point to
the OMPIRBuilder.
Currently, only the `DeviceSharedMemCodeExtractor` uses this feature to get the
`CodeExtractor` to use device shared memory for intermediate allocations when
outlining a parallel region inside of a Generic kernel (code path that is only
used by Flang via MLIR, currently). However, long term this might also be
useful to refactor finalization of variables with destructors, potentially
reducing the use of callbacks and simplifying privatization and reductions.
[5 lines not shown]
Do not format .td files in Clang; NFC (#182075)
We have varying needs for these files. e.g., a diagnostic file is a
different kind of file than compiler options which is different than
attributes which is different than attribute documentation, etc. So
running clang-format over .td files in Clang is not going well in
practice because of how often it reformats things unlike the rest of the
file. This results in a poor new contributor experience because
pre-commit CI tells them the changes are not clang-format clean but we
don't want the changes to be clang-format clean and so a reviewer asks
them to revert and ignore pre-commit CI.
---------
Co-authored-by: Sirraide <aeternalmail at gmail.com>
[mlir][NFC] Remove unused deprecated API wrappers (#182715)
Remove deprecated functions and constructors that have zero callers in
the monorepo: `applyPatternsAndFoldGreedily`, `applyOpPatternsAndFold`,
`NamedAttrList(std::nullopt_t)`, and `OpPrintingFlags(std::nullopt_t)`.
These had FIXME comments requesting their removal.
FunctionAttrs: Do not infer top down on functions with no uses
Guards against introducing illegal nofpclass on functions that don't
have FP typed arguments or return values. This would only happen if
the call graph analysis had stale edges.
Fixes #182834
[LifetimeSafety] Reorganize diagnostic groups and remove confidence-based warnings (#179309)
Reorganized lifetime safety diagnostic groups to be more granular and
renamed diagnostic messages for better clarity.
- **Diagnostic Group Restructuring**: Split lifetime safety warnings
into more specific categories:
- `lifetime-safety-use-after-scope` and
`lifetime-safety-use-after-scope-moved` for scope-related issues
- `lifetime-safety-return-stack-addr` and
`lifetime-safety-return-stack-addr-moved` for return address issues
- `lifetime-safety-dangling-field` and
`lifetime-safety-dangling-field-moved` for field reference issues
- Added new umbrella groups `lifetime-safety-validations` and
`lifetime-safety-all`
- **Diagnostic Message Updates**: Renamed warning diagnostics from
generic "loan expires" terminology to more specific messages like "use
after scope" and "return stack addr"
- **Code Cleanup**: Removed `Confidence` logic (based on possible vs
[22 lines not shown]
[CodeGen] Workaround for compiler crash
This patch implements a workaround for a "Getting frame offset for a dead
object?" assertion triggered when compiling the target-generic-loops.f90
offloading test. A more concise reproducer for this issue:
```f90
! flang -O0 -fopenmp -fopenmp-version=52 --offload-arch=gfx1100 test.f90
program main
integer :: i, counter
!$omp target teams distribute
do i=1, 10
end do
counter = 0
!$omp target map(tofrom: counter)
!$omp parallel do reduction(+:counter)
do i=1, 10
[11 lines not shown]
[OpenMPOpt] Make parallel regions reachable from new DeviceRTL loop functions
This patch updates the OpenMP optimization pass to know about the new DeviceRTL
functions for loop constructs.
This change marks these functions as potentially containing parallel regions,
which fixes a current bug with the state machine rewrite optimization. It
previously failed to identify parallel regions located inside of the callbacks
passed to these new DeviceRTL functions, causing the resulting code to skip
executing these parallel regions.
As a result, Generic kernels produced by Flang that contain parallel regions
now work properly.
One known related issue not fixed by this patch is that the presence of calls
to these functions will prevent the SPMD-ization of Generic kernels by
OpenMPOpt. Previously, this was due to assuming there was no parallel region.
This is changed by this patch, but instead we now mark it temporarily as
unsupported in an SPMD context. The reason is that, without additional changes,
[3 lines not shown]
[OpenMP][OMPIRBuilder] Support parallel in Generic kernels
This patch introduces codegen logic to produce a wrapper function argument for
the `__kmpc_parallel_51` DeviceRTL function needed to handle arguments passed
using device shared memory in Generic mode.
[analyzer] New checker: optin.core.UnconditionalVAArg (#175602)
Add a new optin checker which reports variadic functions that
unconditionally use `va_arg()`. It would be undefined behavior to call
such functions without passing any variadic arguments, so the SEI-CERT
rule EXP47-C says that this pattern should be avoided.
As this part of this SEI-CERT rule focuses on a very narrow area, I
aimed to write a simple and stable checker that can report basic "clear"
occurrences of this fault. It would be possible to cover some additional
corner cases, but it isn't worth the effort.
[APINotes] Fix fatal error when using the Type key on fields (#180672)
This fixes a clang crash when importing a module with apinotes that sets
the Type key on a Field:
```
# .---command stderr------------
# | API notes allowed a type on an unknown declaration
# | UNREACHABLE executed at <path>/llvm-project/clang/lib/Sema/SemaAPINotes.cpp:419!
# | PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
# | Stack dump:
# | 0. <path>/llvm-project/clang/test/APINotes/Inputs/Headers/Fields.h:4:12: current parser token ';'
# | 1. <path>/llvm-project/clang/test/APINotes/Inputs/Headers/Fields.h:3:1: parsing struct/union/class body 'IntWrapper'
...
# | #8 0x0000000109540868 clang::Sema::ApplyAPINotesType(clang::Decl*, llvm::StringRef)
# | #9 0x000000010955c6ec applyAPINotesType(clang::Sema&, clang::Decl*, llvm::StringRef, (anonymous namespace)::VersionedInfoMetadata)
```
```yaml
Tags:
- Name: IntWrapper
[24 lines not shown]
Revert "CodeGen: Emit .prefalign directives based on the prefalign attribute."
This reverts commit 6767bfeec5ede8a878792e39aedff053c36854b2.
This breaks the tools/gold/X86/multiple-sections.ll test.