Skip to content

Instantly share code, notes, and snippets.

@vtjnash
Created December 2, 2019 21:03
Show Gist options
  • Save vtjnash/2f2b642663655d5fc63ec7321c5bd0bd to your computer and use it in GitHub Desktop.
Save vtjnash/2f2b642663655d5fc63ec7321c5bd0bd to your computer and use it in GitHub Desktop.
dwarf linetable pretty printer
julia> @code_native write(devnull, 'x')
.text
; ┌ @ io.jl:644 within `write'
; │┌ @ io.jl:644 within `bswap'
bswapl %edi
xorl %eax, %eax
nopw %cs:(%rax,%rax)
nop
; │└
; │ @ io.jl:648 within `write'
; │┌ @ int.jl:430 within `>>' @ int.jl:424
L16:
shrl $8, %edi
; │└
addq $1, %rax
; │┌ @ int.jl:414 within `==' @ promotion.jl:348 @ promotion.jl:398
testl %edi, %edi
; │└
jne L16
retq
nopl (%rax)
; └
julia> @code_llvm write(devnull, 'x')
; @ io.jl:644 within `write'
define i64 @julia_write_16785(i32) {
top:
; ┌ @ int.jl:326 within `bswap'
%1 = call i32 @llvm.bswap.i32(i32 %0)
br label %L3
L3: ; preds = %L3, %top
%value_phi = phi i32 [ %1, %top ], [ %2, %L3 ]
%value_phi1 = phi i64 [ 1, %top ], [ %4, %L3 ]
; └
; @ io.jl:648 within `write'
; ┌ @ int.jl:430 within `>>' @ int.jl:424
%2 = lshr i32 %value_phi, 8
; └
; ┌ @ int.jl:414 within `==' @ promotion.jl:348 @ promotion.jl:398
%3 = icmp eq i32 %2, 0
; └
; @ io.jl:649 within `write'
; ┌ @ int.jl:53 within `+'
%4 = add nuw nsw i64 %value_phi1, 1
; └
; @ io.jl:648 within `write'
br i1 %3, label %L18, label %L3
L18: ; preds = %L3
ret i64 %value_phi1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment