Skip to content

Commit e5ed768

Browse files
committed
[Mangler] Add "$" (dollar sign) to the list of legal encoding characters.
1 parent 49d592c commit e5ed768

File tree

5 files changed

+197
-46
lines changed

5 files changed

+197
-46
lines changed

lib/ABI/CBCTables.h

Lines changed: 171 additions & 30 deletions
Large diffs are not rendered by default.

lib/ABI/HuffTables.h

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
#include "llvm/ADT/APInt.h"
55
using APInt = llvm::APInt;
66
// This file is autogenerated. Do not modify this file.
7-
// Processing text files: /Users/nadav/swift_devel/repo/mangling/inputs/SZCompressed.sz
7+
// Processing text files: CBC_Compressed.txt
88
namespace Huffman {
99
// The charset that the fragment indices can use:
10-
unsigned CharsetLength = 63;
11-
unsigned LongestEncodingLength = 10;
12-
const char *Charset = "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
10+
unsigned CharsetLength = 64;
11+
unsigned LongestEncodingLength = 11;
12+
const char *Charset = "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$";
1313
char variable_decode(APInt &num) {
1414
uint64_t tailbits = *num.getRawData();
1515
if ((tailbits & 1) == 0) {
@@ -481,23 +481,31 @@ if ((tailbits & 1) == 1) {
481481
if ((tailbits & 1) == 0) {
482482
tailbits/=2;
483483
if ((tailbits & 1) == 0) {
484+
tailbits/=2;
485+
num = num.lshr(8);
486+
return 'j';
487+
}
488+
if ((tailbits & 1) == 1) {
484489
tailbits/=2;
485490
if ((tailbits & 1) == 0) {
486491
tailbits/=2;
487-
num = num.lshr(9);
488-
return 'Q';
492+
if ((tailbits & 1) == 0) {
493+
tailbits/=2;
494+
num = num.lshr(10);
495+
return '$';
496+
}
497+
if ((tailbits & 1) == 1) {
498+
tailbits/=2;
499+
num = num.lshr(10);
500+
return 'Q';
501+
}
489502
}
490503
if ((tailbits & 1) == 1) {
491504
tailbits/=2;
492505
num = num.lshr(9);
493506
return 'H';
494507
}
495508
}
496-
if ((tailbits & 1) == 1) {
497-
tailbits/=2;
498-
num = num.lshr(8);
499-
return 'j';
500-
}
501509
}
502510
if ((tailbits & 1) == 1) {
503511
tailbits/=2;
@@ -572,9 +580,10 @@ if (ch == 'g') {/*0101111*/ num = num.shl(1); num = num.shl(1); num = ++num; num
572580
if (ch == '7') {/*1101111*/ num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; return;}
573581
if (ch == 'C') {/*0011111*/ num = num.shl(1); num = num.shl(1); num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; return;}
574582
if (ch == 'z') {/*1011111*/ num = num.shl(1); num = ++num; num = num.shl(1); num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; return;}
575-
if (ch == 'Q') {/*000111111*/ num = num.shl(1); num = num.shl(1); num = num.shl(1); num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; return;}
576-
if (ch == 'H') {/*100111111*/ num = num.shl(1); num = ++num; num = num.shl(1); num = num.shl(1); num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; return;}
577-
if (ch == 'j') {/*10111111*/ num = num.shl(1); num = ++num; num = num.shl(1); num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; return;}
583+
if (ch == 'j') {/*00111111*/ num = num.shl(1); num = num.shl(1); num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; return;}
584+
if (ch == '$') {/*0010111111*/ num = num.shl(1); num = num.shl(1); num = num.shl(1); num = ++num; num = num.shl(1); num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; return;}
585+
if (ch == 'Q') {/*1010111111*/ num = num.shl(1); num = ++num; num = num.shl(1); num = num.shl(1); num = ++num; num = num.shl(1); num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; return;}
586+
if (ch == 'H') {/*110111111*/ num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; return;}
578587
if (ch == '0') {/*1111111*/ num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; num = num.shl(1); num = ++num; return;}
579588
assert(false);
580589
}

unittests/Basic/CompressionTests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const char* TestValues[] = {"AA", "r", "J", "Swift","A", "ArrayStringPrintable",
2525
"__TMPVs15ContiguousArray",
2626
"__TIF14StdlibUnittest13checkSequenceu0_Rxs14CollectionType_s12SequenceTypeWx9Generator7Element_zW_9GeneratorS3__rFTxq",
2727
"__TTSg5VSS13CharacterViewS_s14CollectionTypes_GVs17IndexingGeneratorS__GS1_S__s13GeneratorTypes_VS_5IndexS3_s16Forwar",
28+
"__TMANameWith$dollar$inIt",
2829
""};
2930

3031
// Test that the code book compression round trips.

utils/name-compression/CBCGen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def addLine(line):
4949
escape_char1 = 'J'
5050

5151
# notice that Y and J are missing because they are escape chars:
52-
charset = r"0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIKLMNOPQRSTUVWXZ"
52+
charset = r"0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIKLMNOPQRSTUVWXZ$"
5353
encoders = [c for c in charset] # alphabet without the escape chars.
5454
enc_len = len(encoders)
5555

utils/name-compression/HuffGen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def generate_encoder(self, stack):
8686
return sb
8787

8888
# Only accept these characters into the tree.
89-
charset = r"0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
89+
charset = r"0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$"
9090
charser_length = str(len(charset))
9191

9292
# Convert the characters and frequencies to a list of trees

0 commit comments

Comments
 (0)