[NVPTX] noop when kernel pointers are already global

Summary:
Some front ends make kernel pointers global already. In that case,
handlePointerParams does nothing.

Test Plan: more tests in lower-kernel-ptr-arg.ll

Reviewers: grosser

Subscribers: jholewinski, llvm-commits

Differential Revision: http://reviews.llvm.org/D10779

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240849 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jingyue Wu 2015-06-26 22:35:43 +00:00
parent 8266df7f7f
commit a70d990f47
2 changed files with 16 additions and 1 deletions

View File

@ -132,6 +132,10 @@ void NVPTXLowerKernelArgs::handlePointerParam(Argument *Arg) {
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(),

View File

@ -16,5 +16,16 @@ define void @kernel(float* %input, float* %output) {
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}