[PATCH] D22524: [NVPTX] deal with all aggregate return types.

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 19 11:56:19 PDT 2016


tra created this revision.
tra added reviewers: jlebar, jholewinski.
tra added a subscriber: llvm-commits.
Herald added a subscriber: jholewinski.

Fixes a crash in llvm_unreachable when a function has array return type.


https://reviews.llvm.org/D22524

Files:
  lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  test/CodeGen/NVPTX/arg-lowering.ll

Index: test/CodeGen/NVPTX/arg-lowering.ll
===================================================================
--- test/CodeGen/NVPTX/arg-lowering.ll
+++ test/CodeGen/NVPTX/arg-lowering.ll
@@ -11,3 +11,9 @@
 define <2 x float> @foo1({float, float, i64} %arg0) {
   ret <2 x float> <float 1.0, float 1.0>
 }
+
+; CHECK: .visible .func  (.param .align 4 .b8 func_retval0[16]) foo2(
+; CHECK:          .param .align 4 .b8 foo2_param_0[8]
+define [4 x float] @foo2({float, float} %arg0) {
+  ret [4 x float] [float 1.0, float 1.0, float 1.0, float 1.0]
+}
Index: lib/Target/NVPTX/NVPTXAsmPrinter.cpp
===================================================================
--- lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -368,13 +368,13 @@
     } else if (isa<PointerType>(Ty)) {
       O << ".param .b" << TLI->getPointerTy(DL).getSizeInBits()
         << " func_retval0";
-    } else if ((Ty->getTypeID() == Type::StructTyID) || isa<VectorType>(Ty)) {
+    } else if (Ty->isAggregateType() || Ty->isVectorTy()) {
       unsigned totalsz = DL.getTypeAllocSize(Ty);
-       unsigned retAlignment = 0;
-       if (!llvm::getAlign(*F, 0, retAlignment))
-         retAlignment = DL.getABITypeAlignment(Ty);
-       O << ".param .align " << retAlignment << " .b8 func_retval0[" << totalsz
-         << "]";
+      unsigned retAlignment = 0;
+      if (!llvm::getAlign(*F, 0, retAlignment))
+        retAlignment = DL.getABITypeAlignment(Ty);
+      O << ".param .align " << retAlignment << " .b8 func_retval0[" << totalsz
+        << "]";
     } else
       llvm_unreachable("Unknown return type");
   } else {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22524.64533.patch
Type: text/x-patch
Size: 1634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160719/9ae83584/attachment.bin>


More information about the llvm-commits mailing list