summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
AgeCommit message (Collapse)Author
2023-03-22[amdgpu][nfc] Extract more functions in LowerModuleLDS, mark more methods staticJon Chesterfield
2023-03-21[amdgpu][nfc] Comment and extract two functions in LowerModuleLDSJon Chesterfield
2023-03-12[amdgpu][nfc] Replace ad hoc LDS frame recalculation with absolute_symbol MDJon Chesterfield
Post ISel, LDS variables are absolute values. Representing them as such is simpler than the frame recalculation currently used to build assembler tables from their addresses. This is a precursor to lowering dynamic/external LDS accesses from non-kernel functions. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D144221
2023-03-03[ReplaceConstant] Extract code for expanding users of constant (NFC)Nikita Popov
AMDGPU implements some handy code for expanding all constexpr users of LDS globals. Extract the core logic into ReplaceConstant, so that it can be reused elsewhere.
2023-02-24[amdgpu] Change LDS lowering default to hybridJon Chesterfield
Postponed from D139433 until the bug fixed by D139874 could be resolved. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D141852
2023-01-06Revert D141134 "[NFC] Only expose getXXXSize functions in TypeSize"Guillaume Chatelet
The patch should be discussed further. This reverts commit dd56e1c92b0e6e6be249f2d2dd40894e0417223f.
2023-01-06[NFC] Only expose getXXXSize functions in TypeSizeGuillaume Chatelet
Currently 'TypeSize' exposes two functions that serve the same purpose: - getFixedSize / getFixedValue - getKnownMinSize / getKnownMinValue source : https://github.com/llvm/llvm-project/blob/bf82070ea465969e9ae86a31dfcbf94c2a7b4c4c/llvm/include/llvm/Support/TypeSize.h#L337-L338 This patch offers to remove one of the two and stick to a single function in the code base. Differential Revision: https://reviews.llvm.org/D141134
2023-01-03AMDGPU: Diagnose which LDS global failed to lowerMatt Arsenault
Also lowercase the message to start since that seems to be the prevailing convention for error messages.
2022-12-14Don't include StringSwitch (NFC)Kazu Hirata
These files do not use llvm::StringSwitch.
2022-12-14llvm-reduce: Fix invalid reductions with llvm.usedMatt Arsenault
Fixes issue 59413.
2022-12-07[amdgpu] Reimplement LDS loweringJon Chesterfield
Renames the current lowering scheme to "module" and introduces two new ones, "kernel" and "table", plus a "hybrid" that chooses between those three on a per-variable basis. Unit tests are set up to pass with the default lowering of "module" or "hybrid" with this patch defaulting to "module", which will be a less dramatic codegen change relative to the current. This reflects the sparsity of test coverage for the table lowering method. Hybrid is better than module in every respect and will be default in a subsequent patch. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D139433
2022-12-06Revert "[amdgpu] Reimplement LDS lowering"Nico Weber
This reverts commit 982017240d7f25a8a6969b8b73dc51f9ac5b93ed. Breaks check-llvm, see https://reviews.llvm.org/D139433#3974862
2022-12-06[amdgpu] Reimplement LDS loweringJon Chesterfield
Renames the current lowering scheme to "module" and introduces two new ones, "kernel" and "table", plus a "hybrid" that chooses between those three on a per-variable basis. Unit tests are set up to pass with the default lowering of "module" or "hybrid" with this patch defaulting to "module", which will be a less dramatic codegen change relative to the current. This reflects the sparsity of test coverage for the table lowering method. Hybrid is better than module in every respect and will be default in a subsequent patch. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D139433
2022-11-09Revert "[amdgpu][lds] Use the same isKernel predicate consistently"Jon Chesterfield
Looks like this composed poorly with a nominally independent patch, will fix This reverts commit 0ba0398517778514eb44cb7ba9bf9d4d20a856e0.
2022-11-09[amdgpu][lds] Use the same isKernel predicate consistentlyJon Chesterfield
isKernelCC != isKernel(F->getCallingConv()) There's a test case (lower-kernel-lds.ll) that explicitly skips amdgpu_ps so this change picks the isKernel predicate that continues to skip that calling convention. isKernel returns true for AMDGPU_KERNEL and SPIR_KERNEL. isKernelCC also returns true for other calling conventions. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D136599
2022-11-09[amdgpu][lds] Use a consistent order of fields in generated structsJon Chesterfield
Avoids spurious and confusing test failures on changing implementation. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D136598
2022-09-28[amdgpu] Error, instead of miscompile, anonymous kernels using ldsJon Chesterfield
The association between kernel and struct is done by symbol name. This doesn't work robustly for anonymous kernels as shown by the modified test case. An alternative association between function and struct can be constructed if necessary, probably though metadata, but on the basis that we currently miscompile anonymous kernels and that they are difficult to construct from application code and difficult to call from the runtime, this patch makes it a fatal error for now. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D134741
2022-09-14[amdgpu] Expand all ConstantExpr users of LDS variables in instructionsJon Chesterfield
Bug noted in D112717 can be sidestepped with this change. Expanding all ConstantExpr involved with LDS up front makes the variable specialisation simpler. Excludes ConstantExpr that don't access LDS to avoid disturbing codegen elsewhere. Reviewed By: rampitec Differential Revision: https://reviews.llvm.org/D133422
2022-09-07[amdgpu] Always, instead of mostly, remove unused LDS symbolsJon Chesterfield
Currently LDS variables are removed by the lower module pass if they have a use which is caught by the replace with struct control flow. This makes tests brittle to changes to that control flow which induces noise when trying to improve lowering. Some tests already check that variables are removed, while others checked that they are not removed. LDS variables are not (currently) externally accessible, and if that changes the machinery which makes them externally accessible will look like a use. This change therefore breaks no applications. Reviewed By: rampitec Differential Revision: https://reviews.llvm.org/D133028
2022-09-03[llvm] Use range-based for loops (NFC)Kazu Hirata
2022-08-31[amdgpu][nfc] Factor predicate out of findLDSVariablesToLowerJon Chesterfield
2022-07-27[amdgpu][nfc] Fix build with a certan Clang versionDmitri Gribenko
It errors out in the Bazel CI: AMDGPULowerModuleLDSPass.cpp:384:12: error: chosen constructor is explicit in copy-initialization return {SGV, std::move(Map)}; Reviewed By: rupprecht Differential Revision: https://reviews.llvm.org/D130623
2022-07-27[amdgpu][nfc] Separate processUsedLDS into independent pieces, rename itJon Chesterfield
2022-07-27[amdgpu][nfc] Extract kernel annotation from processUsedLDSJon Chesterfield
2022-07-26[amdgpu][nfc] Separate LDS struct creation from RAUWJon Chesterfield
2022-07-26[amdgpu][nfc] Skip operations on padding fields in LDS structJon Chesterfield
2022-07-19[nfc][amdgpu] LDS. Move selection logic up the stack.Jon Chesterfield
2022-07-15[nfc][amdgpu] Remove dead variable and functionJon Chesterfield
2022-05-04[amdgpu] Elide module lds allocation in kernels with no calleesJon Chesterfield
Introduces a string attribute, amdgpu-requires-module-lds, to allow eliding the module.lds block from kernels. Will allocate the block as before if the attribute is missing or has its default value of true. Patch uses the new attribute to detect the simplest possible instance of this, where a kernel makes no calls and thus cannot call any functions that use LDS. Tests updated to match, coverage was already good. Interesting cases is in lower-module-lds-offsets where annotating the kernel allows the backend to pick a different (in this case better) variable ordering than previously. A later patch will avoid moving kernel variables into module.lds when the kernel can have this attribute, allowing optimal ordering and locally unused variable elimination. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D122091
2022-02-18[AMDGPU][NFC] Fix typosSebastian Neubauer
Fix some typos in the amdgpu backend. Differential Revision: https://reviews.llvm.org/D119235
2022-02-11[AMDGPU] Merge AMDGPULDSUtils into AMDGPUMemoryUtilsStanislav Mekhanoshin
Differential Revision: https://reviews.llvm.org/D119502
2021-12-12[amdgpu] Increase alignment of all LDS variablesJon Chesterfield
Currently the superalign option only increases the alignment of variables that are moved into the module.lds block. Change that to all LDS variables. Also only increase the alignment once, instead of once per function. Reviewed By: rampitec Differential Revision: https://reviews.llvm.org/D115488
2021-12-11[llvm] Use range-based for loops (NFC)Kazu Hirata
2021-12-11Revert "[amdgpu][nfc] Delete dead code in LowerModuleLDS"Jon Chesterfield
This reverts commit 7b9ab06d10a6a989f76e6c5ecf89d906f838fe7d. Said code is better removed as part of a larger change.
2021-12-10[amdgpu][nfc] Delete dead code in LowerModuleLDSJon Chesterfield
2021-12-09[amdgpu][nfc] Drop dead PtrSet, fix a commentJon Chesterfield
2021-12-08[amdgpu][nfc] Move non-shared code out of LDSUtilsJon Chesterfield
2021-09-21[AMDGPU] Correctly merge alias.scope and noalias metadata for memopsBrendon Cahoon
When adding alias.scope and noalias metadata to a memcpy function, the alias.scope and noalias metadata from the operands are merged. The rule for merging alias.scope is to take the intersection of the domains and the union of the scopes within those domains. The rule for merging noalias is to take the intersection. The bug is that AMDGPULowerModuleLDS was using concatenation for both alias.scope and noalias. For example, when f1 and f2 are added to the LDS structure and there is a memcpy(f2, f1, sizeof(f1)). Then, concatenation creates noalias metadata for the memcpy that includes both {f1, f2}. That means that the memcpy is assumed not to alias a prior load of f2, which enables the optimizer to remove a load of f2 that occurs after mempcy. The function MDNode::getmostGenericAliasScope defines the semantics for alias.scope. There is a function, combineMetadata in Local.cpp, that uses intersect for noalias. Differential Revision: https://reviews.llvm.org/D110049
2021-09-20[AMDGPU][NFC] Correct typos in lib/Target/AMDGPU/AMDGPU*.cpp files. Test ↵Jacob Lambert
commit for new contributor.
2021-08-26AMDGPU: Fix crashing on kernel declarations when lowering LDSMatt Arsenault
This was trying to insert the used marker into a declaration.
2021-08-19[AMDGPU] Add alias.scope metadata to lowered LDS structStanislav Mekhanoshin
Alias analysis is unable to disambiguate accesses to the structure fields without it unlike distinct variables. As a result we cannot combine ds_read and ds_write operations in a case of any store in between which always considered clobbering. Differential Revision: https://reviews.llvm.org/D108315
2021-07-20[AMDGPU] Disable LDS lowering for GFX shadersStanislav Mekhanoshin
Apparently these need external LDS symbols to remain. Fixes: SC1-3279 Differential Revision: https://reviews.llvm.org/D106288
2021-06-23[AMDGPU] Check for pointer operand while refining LDS alignStanislav Mekhanoshin
Also skips the propagation if alignment is 1. Differential Revision: https://reviews.llvm.org/D104796
2021-06-23[AMDGPU] Propagate LDS align into to instructionsStanislav Mekhanoshin
Differential Revision: https://reviews.llvm.org/D104316
2021-06-22[AMDGPU] Use performOptimizedStructLayout for LDS sortStanislav Mekhanoshin
This gives better packing. Differential Revision: https://reviews.llvm.org/D104331
2021-06-21[AMDGPU] Replace non-kernel function uses of LDS globals by pointers.hsmahesha
The main motivation behind pointer replacement of LDS use within non-kernel functions is - to *avoid* subsequent LDS lowering pass from directly packing LDS (assume large LDS) into a struct type which would otherwise cause allocating huge memory for struct instance within every kernel. Reviewed By: rampitec Differential Revision: https://reviews.llvm.org/D103225
2021-06-10[AMDGPU] Fix missing lowering of LDS used in global scope.hsmahesha
Reviewed By: rampitec Differential Revision: https://reviews.llvm.org/D103431
2021-06-07[AMDGPU] Handle constant LDS uses from different kernelsStanislav Mekhanoshin
This allows to lower an LDS variable into a kernel structure even if there is a constant expression used from different kernels. Differential Revision: https://reviews.llvm.org/D103655
2021-06-08[AMDGPU] Introduce command line switch to control super aligning of LDS.hsmahesha
Reviewed By: rampitec Differential Revision: https://reviews.llvm.org/D103817
2021-06-07[AMDGPU] Increase alignment of LDS globals if necessary before LDS lowering.hsmahesha
Before packing LDS globals into a sorted structure, make sure that their alignment is properly updated based on their size. This will make sure that the members of sorted structure are properly aligned, and hence it will further reduce the probability of unaligned LDS access. Reviewed By: rampitec Differential Revision: https://reviews.llvm.org/D103261