[llvm] r300362 - [AMDGPU] set read_only access qualifier for pointers
Stanislav Mekhanoshin via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 14 12:11:40 PDT 2017
Author: rampitec
Date: Fri Apr 14 14:11:40 2017
New Revision: 300362
URL: http://llvm.org/viewvc/llvm-project?rev=300362&view=rev
Log:
[AMDGPU] set read_only access qualifier for pointers
If a kernel's pointer argument is known to be readonly
set access qualifier accordingly. This allows RT not to
flush caches before dispatches.
Differential Revision: https://reviews.llvm.org/D32091
Added:
llvm/trunk/test/CodeGen/AMDGPU/code-object-metadata-deduce-ro-arg.ll
Modified:
llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUCodeObjectMetadataStreamer.cpp
Modified: llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUCodeObjectMetadataStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUCodeObjectMetadataStreamer.cpp?rev=300362&r1=300361&r2=300362&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUCodeObjectMetadataStreamer.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUCodeObjectMetadataStreamer.cpp Fri Apr 14 14:11:40 2017
@@ -478,9 +478,14 @@ void MetadataStreamer::emitKernelArg(con
BaseTypeName = cast<MDString>(Node->getOperand(ArgNo))->getString();
StringRef AccQual;
- Node = Func->getMetadata("kernel_arg_access_qual");
- if (Node && ArgNo < Node->getNumOperands())
- AccQual = cast<MDString>(Node->getOperand(ArgNo))->getString();
+ 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();
+ }
StringRef Name;
Node = Func->getMetadata("kernel_arg_name");
Added: llvm/trunk/test/CodeGen/AMDGPU/code-object-metadata-deduce-ro-arg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/code-object-metadata-deduce-ro-arg.ll?rev=300362&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/code-object-metadata-deduce-ro-arg.ll (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/code-object-metadata-deduce-ro-arg.ll Fri Apr 14 14:11:40 2017
@@ -0,0 +1,33 @@
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -filetype=obj -o - < %s | llvm-readobj -amdgpu-code-object-metadata -elf-output-style=GNU -notes | FileCheck %s
+
+; CHECK: - Name: test_ro_arg
+; CHECK: Args:
+; CHECK-NEXT: - Size: 8
+; CHECK-NEXT: Align: 8
+; CHECK-NEXT: ValueKind: GlobalBuffer
+; CHECK-NEXT: ValueType: F32
+; CHECK-NEXT: AccQual: ReadOnly
+; CHECK-NEXT: AddrSpaceQual: Global
+; CHECK-NEXT: IsConst: true
+; CHECK-NEXT: IsRestrict: true
+; CHECK-NEXT: TypeName: 'float*'
+
+; CHECK-NEXT: - Size: 8
+; CHECK-NEXT: Align: 8
+; CHECK-NEXT: ValueKind: GlobalBuffer
+; CHECK-NEXT: ValueType: F32
+; CHECK-NEXT: AccQual: Default
+; CHECK-NEXT: AddrSpaceQual: Global
+; CHECK-NEXT: TypeName: 'float*'
+
+define amdgpu_kernel void @test_ro_arg(float addrspace(1)* noalias readonly %in, float addrspace(1)* %out)
+ !kernel_arg_addr_space !0 !kernel_arg_access_qual !1 !kernel_arg_type !2
+ !kernel_arg_base_type !2 !kernel_arg_type_qual !3 {
+ ret void
+}
+
+!0 = !{i32 1, i32 1}
+!1 = !{!"none", !"none"}
+!2 = !{!"float*", !"float*"}
+!3 = !{!"const restrict", !""}
+
More information about the llvm-commits
mailing list