[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169418 91177308-0d34-0410-b5e6-96231b3b80d8

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

index d785fd2a478b86fb0546adb95177a5dfa0e0acce..96d8a505aafa864e4adf0c33650a0fb9580063b6 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/test/CodeGen/NVPTX/tuple-literal.ll b/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
+}