Commit 7735556
authored
Name LLVM function arguments (JuliaLang#50500)
This makes it easier to correlate LLVM IR with the originating source
code by including both argument name and argument type in the LLVM
argument variable.
<details>
<summary>Example 1</summary>
```julia
julia> function f(a, b, c, d, g...)
e = a + b + c + d
f = does_not_exist(e) + e
f
end
f (generic function with 1 method)
julia> @code_llvm f(0,0,0,0,0)
```
```llvm
; @ REPL[1]:1 within `f`
define nonnull {}* @julia_f_141(i64 signext %"a::Int64", i64 signext %"b::Int64", i64 signext %"c::Int64", i64 signext %"d::Int64", i64 signext %"g[0]::Int64") #0 {
top:
%0 = alloca [2 x {}*], align 8
%gcframe3 = alloca [4 x {}*], align 16
%gcframe3.sub = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe3, i64 0, i64 0
%1 = bitcast [4 x {}*]* %gcframe3 to i8*
call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 0, i64 32, i1 true)
%thread_ptr = call i8* asm "movq %fs:0, $0", "=r"() #7
%tls_ppgcstack = getelementptr i8, i8* %thread_ptr, i64 -8
%2 = bitcast i8* %tls_ppgcstack to {}****
%tls_pgcstack = load {}***, {}**** %2, align 8
; @ REPL[1]:3 within `f`
%3 = bitcast [4 x {}*]* %gcframe3 to i64*
store i64 8, i64* %3, align 16
%4 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe3, i64 0, i64 1
%5 = bitcast {}** %4 to {}***
%6 = load {}**, {}*** %tls_pgcstack, align 8
store {}** %6, {}*** %5, align 8
%7 = bitcast {}*** %tls_pgcstack to {}***
store {}** %gcframe3.sub, {}*** %7, align 8
%Main.does_not_exist.cached = load atomic {}*, {}** @0 unordered, align 8
%iscached.not = icmp eq {}* %Main.does_not_exist.cached, null
br i1 %iscached.not, label %notfound, label %found
notfound: ; preds = %top
%Main.does_not_exist.found = call {}* @ijl_get_binding_or_error({}* nonnull inttoptr (i64 139831437630272 to {}*), {}* nonnull inttoptr (i64 139831600565400 to {}*))
store atomic {}* %Main.does_not_exist.found, {}** @0 release, align 8
br label %found
found: ; preds = %notfound, %top
%Main.does_not_exist = phi {}* [ %Main.does_not_exist.cached, %top ], [ %Main.does_not_exist.found, %notfound ]
%8 = bitcast {}* %Main.does_not_exist to {}**
%does_not_exist.checked = load atomic {}*, {}** %8 unordered, align 8
%.not = icmp eq {}* %does_not_exist.checked, null
br i1 %.not, label %err, label %ok
err: ; preds = %found
call void @ijl_undefined_var_error({}* inttoptr (i64 139831600565400 to {}*))
unreachable
ok: ; preds = %found
%.sub = getelementptr inbounds [2 x {}*], [2 x {}*]* %0, i64 0, i64 0
; @ REPL[1]:2 within `f`
; ┌ @ operators.jl:587 within `+` @ int.jl:87
%9 = add i64 %"b::Int64", %"a::Int64"
%10 = add i64 %9, %"c::Int64"
; │ @ operators.jl:587 within `+`
; │┌ @ operators.jl:544 within `afoldl`
; ││┌ @ int.jl:87 within `+`
%11 = add i64 %10, %"d::Int64"
%12 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe3, i64 0, i64 3
store {}* %does_not_exist.checked, {}** %12, align 8
; └└└
; @ REPL[1]:3 within `f`
%13 = call nonnull {}* @ijl_box_int64(i64 signext %11)
%14 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe3, i64 0, i64 2
store {}* %13, {}** %14, align 16
store {}* %13, {}** %.sub, align 8
%15 = call nonnull {}* @ijl_apply_generic({}* nonnull %does_not_exist.checked, {}** nonnull %.sub, i32 1)
store {}* %15, {}** %12, align 8
%16 = call nonnull {}* @ijl_box_int64(i64 signext %11)
store {}* %16, {}** %14, align 16
store {}* %15, {}** %.sub, align 8
%17 = getelementptr inbounds [2 x {}*], [2 x {}*]* %0, i64 0, i64 1
store {}* %16, {}** %17, align 8
%18 = call nonnull {}* @ijl_apply_generic({}* inttoptr (i64 139831370516384 to {}*), {}** nonnull %.sub, i32 2)
%19 = load {}*, {}** %4, align 8
%20 = bitcast {}*** %tls_pgcstack to {}**
store {}* %19, {}** %20, align 8
; @ REPL[1]:4 within `f`
ret {}* %18
}
```
</details>
<details>
<summary>Example 2</summary>
```julia
julia> function g(a, b, c, d; kwarg=0)
a + b + c + d + kwarg
end
g (generic function with 1 method)
julia> @code_llvm g(0,0,0,0,kwarg=0)
```
```llvm
; @ REPL[3]:1 within `g`
define i64 @julia_g_160([1 x i64]* nocapture noundef nonnull readonly align 8 dereferenceable(8) %"#1::NamedTuple", i64 signext %"a::Int64", i64 signext %"b::Int64", i64 signext %"c::Int64", i64 signext %"d::Int64") #0 {
top:
%0 = getelementptr inbounds [1 x i64], [1 x i64]* %"#1::NamedTuple", i64 0, i64 0
; ┌ @ REPL[3]:2 within `#g#1`
; │┌ @ operators.jl:587 within `+` @ int.jl:87
%1 = add i64 %"b::Int64", %"a::Int64"
%2 = add i64 %1, %"c::Int64"
; ││ @ operators.jl:587 within `+`
; ││┌ @ operators.jl:544 within `afoldl`
; │││┌ @ int.jl:87 within `+`
%3 = add i64 %2, %"d::Int64"
; │││└
; │││ @ operators.jl:545 within `afoldl`
; │││┌ @ int.jl:87 within `+`
%unbox = load i64, i64* %0, align 8
%4 = add i64 %3, %unbox
; └└└└
ret i64 %4
}
```
</details>File tree
4 files changed
+92
-25
lines changed- src
- test
- compiler
- llvmpasses
4 files changed
+92
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2093 | 2093 | | |
2094 | 2094 | | |
2095 | 2095 | | |
2096 | | - | |
| 2096 | + | |
2097 | 2097 | | |
2098 | 2098 | | |
2099 | | - | |
| 2099 | + | |
2100 | 2100 | | |
2101 | 2101 | | |
2102 | 2102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1736 | 1736 | | |
1737 | 1737 | | |
1738 | 1738 | | |
1739 | | - | |
| 1739 | + | |
1740 | 1740 | | |
1741 | 1741 | | |
1742 | 1742 | | |
| |||
2363 | 2363 | | |
2364 | 2364 | | |
2365 | 2365 | | |
2366 | | - | |
2367 | | - | |
2368 | | - | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
2369 | 2369 | | |
2370 | 2370 | | |
2371 | 2371 | | |
2372 | 2372 | | |
2373 | | - | |
2374 | | - | |
2375 | | - | |
2376 | | - | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
| 2376 | + | |
2377 | 2377 | | |
2378 | 2378 | | |
2379 | 2379 | | |
| |||
4359 | 4359 | | |
4360 | 4360 | | |
4361 | 4361 | | |
4362 | | - | |
| 4362 | + | |
4363 | 4363 | | |
4364 | 4364 | | |
4365 | 4365 | | |
| |||
6935 | 6935 | | |
6936 | 6936 | | |
6937 | 6937 | | |
6938 | | - | |
| 6938 | + | |
6939 | 6939 | | |
6940 | 6940 | | |
6941 | 6941 | | |
| 6942 | + | |
6942 | 6943 | | |
6943 | 6944 | | |
6944 | 6945 | | |
| |||
6956 | 6957 | | |
6957 | 6958 | | |
6958 | 6959 | | |
| 6960 | + | |
6959 | 6961 | | |
6960 | 6962 | | |
6961 | 6963 | | |
| |||
6980 | 6982 | | |
6981 | 6983 | | |
6982 | 6984 | | |
| 6985 | + | |
6983 | 6986 | | |
6984 | 6987 | | |
6985 | 6988 | | |
| |||
7018 | 7021 | | |
7019 | 7022 | | |
7020 | 7023 | | |
| 7024 | + | |
7021 | 7025 | | |
7022 | 7026 | | |
7023 | 7027 | | |
| |||
7026 | 7030 | | |
7027 | 7031 | | |
7028 | 7032 | | |
| 7033 | + | |
7029 | 7034 | | |
7030 | 7035 | | |
7031 | | - | |
| 7036 | + | |
| 7037 | + | |
| 7038 | + | |
| 7039 | + | |
| 7040 | + | |
| 7041 | + | |
| 7042 | + | |
7032 | 7043 | | |
7033 | 7044 | | |
7034 | 7045 | | |
| |||
7060 | 7071 | | |
7061 | 7072 | | |
7062 | 7073 | | |
| 7074 | + | |
| 7075 | + | |
7063 | 7076 | | |
7064 | 7077 | | |
7065 | 7078 | | |
| |||
7089 | 7102 | | |
7090 | 7103 | | |
7091 | 7104 | | |
7092 | | - | |
7093 | | - | |
| 7105 | + | |
| 7106 | + | |
| 7107 | + | |
| 7108 | + | |
| 7109 | + | |
| 7110 | + | |
| 7111 | + | |
| 7112 | + | |
7094 | 7113 | | |
7095 | 7114 | | |
7096 | 7115 | | |
| |||
7316 | 7335 | | |
7317 | 7336 | | |
7318 | 7337 | | |
| 7338 | + | |
| 7339 | + | |
7319 | 7340 | | |
7320 | | - | |
| 7341 | + | |
7321 | 7342 | | |
7322 | 7343 | | |
7323 | 7344 | | |
| 7345 | + | |
| 7346 | + | |
| 7347 | + | |
| 7348 | + | |
| 7349 | + | |
| 7350 | + | |
| 7351 | + | |
| 7352 | + | |
| 7353 | + | |
| 7354 | + | |
| 7355 | + | |
| 7356 | + | |
| 7357 | + | |
| 7358 | + | |
| 7359 | + | |
| 7360 | + | |
| 7361 | + | |
| 7362 | + | |
| 7363 | + | |
| 7364 | + | |
| 7365 | + | |
| 7366 | + | |
| 7367 | + | |
| 7368 | + | |
| 7369 | + | |
| 7370 | + | |
| 7371 | + | |
| 7372 | + | |
| 7373 | + | |
| 7374 | + | |
| 7375 | + | |
| 7376 | + | |
| 7377 | + | |
| 7378 | + | |
| 7379 | + | |
| 7380 | + | |
7324 | 7381 | | |
7325 | 7382 | | |
7326 | 7383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | | - | |
| 256 | + | |
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
32 | | - | |
33 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
34 | 44 | | |
0 commit comments