diff --git a/evmcc/test/jump/fib1.ethel b/evmcc/test/jump/fib1.ethel index 6efd4ed2d..81b869f41 100644 --- a/evmcc/test/jump/fib1.ethel +++ b/evmcc/test/jump/fib1.ethel @@ -2,4 +2,5 @@ let fib n = if n < 3 then 1 else fib (n-1) + fib (n-2) -return fib 5 +return fib 10 + diff --git a/evmcc/test/jump/fib1.evm b/evmcc/test/jump/fib1.evm index b5b5bf9c6..5042a192f 100644 --- a/evmcc/test/jump/fib1.evm +++ b/evmcc/test/jump/fib1.evm @@ -1 +1 @@ -630000000d60056300000016585d60005460206000f28060030a630000004759630000002f816001036300000016585d630000003f836002036300000016585d0163000000495860019350505058 \ No newline at end of file +6007600a6010585d60005460206000f26003810a602f596020600282036010585d602a600183036010585d01603158600190509058 \ No newline at end of file diff --git a/evmcc/test/jump/rec1.ethel b/evmcc/test/jump/rec1.ethel new file mode 100644 index 000000000..f83c8e81e --- /dev/null +++ b/evmcc/test/jump/rec1.ethel @@ -0,0 +1,4 @@ +let f n = + if n == 0 then 2 else f (n-1) + +return f 10 diff --git a/evmcc/test/jump/rec1.evm b/evmcc/test/jump/rec1.evm new file mode 100644 index 000000000..2ae62aff6 --- /dev/null +++ b/evmcc/test/jump/rec1.evm @@ -0,0 +1 @@ +6007600a6010585d60005460206000f26000810e6024596020600182036010585d602658600290509058 \ No newline at end of file diff --git a/libevmjit/BasicBlock.cpp b/libevmjit/BasicBlock.cpp index 927f1180b..2c5ea7285 100644 --- a/libevmjit/BasicBlock.cpp +++ b/libevmjit/BasicBlock.cpp @@ -52,7 +52,7 @@ llvm::Value* BasicBlock::LocalStack::get(size_t _index) m_backend.insert(m_backend.begin(), nMissingVals, nullptr); for (decltype(nMissingVals) i = 0; i < nMissingVals; ++i) { - m_backend[i] = m_llvmBB->empty() ? + m_backend[nMissingVals - 1 - i] = m_llvmBB->empty() ? llvm::PHINode::Create(Type::i256, 0, {}, m_llvmBB) : llvm::PHINode::Create(Type::i256, 0, {}, m_llvmBB->getFirstNonPHI()); m_numRequiredStackItems += 1;