Skip to content

Instantly share code, notes, and snippets.

@gcolvin
Created October 20, 2017 15:54
Show Gist options
  • Save gcolvin/469b84f47de803456ccb22341e5b9402 to your computer and use it in GitHub Desktop.
Save gcolvin/469b84f47de803456ccb22341e5b9402 to your computer and use it in GitHub Desktop.
gcolvin@Dell:~/ether/perf-tests/test/unittests/performance$ make -f tests.mk ETHVM-JIT=./ethvm add256.ran
echo ethvm-jit; time -p ./ethvm --vm jit test add256.bin; touch add256.ran
ethvm-jit
; ModuleID = '7665577a0bc6fbdb1b11cddad76dad92559f0915def3ec7cbb39ad92ae658c11F'
source_filename = "7665577a0bc6fbdb1b11cddad76dad92559f0915def3ec7cbb39ad92ae658c11F"
%Runtime = type { %RuntimeData*, %Env*, %Array }
%RuntimeData = type { i64, i64, i8*, i64, i256, i8*, i64, i256, i256, i64 }
%Env = type opaque
%Array = type { i256*, i64, i64 }
%evm.txctx = type { i256, [20 x i8], [20 x i8], i64, i64, i64, i256 }
define i32 @"7665577a0bc6fbdb1b11cddad76dad92559f0915def3ec7cbb39ad92ae658c11F"(%Runtime* %rt) {
Entry:
%txctx.loaded = alloca i1
store i1 false, i1* %txctx.loaded
%0 = getelementptr inbounds %Runtime, %Runtime* %rt, i32 0, i32 0
%dataPtr = load %RuntimeData*, %RuntimeData** %0
%mem = getelementptr inbounds %Runtime, %Runtime* %rt, i32 0, i32 2
%stack.base = call i256* @malloc(i64 32768)
%stack.size = alloca i64
store i64 0, i64* %stack.size
%data = load %RuntimeData, %RuntimeData* %dataPtr
%msg.gas = extractvalue %RuntimeData %data, 0
%gas.ptr = alloca i64
store i64 %msg.gas, i64* %gas.ptr
%returndata.ptr = alloca i8*
store i8* null, i8** %returndata.ptr
%returndatasize.ptr = alloca i64
store i64 0, i64* %returndatasize.ptr
store %Array zeroinitializer, %Array* %mem
%jmpBuf.words = alloca i8*, i64 3
%fp = call i8* @llvm.frameaddress(i32 0)
store i8* %fp, i8** %jmpBuf.words
%sp = call i8* @llvm.stacksave()
%jmpBuf.sp = getelementptr inbounds i8*, i8** %jmpBuf.words, i64 2
store i8* %sp, i8** %jmpBuf.sp
%jmpBuf = bitcast i8** %jmpBuf.words to i8*
%1 = call i32 @llvm.eh.sjlj.setjmp(i8* %jmpBuf)
%2 = icmp eq i32 %1, 0
br i1 %2, label %.0, label %Exit, !prof !0
.0: ; preds = %Entry
%sp.0 = call i256* @stack.prepare(i256* %stack.base, i64* %stack.size, i64 0, i64 2, i64 2, i8* %jmpBuf)
call void @gas.check(i64* %gas.ptr, i64 6, i8* %jmpBuf)
%3 = getelementptr i256, i256* %sp.0, i64 0
store i256 0, i256* %3, align 16
%4 = getelementptr i256, i256* %sp.0, i64 1
store i256 0, i256* %4, align 16
br label %.4
.4: ; preds = %.16, %.0
%sp.4 = call i256* @stack.prepare(i256* %stack.base, i64* %stack.size, i64 -1, i64 2, i64 0, i8* %jmpBuf)
call void @gas.check(i64* %gas.ptr, i64 26, i8* %jmpBuf)
%5 = getelementptr i256, i256* %sp.4, i64 -1
%6 = load i256, i256* %5, align 16
%7 = icmp ult i256 %6, 1048576
%8 = zext i1 %7 to i256
%iszero = icmp eq i256 %8, 0
%9 = zext i1 %iszero to i256
%jump.check = icmp ne i256 %9, 0
%10 = getelementptr i256, i256* %sp.4, i64 -1
store i256 %6, i256* %10, align 16
br i1 %jump.check, label %.400, label %.16, !destIdx !1
.16: ; preds = %.4
%sp.16 = call i256* @stack.prepare(i256* %stack.base, i64* %stack.size, i64 -2, i64 4, i64 0, i8* %jmpBuf)
call void @gas.check(i64* %gas.ptr, i64 821, i8* %jmpBuf)
%11 = getelementptr i256, i256* %sp.16, i64 -2
store i256 -43650193032093146282442478976287625120531174123200328216868016097665534397671, i256* %11, align 16
%sp.389 = call i256* @stack.prepare(i256* %stack.base, i64* %stack.size, i64 -1, i64 2, i64 0, i8* %jmpBuf)
call void @gas.check(i64* %gas.ptr, i64 26, i8* %jmpBuf)
%12 = getelementptr i256, i256* %sp.389, i64 -1
%13 = load i256, i256* %12, align 16
%14 = add i256 %13, 1
%15 = getelementptr i256, i256* %sp.389, i64 -1
store i256 %14, i256* %15, align 16
br label %.4, !destIdx !2
.400: ; preds = %.4
%sp.400 = call i256* @stack.prepare(i256* %stack.base, i64* %stack.size, i64 -2, i64 2, i64 0, i8* %jmpBuf)
call void @gas.check(i64* %gas.ptr, i64 28, i8* %jmpBuf)
%16 = getelementptr i256, i256* %sp.400, i64 -2
%17 = load i256, i256* %16, align 16
%18 = icmp eq i256 %17, -43650193032093146282442478976287625120531174123200328216868016097665534397671
%19 = zext i1 %18 to i256
%jump.check1 = icmp ne i256 %19, 0
%20 = getelementptr i256, i256* %sp.400, i64 -2
store i256 %17, i256* %20, align 16
%21 = getelementptr i256, i256* %sp.400, i64 -1
store i256 %17, i256* %21, align 16
br i1 %jump.check1, label %.451, label %.442, !destIdx !3
.442: ; preds = %.400
%sp.442 = call i256* @stack.prepare(i256* %stack.base, i64* %stack.size, i64 0, i64 2, i64 2, i8* %jmpBuf)
call void @gas.check(i64* %gas.ptr, i64 6, i8* %jmpBuf)
%22 = getelementptr i256, i256* %sp.442, i64 0
store i256 0, i256* %22, align 16
%23 = getelementptr i256, i256* %sp.442, i64 1
store i256 0, i256* %23, align 16
br label %Exit
.451: ; preds = %.400
%sp.451 = call i256* @stack.prepare(i256* %stack.base, i64* %stack.size, i64 0, i64 0, i64 0, i8* %jmpBuf)
call void @gas.check(i64* %gas.ptr, i64 1, i8* %jmpBuf)
br label %Exit
Exit: ; preds = %Entry, %.451, %.442
%ret = phi i32 [ -1, %.442 ], [ 0, %.451 ], [ -1, %Entry ]
call void @free(i256* %stack.base)
%msg.gas.ptr = getelementptr inbounds %RuntimeData, %RuntimeData* %dataPtr, i32 0, i32 0
%gas = load i64, i64* %gas.ptr
store i64 %gas, i64* %msg.gas.ptr
ret i32 %ret
}
declare void @evm.get_tx_context(%evm.txctx*, %Env*)
define private fastcc void @loadTxCtx(i1* %flag, %evm.txctx* %txctx, %Env* %env) {
Check:
%0 = load i1, i1* %flag
br i1 %0, label %Exit, label %Load
Load: ; preds = %Check
store i1 true, i1* %flag
call void @evm.get_tx_context(%evm.txctx* %txctx, %Env* %env)
br label %Exit
Exit: ; preds = %Load, %Check
ret void
}
; Function Attrs: nounwind
declare noalias i256* @malloc(i64) #0
; Function Attrs: nounwind
declare void @free(i256* nocapture) #0
; Function Attrs: nounwind
define private void @gas.check(i64* nocapture %gasPtr, i64 %cost, i8* %jmpBuf) #0 {
Check:
%gas = load i64, i64* %gasPtr
%gasUpdated = sub nsw i64 %gas, %cost
%gasOk = icmp sge i64 %gasUpdated, 0
br i1 %gasOk, label %Update, label %OutOfGas, !prof !0
Update: ; preds = %Check
store i64 %gasUpdated, i64* %gasPtr
ret void
OutOfGas: ; preds = %Check
call void @llvm.eh.sjlj.longjmp(i8* %jmpBuf)
unreachable
}
; Function Attrs: noreturn nounwind
declare void @llvm.eh.sjlj.longjmp(i8*) #1
; Function Attrs: nounwind readnone
declare i8* @llvm.frameaddress(i32) #2
; Function Attrs: nounwind
declare i8* @llvm.stacksave() #0
; Function Attrs: nounwind
declare i32 @llvm.eh.sjlj.setjmp(i8*) #0
; Function Attrs: nounwind
define private i256* @stack.prepare(i256* readnone %base, i64* noalias nocapture %size.ptr, i64 %min, i64 %max, i64 %diff, i8* %jmpBuf) #0 {
Check:
%size = load i64, i64* %size.ptr, align 4
%size.min = add nsw i64 %size, %min
%size.max = add nuw nsw i64 %size, %max
%ok.min = icmp sge i64 %size.min, 0
%ok.max = icmp ule i64 %size.max, 1024
%ok = and i1 %ok.min, %ok.max
br i1 %ok, label %Update, label %OutOfStack, !prof !0
Update: ; preds = %Check
%size.next = add nsw i64 %size, %diff
store i64 %size.next, i64* %size.ptr, align 4
%sp = getelementptr i256, i256* %base, i64 %size
ret i256* %sp
OutOfStack: ; preds = %Check
call void @llvm.eh.sjlj.longjmp(i8* %jmpBuf)
unreachable
}
attributes #0 = { nounwind }
attributes #1 = { noreturn nounwind }
attributes #2 = { nounwind readnone }
!0 = !{!"branch_weights", i32 1, i32 0}
!1 = !{i256 400}
!2 = !{i256 4}
!3 = !{i256 451}
output: ''
exception: false
gas used: 915406909
gas/sec: 1.388e+10
exec time: 0.065939
real 0.89
user 0.87
sys 0.01
gcolvin@Dell:~/ether/perf-tests/test/unittests/performance$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment