Skip to content

Commit

Permalink
bump remill and fix initial state pc
Browse files Browse the repository at this point in the history
  • Loading branch information
2over12 committed Feb 28, 2024
1 parent 70209a8 commit 009e172
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions lib/Lifters/BasicBlockLifter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ bool BasicBlockLifter::DoInterProceduralControlFlow(
auto func = block->getParent();
auto should_return = func->getArg(kShouldReturnArgNum);
builder.CreateStore(llvm::Constant::getAllOnesValue(
llvm::IntegerType::getInt1Ty(llvm_context)),
llvm::IntegerType::getInt1Ty(llvm_context)),
should_return);
}
}
Expand Down Expand Up @@ -417,7 +417,8 @@ llvm::MDNode *BasicBlockLifter::GetBasicBlockUidAnnotation(Uid uid) const {

llvm::Function *BasicBlockLifter::DeclareBasicBlockFunction() {
std::string name_ = "func" + std::to_string(decl.address) + "basic_block" +
std::to_string(this->block_def.addr) + "_" + std::to_string(this->block_def.uid.value);
std::to_string(this->block_def.addr) + "_" +
std::to_string(this->block_def.uid.value);
auto &context = this->semantics_module->getContext();
llvm::FunctionType *lifted_func_type =
llvm::dyn_cast<llvm::FunctionType>(remill::RecontextualizeType(
Expand Down Expand Up @@ -597,7 +598,8 @@ BasicBlockFunction BasicBlockLifter::CreateBasicBlockFunction() {
auto pc_ptr = pc_reg->AddressOf(this->state_ptr, ir);
auto pc_val = this->options.program_counter_init_procedure(
ir, this->address_type, this->block_def.addr);
ir.CreateStore(pc_val, pc_ptr);

ir.CreateStore(ir.CreateZExtOrTrunc(pc_val, pc_reg_type), pc_ptr);

std::array<llvm::Value *, kNumLiftedBasicBlockArgs> args = {
this->state_ptr, pc_val, mem_res, next_pc, should_return};
Expand Down Expand Up @@ -648,7 +650,8 @@ void BasicBlockLifter::TerminateBasicBlockFunction(
llvm::IRBuilder<> calling_bb_builder(calling_bb);
auto edge_bb = this->decl.cfg.find(edge_uid);
CHECK(edge_bb != this->decl.cfg.end());
auto &child_lifter = this->flifter.GetOrCreateBasicBlockLifter(edge_bb->second.uid);
auto &child_lifter =
this->flifter.GetOrCreateBasicBlockLifter(edge_bb->second.uid);
auto retval = child_lifter.ControlFlowCallBasicBlockFunction(
caller, calling_bb_builder, this->state_ptr, bbfunc.stack, next_mem);
if (this->flifter.curr_decl->type->getReturnType()->isVoidTy()) {
Expand All @@ -658,7 +661,8 @@ void BasicBlockLifter::TerminateBasicBlockFunction(
}

auto succ_const = llvm::ConstantInt::get(
llvm::cast<llvm::IntegerType>(this->address_type), edge_bb->second.addr);
llvm::cast<llvm::IntegerType>(this->address_type),
edge_bb->second.addr);
sw->addCase(succ_const, calling_bb);
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/lifting-tools-ci
2 changes: 1 addition & 1 deletion remill

0 comments on commit 009e172

Please sign in to comment.