[PATCH] [NVPTX] noop when kernel pointers are already global
Jingyue Wu
jingyue at google.com
Fri Jun 26 15:36:06 PDT 2015
REPOSITORY
rL LLVM
http://reviews.llvm.org/D10779
Files:
llvm/trunk/lib/Target/NVPTX/NVPTXLowerKernelArgs.cpp
llvm/trunk/test/CodeGen/NVPTX/lower-kernel-ptr-arg.ll
Index: llvm/trunk/lib/Target/NVPTX/NVPTXLowerKernelArgs.cpp
===================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXLowerKernelArgs.cpp
+++ llvm/trunk/lib/Target/NVPTX/NVPTXLowerKernelArgs.cpp
@@ -132,6 +132,10 @@
assert(!Arg->hasByValAttr() &&
"byval params should be handled by handleByValParam");
+ // Do nothing if the argument already points to the global address space.
+ if (Arg->getType()->getPointerAddressSpace() == ADDRESS_SPACE_GLOBAL)
+ return;
+
Instruction *FirstInst = Arg->getParent()->getEntryBlock().begin();
Instruction *ArgInGlobal = new AddrSpaceCastInst(
Arg, PointerType::get(Arg->getType()->getPointerElementType(),
Index: llvm/trunk/test/CodeGen/NVPTX/lower-kernel-ptr-arg.ll
===================================================================
--- llvm/trunk/test/CodeGen/NVPTX/lower-kernel-ptr-arg.ll
+++ llvm/trunk/test/CodeGen/NVPTX/lower-kernel-ptr-arg.ll
@@ -16,5 +16,16 @@
ret void
}
-!nvvm.annotations = !{!0}
+define void @kernel2(float addrspace(1)* %input, float addrspace(1)* %output) {
+; CHECK-LABEL: .visible .entry kernel2(
+; CHECK-NOT: cvta.to.global.u64
+ %1 = load float, float addrspace(1)* %input, align 4
+; CHECK: ld.global.f32
+ store float %1, float addrspace(1)* %output, align 4
+; CHECK: st.global.f32
+ ret void
+}
+
+!nvvm.annotations = !{!0, !1}
!0 = !{void (float*, float*)* @kernel, !"kernel", i32 1}
+!1 = !{void (float addrspace(1)*, float addrspace(1)*)* @kernel2, !"kernel", i32 1}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10779.28605.patch
Type: text/x-patch
Size: 1537 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150626/34b5e4f6/attachment.bin>
More information about the llvm-commits
mailing list