diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-09-07 08:06:07 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-07 08:06:07 +0200 |
| commit | da61325bfab3f4292843791b10eeaabf2f835741 (patch) | |
| tree | da3db2e395551cbbe222d341b9d76e678de05ef4 /src/libsyntax_ext | |
| parent | 7dcac19446ca8fca2c74e3da0461d010043224a7 (diff) | |
| parent | eedf555d0c041caa0a9e7c8cd4394716e637feaf (diff) | |
| download | rust-da61325bfab3f4292843791b10eeaabf2f835741.tar.gz rust-da61325bfab3f4292843791b10eeaabf2f835741.zip | |
Rollup merge of #64149 - eddyb:llvm-var-names, r=rkruppe
rustc_codegen_llvm: give names to non-alloca variable values.
These names only matter when looking at LLVM IR, but they can help.
When one value is used for multiple variables, I decided to combine the names.
I chose `,` as a separator but maybe `=` or ` ` (space) are more appropriate.
(LLVM names can contain any characters - if necessary they end up having quotes)
As an example, this function:
```rust
#[no_mangle]
pub fn test(a: u32, b: u32) -> u32 {
let c = a + b;
let d = c;
let e = d * a;
e
}
```
Used to produce this LLVM IR:
```llvm
define i32 @test(i32 %a, i32 %b) unnamed_addr #0 {
start:
%0 = add i32 %a, %b
%1 = mul i32 %0, %a
ret i32 %1
}
```
But after this PR you get this:
```llvm
define i32 @test(i32 %a, i32 %b) unnamed_addr #0 {
start:
%"c,d" = add i32 %a, %b
%e = mul i32 %"c,d", %a
ret i32 %e
}
```
cc @nagisa @rkruppe
Diffstat (limited to 'src/libsyntax_ext')
0 files changed, 0 insertions, 0 deletions
