[llvm] 6555c47 - [OpenMP][NVPTX] Handle additional invalid PTX characters
Chi Chun Chen via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 30 12:58:52 PDT 2023
Author: Jeffrey Sandoval
Date: 2023-06-30T14:58:37-05:00
New Revision: 6555c474483d8423e2a626814843e9f62efe6fd7
URL: https://github.com/llvm/llvm-project/commit/6555c474483d8423e2a626814843e9f62efe6fd7
DIFF: https://github.com/llvm/llvm-project/commit/6555c474483d8423e2a626814843e9f62efe6fd7.diff
LOG: [OpenMP][NVPTX] Handle additional invalid PTX characters
For OpenMP offload, Clang emits global symbols containing the string
'<captured>', which contains characters that are invalid in PTX.
Extend the existing pass that replaces '.' and '@' characters with
'_$_' to also replace '<' and '>' characters.
Reviewed By: cchen
Differential Revision: https://reviews.llvm.org/D154241
Added:
Modified:
llvm/lib/Target/NVPTX/NVPTXAssignValidGlobalNames.cpp
llvm/test/CodeGen/NVPTX/symbol-naming.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/NVPTX/NVPTXAssignValidGlobalNames.cpp b/llvm/lib/Target/NVPTX/NVPTXAssignValidGlobalNames.cpp
index 34b9dfe87cc28..7899957438612 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAssignValidGlobalNames.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAssignValidGlobalNames.cpp
@@ -73,7 +73,7 @@ std::string NVPTXAssignValidGlobalNames::cleanUpName(StringRef Name) {
std::string ValidName;
raw_string_ostream ValidNameStream(ValidName);
for (char C : Name) {
- if (C == '.' || C == '@') {
+ if (C == '.' || C == '@' || C == '<' || C == '>') {
ValidNameStream << "_$_";
} else {
ValidNameStream << C;
diff --git a/llvm/test/CodeGen/NVPTX/symbol-naming.ll b/llvm/test/CodeGen/NVPTX/symbol-naming.ll
index a719dd57c4b9c..ba85e1fc73743 100644
--- a/llvm/test/CodeGen/NVPTX/symbol-naming.ll
+++ b/llvm/test/CodeGen/NVPTX/symbol-naming.ll
@@ -7,9 +7,11 @@
; PTX.
; CHECK-NOT: .str
+; CHECK-NOT: <str>
; CHECK-NOT: .function.
; CHECK-DAG: _$_str
+; CHECK-DAG: _$_str_$_
; CHECK-DAG: _$_str1
; CHECK-DAG: _$_function_$_
@@ -20,6 +22,7 @@ target triple = "nvptx64-unknown-unknown"
@.str = private unnamed_addr constant [13 x i8] c"%d %f %c %d\0A\00", align 1
+@"<str>" = private unnamed_addr constant [13 x i8] c"%d %f %c %d\0A\00", align 1
@_$_str = private unnamed_addr constant [13 x i8] c"%d %f %c %d\0A\00", align 1
@@ -27,6 +30,7 @@ target triple = "nvptx64-unknown-unknown"
define internal void @.function.() {
entry:
%call = call i32 (ptr, ...) @printf(ptr @.str)
+ %call2 = call i32 (ptr, ...) @printf(ptr @"<str>")
ret void
}
@@ -34,6 +38,7 @@ entry:
define internal void @_$_function_$_() {
entry:
%call = call i32 (ptr, ...) @printf(ptr @_$_str)
+ %call2 = call i32 (ptr, ...) @printf(ptr @"<str>")
ret void
}
More information about the llvm-commits
mailing list