[PATCH] D157451: [AMDGPU] Emit .actual_access metadata
Changpeng Fang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 10 12:18:58 PDT 2023
cfang updated this revision to Diff 549132.
cfang added a comment.
implement .actual_access metadata emission.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157451/new/
https://reviews.llvm.org/D157451
Files:
llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.h
llvm/test/CodeGen/AMDGPU/hsa-metadata-deduce-ro-arg.ll
Index: llvm/test/CodeGen/AMDGPU/hsa-metadata-deduce-ro-arg.ll
===================================================================
--- llvm/test/CodeGen/AMDGPU/hsa-metadata-deduce-ro-arg.ll
+++ llvm/test/CodeGen/AMDGPU/hsa-metadata-deduce-ro-arg.ll
@@ -1,7 +1,7 @@
; RUN: llc -mtriple=amdgcn-amd-amdhsa -filetype=obj -o - < %s | llvm-readelf --notes - | FileCheck %s
; CHECK: - .args:
-; CHECK-NEXT: - .access: read_only
+; CHECK-NEXT: - .actual_access: read_only
; CHECK-NEXT: .address_space: global
; CHECK-NEXT: .is_const: true
; CHECK-NEXT: .is_restrict: true
Index: llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.h
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.h
+++ llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.h
@@ -105,8 +105,8 @@
msgpack::ArrayDocNode Args,
MaybeAlign PointeeAlign = std::nullopt,
StringRef Name = "", StringRef TypeName = "",
- StringRef BaseTypeName = "", StringRef AccQual = "",
- StringRef TypeQual = "");
+ StringRef BaseTypeName = "", StringRef ActAccQual = "",
+ StringRef AccQual = "", StringRef TypeQual = "");
void emitHiddenKernelArgs(const MachineFunction &MF, unsigned &Offset,
msgpack::ArrayDocNode Args) override;
Index: llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
@@ -714,16 +714,17 @@
if (Node && ArgNo < Node->getNumOperands())
BaseTypeName = cast<MDString>(Node->getOperand(ArgNo))->getString();
- StringRef AccQual;
+ StringRef ActAccQual;
if (Arg.getType()->isPointerTy() && Arg.onlyReadsMemory() &&
Arg.hasNoAliasAttr()) {
- AccQual = "read_only";
- } else {
- Node = Func->getMetadata("kernel_arg_access_qual");
- if (Node && ArgNo < Node->getNumOperands())
- AccQual = cast<MDString>(Node->getOperand(ArgNo))->getString();
+ ActAccQual = "read_only";
}
+ StringRef AccQual;
+ Node = Func->getMetadata("kernel_arg_access_qual");
+ if (Node && ArgNo < Node->getNumOperands())
+ AccQual = cast<MDString>(Node->getOperand(ArgNo))->getString();
+
StringRef TypeQual;
Node = Func->getMetadata("kernel_arg_type_qual");
if (Node && ArgNo < Node->getNumOperands())
@@ -747,14 +748,15 @@
emitKernelArg(DL, ArgTy, ArgAlign,
getValueKind(ArgTy, TypeQual, BaseTypeName), Offset, Args,
- PointeeAlign, Name, TypeName, BaseTypeName, AccQual, TypeQual);
+ PointeeAlign, Name, TypeName, BaseTypeName, ActAccQual,
+ AccQual, TypeQual);
}
void MetadataStreamerMsgPackV3::emitKernelArg(
const DataLayout &DL, Type *Ty, Align Alignment, StringRef ValueKind,
unsigned &Offset, msgpack::ArrayDocNode Args, MaybeAlign PointeeAlign,
StringRef Name, StringRef TypeName, StringRef BaseTypeName,
- StringRef AccQual, StringRef TypeQual) {
+ StringRef ActAccQual, StringRef AccQual, StringRef TypeQual) {
auto Arg = Args.getDocument()->getMapNode();
if (!Name.empty())
@@ -780,7 +782,8 @@
if (auto AQ = getAccessQualifier(AccQual))
Arg[".access"] = Arg.getDocument()->getNode(*AQ, /*Copy=*/true);
- // TODO: Emit Arg[".actual_access"].
+ if (auto AAQ = getAccessQualifier(ActAccQual))
+ Arg[".actual_access"] = Arg.getDocument()->getNode(*AAQ, /*Copy=*/true);
SmallVector<StringRef, 1> SplitTypeQuals;
TypeQual.split(SplitTypeQuals, " ", -1, false);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157451.549132.patch
Type: text/x-patch
Size: 3774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230810/79ce26a1/attachment.bin>
More information about the llvm-commits
mailing list