[llvm] 6a51997 - [NVPTX] Fix lack of `.noreturn` on certain functions for aliases

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 24 05:01:15 PDT 2023


Author: Joseph Huber
Date: 2023-07-24T07:01:05-05:00
New Revision: 6a51997ccc23f7b9e2b0e154f0829cd05b11358a

URL: https://github.com/llvm/llvm-project/commit/6a51997ccc23f7b9e2b0e154f0829cd05b11358a
DIFF: https://github.com/llvm/llvm-project/commit/6a51997ccc23f7b9e2b0e154f0829cd05b11358a.diff

LOG: [NVPTX] Fix lack of `.noreturn` on certain functions for aliases

Forgot to include this special handling on the declaration of the alias
function.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D156012

Added: 
    

Modified: 
    llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
    llvm/test/CodeGen/NVPTX/alias.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index e9239faf56f856..71b70766bf9e13 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -873,6 +873,8 @@ void NVPTXAsmPrinter::emitGlobalAlias(const Module &M, const GlobalAlias &GA) {
   printReturnValStr(F, OS);
   OS << Name->getName();
   emitFunctionParamList(F, OS);
+  if (shouldEmitPTXNoReturn(F, TM))
+    OS << "\n.noreturn";
   OS << ";\n";
 
   OS << ".alias " << Name->getName() << ", " << F->getName() << ";\n";

diff  --git a/llvm/test/CodeGen/NVPTX/alias.ll b/llvm/test/CodeGen/NVPTX/alias.ll
index 3c23133763fc1e..d5dc3a12029ae6 100644
--- a/llvm/test/CodeGen/NVPTX/alias.ll
+++ b/llvm/test/CodeGen/NVPTX/alias.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -march=nvptx64 -mcpu=sm_30 -mattr=+ptx63 | FileCheck %s
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_30 -mattr=+ptx64 | FileCheck %s
 
 define i32 @a() { ret i32 0 }
 @b = internal alias i32 (), ptr @a
@@ -7,6 +7,13 @@ define i32 @a() { ret i32 0 }
 define void @foo(i32 %0, ptr %1) { ret void }
 @bar = alias i32 (), ptr @foo
 
+define void @noreturn() #0 {
+  ret void
+}
+ at noreturn_alias = alias i32 (), ptr @noreturn
+
+attributes #0 = { noreturn }
+
 ; CHECK: .visible .func  (.param .b32 func_retval0) a()
 
 ;      CHECK: .visible .func foo(
@@ -14,6 +21,9 @@ define void @foo(i32 %0, ptr %1) { ret void }
 ; CHECK-NEXT:         .param .b64 foo_param_1
 ; CHECK-NEXT: )
 
+;      CHECK: .visible .func noreturn()
+; CHECK-NEXT: .noreturn
+
 ;      CHECK: .visible .func  (.param .b32 func_retval0) b();
 ; CHECK-NEXT: .alias b, a;
 
@@ -25,3 +35,7 @@ define void @foo(i32 %0, ptr %1) { ret void }
 ; CHECK-NEXT:         .param .b64 foo_param_1
 ; CHECK-NEXT: );
 ; CHECK-NEXT: .alias bar, foo;
+
+;      CHECK: .visible .func noreturn_alias()
+; CHECK-NEXT: .noreturn;
+; CHECK-NEXT: .alias noreturn_alias, noreturn;


        


More information about the llvm-commits mailing list