From: Jeffrey Sandoval Date: Fri, 30 Jun 2023 19:57:05 +0000 (-0500) Subject: [OpenMP][NVPTX] Handle additional invalid PTX characters X-Git-Tag: upstream/17.0.6~3214 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6555c474483d8423e2a626814843e9f62efe6fd7;p=platform%2Fupstream%2Fllvm.git [OpenMP][NVPTX] Handle additional invalid PTX characters For OpenMP offload, Clang emits global symbols containing the string '', 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 --- diff --git a/llvm/lib/Target/NVPTX/NVPTXAssignValidGlobalNames.cpp b/llvm/lib/Target/NVPTX/NVPTXAssignValidGlobalNames.cpp index 34b9dfe..7899957 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 a719dd5..ba85e1f 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: ; 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 +@"" = 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 @"") 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 @"") ret void }