[PATCH] D65468: [NVPTX] Fix PR41651

Michael Liao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 30 12:12:28 PDT 2019


hliao created this revision.
Herald added subscribers: llvm-commits, hiraditya, jholewinski.
Herald added a project: LLVM.

- Use the reliable way to retrive the IR module from callsite. As the indirect callsite doesn't have a called function, it would crash the compiler. Retrive the module from CS's call instruction instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65468

Files:
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/test/CodeGen/NVPTX/bug41651.ll


Index: llvm/test/CodeGen/NVPTX/bug41651.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/bug41651.ll
@@ -0,0 +1,13 @@
+; RUN: llc -filetype=asm -o - %s | FileCheck %s
+target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64"
+target triple = "nvptx64-nvidia-cuda"
+
+%func = type { i32 (i32, i32)** }
+
+; CHECK: foo
+; CHECK: call
+; CHECK: ret
+define void @foo() {
+  %call = call %func undef(i32 0, i32 1)
+  ret void
+}
Index: llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
===================================================================
--- llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
+++ llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
@@ -1291,8 +1291,9 @@
       O << ".param .b" << size << " _";
     } else if (isa<PointerType>(retTy)) {
       O << ".param .b" << PtrVT.getSizeInBits() << " _";
-    } else if (retTy->isAggregateType() || retTy->isVectorTy() || retTy->isIntegerTy(128)) {
-      auto &DL = CS.getCalledFunction()->getParent()->getDataLayout();
+    } else if (retTy->isAggregateType() || retTy->isVectorTy() ||
+               retTy->isIntegerTy(128)) {
+      auto &DL = CS.getParent()->getModule()->getDataLayout();
       O << ".param .align " << retAlignment << " .b8 _["
         << DL.getTypeAllocSize(retTy) << "]";
     } else {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65468.212407.patch
Type: text/x-patch
Size: 1334 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190730/e3ffad6b/attachment.bin>


More information about the llvm-commits mailing list