[NVPTX] Fix crash with unnamed struct arguments
authorJustin Holewinski <jholewinski@nvidia.com>
Wed, 5 Dec 2012 20:50:28 +0000 (20:50 +0000)
committerJustin Holewinski <jholewinski@nvidia.com>
Wed, 5 Dec 2012 20:50:28 +0000 (20:50 +0000)
Patch by Eric Holk

llvm-svn: 169418

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
llvm/test/CodeGen/NVPTX/tuple-literal.ll [new file with mode: 0644]

index d785fd2..96d8a50 100644 (file)
@@ -957,7 +957,7 @@ bool llvm::isImageOrSamplerVal(const Value *arg, const Module *context) {
     return false;
 
   const StructType *STy = dyn_cast<StructType>(PTy->getElementType());
-  const std::string TypeName = STy ? STy->getName() : "";
+  const std::string TypeName = STy && !STy->isLiteral() ? STy->getName() : "";
 
   for (int i = 0, e = array_lengthof(specialTypes); i != e; ++i)
     if (TypeName == specialTypes[i])
diff --git a/llvm/test/CodeGen/NVPTX/tuple-literal.ll b/llvm/test/CodeGen/NVPTX/tuple-literal.ll
new file mode 100644 (file)
index 0000000..5c0cb2c
--- /dev/null
@@ -0,0 +1,5 @@
+; RUN: llc < %s -march=nvptx -mcpu=sm_13
+
+define ptx_device void @test_function({i8, i8}*) {
+  ret void
+}