From 14defde057533655f710fc09122774ef5defcadc Mon Sep 17 00:00:00 2001 From: Justin Holewinski Date: Mon, 26 Sep 2011 16:20:34 +0000 Subject: [PATCH] PTX: Fix some lingering issues with stack allocation llvm-svn: 140535 --- llvm/lib/Target/PTX/PTXAsmPrinter.cpp | 4 +++- llvm/test/CodeGen/PTX/stack-object.ll | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 llvm/test/CodeGen/PTX/stack-object.ll diff --git a/llvm/lib/Target/PTX/PTXAsmPrinter.cpp b/llvm/lib/Target/PTX/PTXAsmPrinter.cpp index d1b6653373ed..260ed231b1dc 100644 --- a/llvm/lib/Target/PTX/PTXAsmPrinter.cpp +++ b/llvm/lib/Target/PTX/PTXAsmPrinter.cpp @@ -297,7 +297,9 @@ void PTXAsmPrinter::EmitFunctionBodyStart() { for (unsigned i = 0, e = FrameInfo->getNumObjects(); i != e; ++i) { DEBUG(dbgs() << "Size of object: " << FrameInfo->getObjectSize(i) << "\n"); if (FrameInfo->getObjectSize(i) > 0) { - std::string def = "\t.local .b"; + std::string def = "\t.local .align "; + def += utostr(FrameInfo->getObjectAlignment(i)); + def += " .b"; def += utostr(FrameInfo->getObjectSize(i)*8); // Convert to bits def += " __local"; def += utostr(i); diff --git a/llvm/test/CodeGen/PTX/stack-object.ll b/llvm/test/CodeGen/PTX/stack-object.ll new file mode 100644 index 000000000000..07cc0ab6d2d4 --- /dev/null +++ b/llvm/test/CodeGen/PTX/stack-object.ll @@ -0,0 +1,10 @@ +; RUN: llc < %s -march=ptx32 -mattr=sm20 | FileCheck %s + +define ptx_device float @stack1(float %a) { + ; CHECK: .local .b32 __local0; + %a.2 = alloca float + ; CHECK: st.local.f32 [__local0], %f0 + store float %a, float* %a.2 + %a.3 = load float* %a.2 + ret float %a.3 +}