Skip to content

Commit

Permalink
[CUDA] Die gracefully when trying to output an LLVM alias.
Browse files Browse the repository at this point in the history
Summary:
Previously, we would just output "foo = bar" in the assembly, and then
ptxas would choke.  Now we die before emitting any invalid code.

Reviewers: echristo

Subscribers: jholewinski, llvm-commits, jhen, tra

Differential Revision: http://reviews.llvm.org/D16490

llvm-svn: 258638
  • Loading branch information
Justin Lebar committed Jan 23, 2016
1 parent 2a161f9 commit 3a5f579
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,11 @@ bool NVPTXAsmPrinter::doInitialization(Module &M) {
const NVPTXTargetMachine &NTM = static_cast<const NVPTXTargetMachine &>(TM);
const NVPTXSubtarget STI(TT, CPU, FS, NTM);

if (M.alias_size()) {
report_fatal_error("Module has aliases, which NVPTX does not support.");
return true; // error
}

SmallString<128> Str1;
raw_svector_ostream OS1(Str1);

Expand Down
7 changes: 7 additions & 0 deletions llvm/test/CodeGen/NVPTX/alias.ll
Original file line number Diff line number Diff line change
@@ -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
@b = internal alias i32 (), i32 ()* @a

0 comments on commit 3a5f579

Please sign in to comment.