Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ThinLTO][MC] Use conditional assignments for promotion aliases
Inline assembly refererences to static functions with ThinLTO+CFI were fixed in D104058 by creating aliases for promoted functions. Creating the aliases unconditionally resulted in an unexpected size increase in a Chrome helper binary: https://bugs.chromium.org/p/chromium/issues/detail?id=1261715 This is caused by the compiler being unable to drop unused code now referenced by the alias in module-level inline assembly. This change adds a .set_conditional assembly extension, which emits an assignment only if the target symbol is also emitted, avoiding phantom references to functions that could have otherwise been dropped. This is an alternative to the solution proposed in D112761. Reviewed By: pcc, nickdesaulniers, MaskRay Differential Revision: https://reviews.llvm.org/D113613
- Loading branch information
1 parent
b575405
commit 9a74c75
Showing
11 changed files
with
228 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu < %s | llvm-readobj --symbols - | FileCheck %s | ||
# RUN: not llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --defsym ERR=1 %s 2>&1 |\ | ||
# RUN: FileCheck %s --check-prefix=ERR | ||
|
||
.byte 0 | ||
|
||
.lto_set_conditional b, a | ||
.lto_set_conditional d, a | ||
.lto_set_conditional c, b | ||
.lto_set_conditional e, n | ||
|
||
# CHECK: Symbol { | ||
# CHECK: Name: a | ||
# CHECK-NEXT: Value: 0x1 | ||
a: | ||
.byte 0 | ||
|
||
# Verify that pending conditional symbols are emitted next | ||
|
||
# CHECK: Symbol { | ||
# CHECK-NEXT: Name: b | ||
# CHECK-NEXT: Value: 0x1 | ||
# CHECK: Symbol { | ||
# CHECK-NEXT: Name: c | ||
# CHECK-NEXT: Value: 0x1 | ||
# CHECK: Symbol { | ||
# CHECK-NEXT: Name: d | ||
# CHECK-NEXT: Value: 0x1 | ||
|
||
# CHECK-NOT: Name: e | ||
|
||
# Remaining conditional symbols are emitted immediately | ||
|
||
# CHECK: Symbol { | ||
# CHECK-NEXT: Name: f | ||
# CHECK-NEXT: Value: 0x1 | ||
.lto_set_conditional f, a | ||
|
||
# CHECK: Symbol { | ||
# CHECK-NEXT: Name: g | ||
# CHECK-NEXT: Value: 0x1 | ||
.lto_set_conditional g, b | ||
|
||
# CHECK-NOT: Name: h | ||
.lto_set_conditional h, m | ||
|
||
.ifdef ERR | ||
.text | ||
# ERR: {{.*}}.s:[[#@LINE+1]]:25: error: expected identifier | ||
.lto_set_conditional i, ERR | ||
.endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# RUN: llvm-mc -filetype=obj -triple i386-apple-darwin9 < %s | llvm-readobj --symbols - | FileCheck %s | ||
# RUN: not llvm-mc -filetype=obj -triple i386-apple-darwin9 --defsym ERR=1 %s 2>&1 |\ | ||
# RUN: FileCheck %s --check-prefix=ERR | ||
|
||
.byte 0 | ||
|
||
.lto_set_conditional b, a | ||
.lto_set_conditional d, a | ||
.lto_set_conditional c, b | ||
.lto_set_conditional e, n | ||
|
||
# CHECK: Symbol { | ||
# CHECK: Name: a | ||
# CHECK: Flags [ | ||
# CHECK-NEXT: NoDeadStrip | ||
# CHECK: Value: 0x1 | ||
a: | ||
.byte 0 | ||
.no_dead_strip a | ||
|
||
# Verify that pending conditional symbols are emitted next | ||
|
||
# CHECK: Symbol { | ||
# CHECK-NEXT: Name: b | ||
# CHECK: Flags [ | ||
# CHECK-NEXT: NoDeadStrip | ||
# CHECK: Value: 0x1 | ||
# CHECK: Symbol { | ||
# CHECK-NEXT: Name: c | ||
# CHECK: Flags [ | ||
# CHECK-NEXT: NoDeadStrip | ||
# CHECK: Value: 0x1 | ||
# CHECK: Symbol { | ||
# CHECK-NEXT: Name: d | ||
# CHECK: Flags [ | ||
# CHECK-NEXT: NoDeadStrip | ||
# CHECK: Value: 0x1 | ||
|
||
# CHECK-NOT: Name: e | ||
|
||
# Remaining conditional symbols are emitted immediately | ||
|
||
# CHECK: Symbol { | ||
# CHECK-NEXT: Name: f | ||
# CHECK: Flags [ | ||
# CHECK-NEXT: NoDeadStrip | ||
# CHECK: Value: 0x1 | ||
.lto_set_conditional f, a | ||
|
||
# CHECK: Symbol { | ||
# CHECK-NEXT: Name: g | ||
# CHECK: Flags [ | ||
# CHECK-NEXT: NoDeadStrip | ||
# CHECK: Value: 0x1 | ||
.lto_set_conditional g, b | ||
|
||
# CHECK: Symbol { | ||
# CHECK-NEXT: Name: m | ||
# CHECK: Flags [ | ||
# CHECK-NOT : NoDeadStrip | ||
# CHECK: Value: 0x2 | ||
m: | ||
|
||
# CHECK: Symbol { | ||
# CHECK-NEXT: Name: h | ||
# CHECK: Flags [ | ||
# CHECK-NOT : NoDeadStrip | ||
# CHECK: Value: 0x2 | ||
.lto_set_conditional h, m | ||
|
||
.ifdef ERR | ||
.text | ||
# ERR: {{.*}}.s:[[#@LINE+1]]:25: error: expected identifier | ||
.lto_set_conditional i, ERR | ||
.endif |
Oops, something went wrong.