Commit e922c236 by Jim Stichnoth

Subzero: Shorten and normalize strings in non-DUMP builds.

Jump table labels change from ".Lxxxxx_yy" to "$Jxxxxx_yy". Pooled float labels change from ".L$float$xxxxyyyy" to "$Fxxxxyyyy". Pooled double labels change from ".L$double$xxxxxxxxyyyyyyyy" to "$Dxxxxxxxxyyyyyyyy". All these should in theory not conflict with C/C++ user symbols. Float labels now likely fit into short strings and don't require extra memory allocation. Double labels may exceed the limit - encoding in base64 instead of hex would fix that. Or, directly use the binary bytes as the string value. BUG= none R=jpp@chromium.org Review URL: https://codereview.chromium.org/1868113002 .
parent 9a23e431
...@@ -579,7 +579,7 @@ GlobalString makeName(Cfg *Func, const SizeT Id) { ...@@ -579,7 +579,7 @@ GlobalString makeName(Cfg *Func, const SizeT Id) {
return GlobalString::createWithString( return GlobalString::createWithString(
Ctx, ".L" + FuncName.toString() + "$jumptable$__" + std::to_string(Id)); Ctx, ".L" + FuncName.toString() + "$jumptable$__" + std::to_string(Id));
return GlobalString::createWithString( return GlobalString::createWithString(
Ctx, ".L" + std::to_string(FuncName.getID()) + "_" + std::to_string(Id)); Ctx, "$J" + std::to_string(FuncName.getID()) + "_" + std::to_string(Id));
} }
} // end of anonymous namespace } // end of anonymous namespace
......
...@@ -209,7 +209,23 @@ private: ...@@ -209,7 +209,23 @@ private:
void initName(GlobalContext *Ctx) { void initName(GlobalContext *Ctx) {
std::string Buffer; std::string Buffer;
llvm::raw_string_ostream Str(Buffer); llvm::raw_string_ostream Str(Buffer);
constexpr bool IsCompact = !BuildDefs::dump();
if (IsCompact) {
switch (getType()) {
case IceType_f32:
Str << "$F";
break;
case IceType_f64:
Str << "$D";
break;
default:
// For constant pooling diversification
Str << ".L$" << getType() << "$"; Str << ".L$" << getType() << "$";
break;
}
} else {
Str << ".L$" << getType() << "$";
}
// Print hex characters byte by byte, starting from the most significant // Print hex characters byte by byte, starting from the most significant
// byte. NOTE: This ordering assumes Subzero runs on a little-endian // byte. NOTE: This ordering assumes Subzero runs on a little-endian
// platform. That means the possibility of different label names depending // platform. That means the possibility of different label names depending
...@@ -223,7 +239,7 @@ private: ...@@ -223,7 +239,7 @@ private:
// For a floating-point value in DecorateAsm mode, also append the value in // For a floating-point value in DecorateAsm mode, also append the value in
// human-readable sprintf form, changing '+' to 'p' and '-' to 'm' to // human-readable sprintf form, changing '+' to 'p' and '-' to 'm' to
// maintain valid asm labels. // maintain valid asm labels.
if (std::is_floating_point<PrimType>::value && !BuildDefs::minimal() && if (BuildDefs::dump() && std::is_floating_point<PrimType>::value &&
getFlags().getDecorateAsm()) { getFlags().getDecorateAsm()) {
char Buf[30]; char Buf[30];
snprintf(Buf, llvm::array_lengthof(Buf), "$%g", (double)Value); snprintf(Buf, llvm::array_lengthof(Buf), "$%g", (double)Value);
......
...@@ -49,8 +49,8 @@ entry: ...@@ -49,8 +49,8 @@ entry:
ret i64 %v0 ret i64 %v0
} }
; CHECK-LABEL: cast_d2ll_const ; CHECK-LABEL: cast_d2ll_const
; CHECK: mov e{{..}},{{(DWORD PTR )?}}ds:0x0 {{.*}} .L$double$0012345678901234 ; CHECK: mov e{{..}},{{(DWORD PTR )?}}ds:0x0 {{.*}} {{.*}}0012345678901234
; CHECK: mov e{{..}},{{(DWORD PTR )?}}ds:0x4 {{.*}} .L$double$0012345678901234 ; CHECK: mov e{{..}},{{(DWORD PTR )?}}ds:0x4 {{.*}} {{.*}}0012345678901234
; ARM32-LABEL: cast_d2ll_const ; ARM32-LABEL: cast_d2ll_const
; ARM32-DAG: movw [[ADDR:r[0-9]+]], #:lower16:.L$ ; ARM32-DAG: movw [[ADDR:r[0-9]+]], #:lower16:.L$
; ARM32-DAG: movt [[ADDR]], #:upper16:.L$ ; ARM32-DAG: movt [[ADDR]], #:upper16:.L$
......
...@@ -57,8 +57,8 @@ entry: ...@@ -57,8 +57,8 @@ entry:
ret float %f ret float %f
} }
; TEXT-RELOCS-LABEL: returnFloatConst ; TEXT-RELOCS-LABEL: returnFloatConst
; TEXT-RELOCS: movss {{.*}} R_386_32 .L$float$80000000 ; TEXT-RELOCS: movss {{.*}} R_386_32 {{.*}}80000000
; TEXT-RELOCS: addss {{.*}} R_386_32 .L$float$3f9d70a0 ; TEXT-RELOCS: addss {{.*}} R_386_32 {{.*}}3f9d70a0
define internal double @returnDoubleConst() { define internal double @returnDoubleConst() {
entry: entry:
...@@ -67,9 +67,9 @@ entry: ...@@ -67,9 +67,9 @@ entry:
ret double %d2 ret double %d2
} }
; TEXT-RELOCS-LABEL: returnDoubleConst ; TEXT-RELOCS-LABEL: returnDoubleConst
; TEXT-RELOCS: movsd {{.*}} R_386_32 .L$double$ffffffffffffffff ; TEXT-RELOCS: movsd {{.*}} R_386_32 {{.*}}ffffffffffffffff
; TEXT-RELOCS: addsd {{.*}} R_386_32 .L$double$fff7ffffffffffff ; TEXT-RELOCS: addsd {{.*}} R_386_32 {{.*}}fff7ffffffffffff
; TEXT-RELOCS: addsd {{.*}} R_386_32 .L$double$fff8000000000003 ; TEXT-RELOCS: addsd {{.*}} R_386_32 {{.*}}fff8000000000003
; Test intrinsics that call out to external functions. ; Test intrinsics that call out to external functions.
define internal void @test_memcpy(i32 %iptr_dst, i32 %len) { define internal void @test_memcpy(i32 %iptr_dst, i32 %len) {
...@@ -385,11 +385,11 @@ define void @_start(i32) { ...@@ -385,11 +385,11 @@ define void @_start(i32) {
; CHECK: Relocations [ ; CHECK: Relocations [
; CHECK: Section ({{[0-9]+}}) .rel.text { ; CHECK: Section ({{[0-9]+}}) .rel.text {
; CHECK: 0x7 R_386_32 .L$float$80000000 0x0 ; CHECK: 0x7 R_386_32 {{.*}}80000000 0x0
; CHECK: 0xF R_386_32 .L$float$3f9d70a0 0x0 ; CHECK: 0xF R_386_32 {{.*}}3f9d70a0 0x0
; CHECK: 0x27 R_386_32 .L$double$ffffffffffffffff 0x0 ; CHECK: 0x27 R_386_32 {{.*}}ffffffffffffffff 0x0
; CHECK: 0x2F R_386_32 .L$double$fff7ffffffffffff 0x0 ; CHECK: 0x2F R_386_32 {{.*}}fff7ffffffffffff 0x0
; CHECK: 0x37 R_386_32 .L$double$fff8000000000003 0x0 ; CHECK: 0x37 R_386_32 {{.*}}fff8000000000003 0x0
; CHECK: 0x{{.*}} R_386_PC32 memcpy ; CHECK: 0x{{.*}} R_386_PC32 memcpy
; CHECK: 0x{{.*}} R_386_PC32 memset ; CHECK: 0x{{.*}} R_386_PC32 memset
; CHECK: 0x{{.*}} R_386_PC32 external_foo ; CHECK: 0x{{.*}} R_386_PC32 external_foo
...@@ -421,7 +421,7 @@ define void @_start(i32) { ...@@ -421,7 +421,7 @@ define void @_start(i32) {
; CHECK-NEXT: Section: Undefined (0x0) ; CHECK-NEXT: Section: Undefined (0x0)
; CHECK-NEXT: } ; CHECK-NEXT: }
; CHECK: Symbol { ; CHECK: Symbol {
; CHECK: Name: .L$double$fff8000000000003 ; CHECK: Name: {{.*}}fff8000000000003
; CHECK-NEXT: Value: 0x8 ; CHECK-NEXT: Value: 0x8
; CHECK-NEXT: Size: 0 ; CHECK-NEXT: Size: 0
; CHECK-NEXT: Binding: Local (0x0) ; CHECK-NEXT: Binding: Local (0x0)
...@@ -430,7 +430,7 @@ define void @_start(i32) { ...@@ -430,7 +430,7 @@ define void @_start(i32) {
; CHECK-NEXT: Section: .rodata.cst8 ; CHECK-NEXT: Section: .rodata.cst8
; CHECK-NEXT: } ; CHECK-NEXT: }
; CHECK: Symbol { ; CHECK: Symbol {
; CHECK: Name: .L$double$ffffffffffffffff ; CHECK: Name: {{.*}}ffffffffffffffff
; CHECK-NEXT: Value: 0x10 ; CHECK-NEXT: Value: 0x10
; CHECK-NEXT: Size: 0 ; CHECK-NEXT: Size: 0
; CHECK-NEXT: Binding: Local (0x0) ; CHECK-NEXT: Binding: Local (0x0)
...@@ -439,7 +439,7 @@ define void @_start(i32) { ...@@ -439,7 +439,7 @@ define void @_start(i32) {
; CHECK-NEXT: Section: .rodata.cst8 ; CHECK-NEXT: Section: .rodata.cst8
; CHECK-NEXT: } ; CHECK-NEXT: }
; CHECK: Symbol { ; CHECK: Symbol {
; CHECK: Name: .L$float$3f9d70a0 ; CHECK: Name: {{.*}}3f9d70a0
; CHECK-NEXT: Value: 0x0 ; CHECK-NEXT: Value: 0x0
; CHECK-NEXT: Size: 0 ; CHECK-NEXT: Size: 0
; CHECK-NEXT: Binding: Local (0x0) ; CHECK-NEXT: Binding: Local (0x0)
...@@ -448,7 +448,7 @@ define void @_start(i32) { ...@@ -448,7 +448,7 @@ define void @_start(i32) {
; CHECK-NEXT: Section: .rodata.cst4 ; CHECK-NEXT: Section: .rodata.cst4
; CHECK-NEXT: } ; CHECK-NEXT: }
; CHECK: Symbol { ; CHECK: Symbol {
; CHECK: Name: .L$float$80000000 ; CHECK: Name: {{.*}}80000000
; CHECK-NEXT: Value: 0x4 ; CHECK-NEXT: Value: 0x4
; CHECK-NEXT: Size: 0 ; CHECK-NEXT: Size: 0
; CHECK-NEXT: Binding: Local (0x0) ; CHECK-NEXT: Binding: Local (0x0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment