File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 1717// ===----------------------------------------------------------------------===//
1818
1919#include " NVPTX.h"
20+ #include " llvm/ADT/StringExtras.h"
2021#include " llvm/IR/Function.h"
2122#include " llvm/IR/GlobalVariable.h"
2223#include " llvm/IR/LegacyPassManager.h"
@@ -73,10 +74,12 @@ std::string NVPTXAssignValidGlobalNames::cleanUpName(StringRef Name) {
7374 std::string ValidName;
7475 raw_string_ostream ValidNameStream (ValidName);
7576 for (char C : Name) {
76- if (C == ' . ' || C == ' @ ' || C == ' < ' || C == ' > ' ) {
77- ValidNameStream << " _$_ " ;
78- } else {
77+ // While PTX also allows '%' at the start of identifiers, LLVM will throw a
78+ // fatal error for '%' in symbol names in MCSymbol::print. Exclude for now.
79+ if ( isAlnum (C) || C == ' _ ' || C == ' $ ' ) {
7980 ValidNameStream << C;
81+ } else {
82+ ValidNameStream << " _$_" ;
8083 }
8184 }
8285
Original file line number Diff line number Diff line change 88
99; CHECK-NOT: .str
1010; CHECK-NOT: <str>
11+ ; CHECK-NOT: another-str
1112; CHECK-NOT: .function.
1213
1314; CHECK-DAG: _$_str
1415; CHECK-DAG: _$_str_$_
1516; CHECK-DAG: _$_str1
17+ ; CHECK-DAG: another_$_str
1618
1719; CHECK-DAG: _$_function_$_
1820; CHECK-DAG: _$_function_$_2
@@ -24,6 +26,7 @@ target triple = "nvptx64-unknown-unknown"
2426@.str = private unnamed_addr constant [13 x i8 ] c "%d %f %c %d\0A\00 " , align 1
2527@"<str>" = private unnamed_addr constant [13 x i8 ] c "%d %f %c %d\0A\00 " , align 1
2628@_$_str = private unnamed_addr constant [13 x i8 ] c "%d %f %c %d\0A\00 " , align 1
29+ @another-str = private unnamed_addr constant [13 x i8 ] c "%d %f %c %d\0A\00 " , align 1
2730
2831
2932; Function Attrs: nounwind
3841define internal void @_$_function_$_ () {
3942entry:
4043 %call = call i32 (ptr , ...) @printf (ptr @_$_str )
41- %call2 = call i32 (ptr , ...) @printf (ptr @"< str>" )
44+ %call2 = call i32 (ptr , ...) @printf (ptr @another- str )
4245 ret void
4346}
4447
You can’t perform that action at this time.
0 commit comments