Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions VTIL-Compiler/optimizer/register_renaming_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ namespace vtil::optimizer
//
if ( i->is_volatile() )
return fail();

// If source is being accessed by a vxcall instruction, fail.
//
if ( mask && i->base == &ins::vxcall )
return fail();
}

// If destination is used by the instruction, fail.
Expand Down
40 changes: 40 additions & 0 deletions VTIL-Tests/dummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,46 @@ DOCTEST_TEST_CASE("Optimization register_renaming_pass")
CHECK(ins.operands[1].imm().ival == 0x1);
}

DOCTEST_TEST_CASE("Optimization register_renaming_pass vxcall")
{
vtil::logger::log("\n\n>> %s \n", __FUNCTION__);

auto block = vtil::basic_block::begin(0x1337);

vtil::register_desc reg_ecx(vtil::register_physical, registers::cx, vtil::arch::bit_count, 0);

auto sr0 = block->owner->alloc(vtil::arch::bit_count);

// The ecx register here is a potential function argument, register_renaming_pass should not work here.
block->mov(reg_ecx, (uintptr_t)0x880000);
block->vxcall((uintptr_t)0x10000);

auto block2 = block->fork(0x2000);
block2->mov(sr0, reg_ecx);
block2->mov(reg_ecx, (uintptr_t)1);
block2->mov(reg_ecx, sr0);
block2->vxcall((uintptr_t)0x10000);

auto block3 = block2->fork(0x3000);
block3->vexit(0ull); // marks the end of a basic_block

vtil::logger::log(":: Before:\n");
vtil::debug::dump(block->owner);

vtil::optimizer::register_renaming_pass{}(block->owner);

vtil::logger::log(":: After:\n");
vtil::debug::dump(block->owner);

auto ins = (*block)[0];

// mov ecx, 0x880000
CHECK(ins.base == &vtil::ins::mov);
CHECK(ins.operands.size() == 2);
CHECK(ins.operands[0].reg().local_id == registers::cx);
CHECK(ins.operands[1].imm().ival == 0x880000);
}

DOCTEST_TEST_CASE("Optimization symbolic_rewrite_pass<true>")
{
vtil::logger::log("\n\n>> %s \n", __FUNCTION__);
Expand Down