JuliaLabs / Cassette.jl

Overdub Your Julia Code
Other
371 stars 35 forks source link

clean debug info #12

Open maleadt opened 7 years ago

maleadt commented 7 years ago

For future use in "production", the debug info added|overwritten by Cassette is going to be severely downgrading the debugging experience.

Exhibit 1

foo(ptr, i) = Base.unsafe_load(ptr, i)

Original IR:

; Function foo
; Location: test.jl:1
define float @julia_foo_62524(i64, i64) {
top:
  %2 = add i64 %1, -1
  %3 = inttoptr i64 %0 to float*
  %4 = getelementptr float, float* %3, i64 %2
  %5 = load float, float* %4, align 1
  ret float %5
}

Overdubbed IR:

; Function Overdub
; Location: Cassette/src/workarounds.jl:21
define nonnull %jl_value_t addrspace(10)* @julia_Overdub_62640(i64, i64) {
top:
; Function execute; {
; Location: Cassette/src/workarounds.jl:16
; Function execute; {
; Location: Cassette/src/overdub/execution.jl:75
; Function execute; {
; Location: Cassette/src/workarounds.jl:18
; Function execute; {
; Location: Cassette/src/overdub/execution.jl:77
; Function Overdub; {
; Location: Cassette/src/overdub/execution.jl:129
; Function Overdub; {
; Location: Cassette/src/workarounds.jl:21
; Function execute; {
; Location: Cassette/src/workarounds.jl:16
; Function execute; {
; Location: Cassette/src/overdub/execution.jl:75
; Function execute; {
; Location: Cassette/src/workarounds.jl:18
; Function execute; {
; Location: Cassette/src/overdub/execution.jl:77
; Function Overdub; {
; Location: Cassette/src/overdub/execution.jl:129
; Function Overdub; {
; Location: Cassette/src/workarounds.jl:21
; Function execute; {
; Location: Cassette/src/workarounds.jl:16
; Function execute; {
; Location: Cassette/src/overdub/execution.jl:75
; Function execute; {
; Location: Cassette/src/workarounds.jl:18
; Function execute; {
; Location: Cassette/src/overdub/execution.jl:77
; Function Overdub; {
; Location: Cassette/src/overdub/execution.jl:129
; Function @generated body; {
; Location: Cassette/src/overdub/execution.jl:138
; Function execute; {
; Location: Cassette/src/workarounds.jl:17
; Function execute; {
; Location: Cassette/src/overdub/execution.jl:76
; Function execution; {
; Location: Cassette/src/workarounds.jl:12
; Function execution; {
; Location: Cassette/src/overdub/execution.jl:46
; Function _execution; {
; Location: Cassette/src/workarounds.jl:9
; Function _execution; {
; Location: Cassette/src/overdub/execution.jl:45
; Function unwrapcall; {
; Location: Cassette/src/workarounds.jl:24
; Function unwrapcall; {
; Location: Cassette/src/contextual/metadata.jl:45
; Function @generated body; {
; Location: Cassette/src/contextual/metadata.jl:48
  %2 = add i64 %1, -1
  %3 = inttoptr i64 %0 to float*
  %4 = getelementptr float, float* %3, i64 %2
  %5 = load float, float* %4, align 1
  %6 = call %jl_value_t addrspace(10)* @jl_box_float32(float %5)
;}}}}}}}}}}}}}}}}}}}}}}}}}}}
  ret %jl_value_t addrspace(10)* %6
}

Another problem is method names getting lost. For example:

foobar(i) = foo(bar(i))
@noinline foo(i) = i
@noinline bar(i) = i

Original IR:

define i64 @julia_foobar_62524(i64) {
top:
  %1 = call i64 @julia_bar_62525(i64 %0)
  %2 = call i64 @julia_foo_62526(i64 %1)
  ret i64 %2
}

Overdubbed IR:

define i64 @julia_Overdub_62611(i64) {
top:
  %1 = call i64 @julia_Overdub_62612(i64 %0)
  %2 = call i64 @julia_Overdub_62613(i64 %1)
  ret i64 %2
}

ie. everything is overdub now.

Of course, these issues aren't critical, just putting it out here 🙂

jrevels commented 6 years ago

everything is overdub now.

All your functions are belong to Cassette! 😛

Maybe we can implement some mechanism that optionally removes all the Cassette plumbing from the debug info, but still attaches contextual information to each call in some reasonable way. I wonder how that would work...