Skip to content

Instantly share code, notes, and snippets.

@dhoegh
Last active November 6, 2017 20:06
Show Gist options
  • Save dhoegh/34d9a707eee65ed9cfe5c27203875f6c to your computer and use it in GitHub Desktop.
Save dhoegh/34d9a707eee65ed9cfe5c27203875f6c to your computer and use it in GitHub Desktop.
julia> @code_llvm testnew(signal)
; Function testnew
; Location: REPL[17]
; Function Attrs: uwtable
define %jl_value_t addrspace(10)* @japi1_testnew_64914(%jl_value_t addrspace(10)*, %jl_value_t addrspace(10)**, i32) #0 {
top:
%gcframe2 = alloca [3 x %jl_value_t addrspace(10)*], align 8
%gcframe2.sub = getelementptr inbounds [3 x %jl_value_t addrspace(10)*], [3 x %jl_value_t addrspace(10)*]* %gcframe2, i64 0, i64 0
%3 = getelementptr inbounds [3 x %jl_value_t addrspace(10)*], [3 x %jl_value_t addrspace(10)*]* %gcframe2, i64 0, i64 1
%4 = bitcast %jl_value_t addrspace(10)** %3 to i8*
call void @llvm.memset.p0i8.i32(i8* %4, i8 0, i32 16, i32 8, i1 false)
%5 = alloca %jl_value_t addrspace(10)**, align 8
store volatile %jl_value_t addrspace(10)** %1, %jl_value_t addrspace(10)*** %5, align 8
%6 = call %jl_value_t*** @jl_get_ptls_states() #3
%7 = bitcast [3 x %jl_value_t addrspace(10)*]* %gcframe2 to i64*
store i64 2, i64* %7, align 8
%8 = getelementptr [3 x %jl_value_t addrspace(10)*], [3 x %jl_value_t addrspace(10)*]* %gcframe2, i64 0, i64 1
%9 = bitcast %jl_value_t*** %6 to i64*
%10 = load i64, i64* %9, align 8
%11 = bitcast %jl_value_t addrspace(10)** %8 to i64*
store i64 %10, i64* %11, align 8
%12 = bitcast %jl_value_t*** %6 to %jl_value_t addrspace(10)***
store %jl_value_t addrspace(10)** %gcframe2.sub, %jl_value_t addrspace(10)*** %12, align 8
%13 = load %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)** %1, align 8
; Location: REPL[17]:2
%14 = call %jl_value_t addrspace(10)* inttoptr (i64 1693665680 to %jl_value_t addrspace(10)* (%jl_value_t addrspace(10)*)*)(%jl_value_t addrspace(10)* %13)
; Location: REPL[17]:3
%15 = addrspacecast %jl_value_t addrspace(10)* %14 to %jl_value_t addrspace(11)*
%16 = bitcast %jl_value_t addrspace(11)* %15 to %jl_array_t addrspace(11)*
%17 = getelementptr inbounds %jl_array_t, %jl_array_t addrspace(11)* %16, i64 0, i32 1
%18 = load i64, i64 addrspace(11)* %17, align 8
%19 = icmp slt i64 %18, 1001
%.op = add i64 %18, 1
%20 = icmp eq i64 %.op, 1001
%21 = or i1 %19, %20
br i1 %21, label %L29, label %if.lr.ph
if.lr.ph: ; preds = %top
%22 = getelementptr [3 x %jl_value_t addrspace(10)*], [3 x %jl_value_t addrspace(10)*]* %gcframe2, i64 0, i64 2
br label %if
if: ; preds = %if.lr.ph, %if
%"#temp#.03" = phi i64 [ 1001, %if.lr.ph ], [ %23, %if ]
%23 = add i64 %"#temp#.03", 1
store %jl_value_t addrspace(10)* %14, %jl_value_t addrspace(10)** %22, align 8
; Location: REPL[17]:4
; Function deleteat!; {
; Location: array.jl:1206
call void inttoptr (i64 1693663328 to void (%jl_value_t addrspace(10)*, i64, i64)*)(%jl_value_t addrspace(10)* %14, i64 999, i64 1)
;}
; Location: REPL[17]:3
%24 = icmp eq i64 %23, %.op
br i1 %24, label %L29.loopexit, label %if
L29.loopexit: ; preds = %if
; Location: REPL[17]:6
br label %L29
L29: ; preds = %L29.loopexit, %top
%25 = load i64, i64* %11, align 8
store i64 %25, i64* %9, align 8
ret %jl_value_t addrspace(10)* %14
}
julia> @code_llvm test(signal)
; Function test
; Location: REPL[16]
; Function Attrs: uwtable
define %jl_value_t addrspace(10)* @japi1_test_64913(%jl_value_t addrspace(10)*, %jl_value_t addrspace(10)**, i32) #0 {
top:
%gcframe1 = alloca [3 x %jl_value_t addrspace(10)*], align 8
%gcframe1.sub = getelementptr inbounds [3 x %jl_value_t addrspace(10)*], [3 x %jl_value_t addrspace(10)*]* %gcframe1, i64 0, i64 0
%3 = getelementptr inbounds [3 x %jl_value_t addrspace(10)*], [3 x %jl_value_t addrspace(10)*]* %gcframe1, i64 0, i64 1
%4 = bitcast %jl_value_t addrspace(10)** %3 to i8*
call void @llvm.memset.p0i8.i32(i8* %4, i8 0, i32 16, i32 8, i1 false)
%5 = alloca %jl_value_t addrspace(10)**, align 8
store volatile %jl_value_t addrspace(10)** %1, %jl_value_t addrspace(10)*** %5, align 8
%6 = call %jl_value_t*** @jl_get_ptls_states() #2
%7 = bitcast [3 x %jl_value_t addrspace(10)*]* %gcframe1 to i64*
store i64 2, i64* %7, align 8
%8 = getelementptr [3 x %jl_value_t addrspace(10)*], [3 x %jl_value_t addrspace(10)*]* %gcframe1, i64 0, i64 1
%9 = bitcast %jl_value_t*** %6 to i64*
%10 = load i64, i64* %9, align 8
%11 = bitcast %jl_value_t addrspace(10)** %8 to i64*
store i64 %10, i64* %11, align 8
%12 = bitcast %jl_value_t*** %6 to %jl_value_t addrspace(10)***
store %jl_value_t addrspace(10)** %gcframe1.sub, %jl_value_t addrspace(10)*** %12, align 8
%13 = load %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)** %1, align 8
; Location: REPL[16]:2
%14 = call %jl_value_t addrspace(10)* inttoptr (i64 1693665680 to %jl_value_t addrspace(10)* (%jl_value_t addrspace(10)*)*)(%jl_value_t addrspace(10)* %13)
; Location: REPL[16]:3
%15 = addrspacecast %jl_value_t addrspace(10)* %14 to %jl_value_t addrspace(11)*
%16 = bitcast %jl_value_t addrspace(11)* %15 to %jl_array_t addrspace(11)*
%17 = getelementptr inbounds %jl_array_t, %jl_array_t addrspace(11)* %16, i64 0, i32 1
%18 = load i64, i64 addrspace(11)* %17, align 8
%19 = icmp slt i64 %18, 1001
%.op = add i64 %18, 1
%20 = icmp eq i64 %.op, 1001
%21 = or i1 %19, %20
br i1 %21, label %L14, label %if.lr.ph
if.lr.ph: ; preds = %top
%22 = getelementptr [3 x %jl_value_t addrspace(10)*], [3 x %jl_value_t addrspace(10)*]* %gcframe1, i64 0, i64 2
br label %if
if: ; preds = %if.lr.ph, %if
%"#temp#.02" = phi i64 [ 1001, %if.lr.ph ], [ %23, %if ]
%23 = add i64 %"#temp#.02", 1
store %jl_value_t addrspace(10)* %14, %jl_value_t addrspace(10)** %22, align 8
; Location: REPL[16]:4
%24 = call %jl_value_t addrspace(10)* @"julia__deleteat_beg!_64844"(%jl_value_t addrspace(10)* %14, i64 1000, i64 1)
; Location: REPL[16]:3
%25 = icmp eq i64 %23, %.op
br i1 %25, label %L14.loopexit, label %if
L14.loopexit: ; preds = %if
; Location: REPL[16]:6
br label %L14
L14: ; preds = %L14.loopexit, %top
%26 = load i64, i64* %11, align 8
store i64 %26, i64* %9, align 8
ret %jl_value_t addrspace(10)* %14
}
julia> @code_native test(signal)
.text
; Function <invalid> {
; Location: REPL[16]
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rsi
pushq %rdi
pushq %rbx
subq $64, %rsp
movq %rdx, %rdi
xorps %xmm0, %xmm0
movups %xmm0, -48(%rbp)
movq %rdi, -64(%rbp)
movabsq $jl_get_ptls_states, %rax
callq *%rax
movq %rax, %r14
movq $2, -56(%rbp)
movq (%r14), %rax
movq %rax, -48(%rbp)
leaq -56(%rbp), %rax
movq %rax, (%r14)
movq (%rdi), %rcx
;}
; Function test {
; Location: REPL[16]:2
movl $jl_array_copy, %eax
callq *%rax
movq %rax, %rdi
; Location: REPL[16]:3
movq 8(%rdi), %rbx
cmpq $1001, %rbx # imm = 0x3E9
jl L153
leaq 1(%rbx), %rax
cmpq $1001, %rax # imm = 0x3E9
je L153
addq $-1000, %rbx # imm = 0xFC18
; Location: REPL[16]:4
movabsq $"_deleteat_beg!", %rsi
nopw (%rax,%rax)
L128:
movq %rdi, -40(%rbp)
movl $1000, %edx # imm = 0x3E8
movl $1, %r8d
movq %rdi, %rcx
callq *%rsi
; Location: REPL[16]:3
decq %rbx
jne L128
; Location: REPL[16]:6
L153:
movq -48(%rbp), %rax
movq %rax, (%r14)
movq %rdi, %rax
addq $64, %rsp
popq %rbx
popq %rdi
popq %rsi
popq %r14
popq %rbp
retq
nop
;}
julia> @code_native testnew(signal)
.text
; Function <invalid> {
; Location: REPL[17]
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rsi
pushq %rdi
pushq %rbx
subq $64, %rsp
movq %rdx, %rdi
xorps %xmm0, %xmm0
movups %xmm0, -48(%rbp)
movq %rdi, -64(%rbp)
movabsq $jl_get_ptls_states, %rax
callq *%rax
movq %rax, %r14
movq $2, -56(%rbp)
movq (%r14), %rax
movq %rax, -48(%rbp)
leaq -56(%rbp), %rax
movq %rax, (%r14)
movq (%rdi), %rcx
;}
; Function testnew {
; Location: REPL[17]:2
movl $jl_array_copy, %eax
callq *%rax
movq %rax, %rdi
; Location: REPL[17]:3
movq 8(%rdi), %rbx
cmpq $1001, %rbx # imm = 0x3E9
jl L153
leaq 1(%rbx), %rax
cmpq $1001, %rax # imm = 0x3E9
je L153
addq $-1000, %rbx # imm = 0xFC18
; Location: REPL[17]:4
; Function deleteat!; {
; Location: array.jl:1206
movl $jl_array_del_at, %esi
nopw %cs:(%rax,%rax)
L128:
movq %rdi, -40(%rbp)
movl $999, %edx # imm = 0x3E7
movl $1, %r8d
movq %rdi, %rcx
callq *%rsi
;}
; Location: REPL[17]:3
decq %rbx
jne L128
; Location: REPL[17]:6
L153:
movq -48(%rbp), %rax
movq %rax, (%r14)
movq %rdi, %rax
addq $64, %rsp
popq %rbx
popq %rdi
popq %rsi
popq %r14
popq %rbp
retq
nop
;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment