diff options
| author | Patrick Walton <pcwalton@fb.com> | 2021-09-10 12:00:22 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@fb.com> | 2021-09-10 12:07:03 -0700 |
| commit | 79bc53870f9fb2b25abffedaa3a4823b974fe69f (patch) | |
| tree | 511bbcd39741c1be22a2a2c2a37da0c63b1ca953 /compiler/rustc_span/src | |
| parent | 497ee321af3b8496eaccd7af7b437f18bab81abf (diff) | |
Introduce a fast path that avoids the `debug_tuple` abstraction when deriving
Debug for unit-like enum variants. The intent here is to allow LLVM to remove the switch entirely in favor of an indexed load from a table of constant strings, which is likely what the programmer would write in C. Unfortunately, LLVM currently doesn't perform this optimization due to a bug, but there is [a patch](https://reviews.llvm.org/D109565) that fixes this issue. I've verified that, with that patch applied on top of this commit, Debug for unit-like tuple variants becomes a load, reducing the O(n) code bloat to O(1). Note that inlining `DebugTuple::finish()` wasn't enough to allow LLVM to optimize the code properly; I had to avoid the abstraction entirely. Not using the abstraction is likely better for compile time anyway. Part of #88793.
Diffstat (limited to 'compiler/rustc_span/src')
| -rw-r--r-- | compiler/rustc_span/src/symbol.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 24023163cc3..e88f86a164a 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1418,6 +1418,7 @@ symbols! { wrapping_sub, wreg, write_bytes, + write_str, x87_reg, xer, xmm_reg, |
