[PATCH] D16490: [CUDA] Die gracefully when trying to output an LLVM alias.
Justin Lebar via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 22 16:23:10 PST 2016
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: echristo, jhen, llvm-commits.
Herald added a subscriber: jholewinski.
Previously, we would just output "foo = bar" in the assembly, and then
ptxas would choke. Now we die before emitting any invalid code.
We could check for aliases much earlier, e.g. during doInitialization.
But I figure it's better to emit as much code as we can and only die at
the last minute.
http://reviews.llvm.org/D16490
Files:
lib/Target/NVPTX/NVPTXAsmPrinter.cpp
test/CodeGen/NVPTX/alias.ll
Index: test/CodeGen/NVPTX/alias.ll
===================================================================
--- /dev/null
+++ test/CodeGen/NVPTX/alias.ll
@@ -0,0 +1,7 @@
+; RUN: not llc < %s -march=nvptx -mcpu=sm_20 2>&1 | FileCheck %s
+
+; Check that llc dies gracefully when given an alias.
+
+define i32 @a() { ret i32 0 }
+; CHECK: ERROR: Module has aliases
+ at b = internal alias i32 (), i32 ()* @a
Index: lib/Target/NVPTX/NVPTXAsmPrinter.cpp
===================================================================
--- lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -945,8 +945,16 @@
while (!global_list.empty())
global_list.remove(global_list.begin());
- // call doFinalization
- bool ret = AsmPrinter::doFinalization(M);
+ // Aliases are emitted during AsmPrinter::doFinalization(), so bail before
+ // then if we have any.
+ bool ret = false;
+ if (M.alias_size()) {
+ report_fatal_error("Module has aliases, which NVPTX does not support.");
+ ret = true; // error
+ }
+
+ if (!ret)
+ ret = AsmPrinter::doFinalization(M);
// now we restore global variables
for (i = 0; i < n; i++)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16490.45765.patch
Type: text/x-patch
Size: 1147 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160123/3c29cf13/attachment-0001.bin>
More information about the llvm-commits
mailing list