File tree 2 files changed +10
-4
lines changed 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 17
17
// ===----------------------------------------------------------------------===//
18
18
19
19
#include " NVPTX.h"
20
+ #include " llvm/ADT/StringExtras.h"
20
21
#include " llvm/IR/Function.h"
21
22
#include " llvm/IR/GlobalVariable.h"
22
23
#include " llvm/IR/LegacyPassManager.h"
@@ -73,10 +74,12 @@ std::string NVPTXAssignValidGlobalNames::cleanUpName(StringRef Name) {
73
74
std::string ValidName;
74
75
raw_string_ostream ValidNameStream (ValidName);
75
76
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 == ' $ ' ) {
79
80
ValidNameStream << C;
81
+ } else {
82
+ ValidNameStream << " _$_" ;
80
83
}
81
84
}
82
85
Original file line number Diff line number Diff line change 8
8
9
9
; CHECK-NOT: .str
10
10
; CHECK-NOT: <str>
11
+ ; CHECK-NOT: another-str
11
12
; CHECK-NOT: .function.
12
13
13
14
; CHECK-DAG: _$_str
14
15
; CHECK-DAG: _$_str_$_
15
16
; CHECK-DAG: _$_str1
17
+ ; CHECK-DAG: another_$_str
16
18
17
19
; CHECK-DAG: _$_function_$_
18
20
; CHECK-DAG: _$_function_$_2
@@ -24,6 +26,7 @@ target triple = "nvptx64-unknown-unknown"
24
26
@.str = private unnamed_addr constant [13 x i8 ] c "%d %f %c %d\0A\00 " , align 1
25
27
@"<str>" = private unnamed_addr constant [13 x i8 ] c "%d %f %c %d\0A\00 " , align 1
26
28
@_$_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
27
30
28
31
29
32
; Function Attrs: nounwind
38
41
define internal void @_$_function_$_ () {
39
42
entry:
40
43
%call = call i32 (ptr , ...) @printf (ptr @_$_str )
41
- %call2 = call i32 (ptr , ...) @printf (ptr @"< str>" )
44
+ %call2 = call i32 (ptr , ...) @printf (ptr @another- str )
42
45
ret void
43
46
}
44
47
You can’t perform that action at this time.
0 commit comments