From 2dc9d072e5a3fffa34963efc8a7dfc7656ea020b Mon Sep 17 00:00:00 2001 From: Justin Holewinski Date: Fri, 9 Nov 2012 23:50:24 +0000 Subject: [PATCH] [NVPTX] Use ABI alignment for parameters when alignment is not specified. Affects SM 2.0+. Fixes bug 13324. llvm-svn: 167646 --- llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp | 3 +++ llvm/test/CodeGen/NVPTX/param-align.ll | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 llvm/test/CodeGen/NVPTX/param-align.ll diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp index d3dfb35..348ef72 100644 --- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -1525,6 +1525,9 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, // = PAL.getparamalignment // size = typeallocsize of element type unsigned align = PAL.getParamAlignment(paramIndex+1); + if (align == 0) + align = TD->getABITypeAlignment(ETy); + unsigned sz = TD->getTypeAllocSize(ETy); O << "\t.param .align " << align << " .b8 "; diff --git a/llvm/test/CodeGen/NVPTX/param-align.ll b/llvm/test/CodeGen/NVPTX/param-align.ll new file mode 100644 index 0000000..84ccb65 --- /dev/null +++ b/llvm/test/CodeGen/NVPTX/param-align.ll @@ -0,0 +1,25 @@ +; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s + +;;; Need 4-byte alignment on float* passed byval +define ptx_device void @t1(float* byval %x) { +; CHECK: .func t1 +; CHECK: .param .align 4 .b8 t1_param_0[4] + ret void +} + + +;;; Need 8-byte alignment on double* passed byval +define ptx_device void @t2(double* byval %x) { +; CHECK: .func t2 +; CHECK: .param .align 8 .b8 t2_param_0[8] + ret void +} + + +;;; Need 4-byte alignment on float2* passed byval +%struct.float2 = type { float, float } +define ptx_device void @t3(%struct.float2* byval %x) { +; CHECK: .func t3 +; CHECK: .param .align 4 .b8 t3_param_0[8] + ret void +} -- 2.7.4