File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -1526,6 +1526,15 @@ version (IN_LLVM)
1526
1526
dchar c = slice[i];
1527
1527
if (c < 0x80 )
1528
1528
{
1529
+ version (IN_LLVM)
1530
+ {
1531
+ // LDC: allow leading "\1" to prevent target-specific prefix
1532
+ if (i == 0 && c == ' \1 ' )
1533
+ {
1534
+ ++ i;
1535
+ continue ;
1536
+ }
1537
+ }
1529
1538
if (c.isValidMangling)
1530
1539
{
1531
1540
++ i;
Original file line number Diff line number Diff line change @@ -125,11 +125,15 @@ std::string getIRMangledName(VarDeclaration *vd) {
125
125
}
126
126
127
127
std::string getIRMangledFuncName (std::string baseMangle, LINK link) {
128
- return gABI ->mangleFunctionForLLVM (std::move (baseMangle), link);
128
+ return baseMangle[0 ] == ' \1 '
129
+ ? baseMangle
130
+ : gABI ->mangleFunctionForLLVM (std::move (baseMangle), link);
129
131
}
130
132
131
133
std::string getIRMangledVarName (std::string baseMangle, LINK link) {
132
- return gABI ->mangleVariableForLLVM (std::move (baseMangle), link);
134
+ return baseMangle[0 ] == ' \1 '
135
+ ? baseMangle
136
+ : gABI ->mangleVariableForLLVM (std::move (baseMangle), link);
133
137
}
134
138
135
139
std::string getIRMangledAggregateName (AggregateDeclaration *ad,
Original file line number Diff line number Diff line change
1
+ // Tests that 'raw mangles' starting with "\1" are correctly propagated to IR.
2
+
3
+ // RUN: %ldc -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
4
+
5
+ // CHECK: @"\01myGlobal" = global i32
6
+ pragma (mangle, " \1 myGlobal" )
7
+ __gshared int myGlobal;
8
+
9
+ // CHECK: define {{.*}} @"\01myFunction"()
10
+ pragma (mangle, " \1 myFunction" )
11
+ void myFunction () {}
You can’t perform that action at this time.
0 commit comments