Skip to content

Commit

Permalink
Refine APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
tetsuo-cpp committed Jun 21, 2022
1 parent 080969e commit e266fa9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion include/remill/Arch/Arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ struct Register {
// The directly enclosed registers.
std::vector<const Register *> children;

void ComputeGEPAccessors(const llvm::DataLayout &dl, llvm::Type *state_type);
void ComputeGEPAccessors(const llvm::DataLayout &dl,
llvm::StructType *state_type);
};

class Arch {
Expand Down
15 changes: 9 additions & 6 deletions lib/Arch/Arch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ namespace {

// Compute the total offset of a GEP chain.
static uint64_t TotalOffset(const llvm::DataLayout &dl, llvm::Value *base,
llvm::Type *state_type) {
llvm::StructType *state_type) {
uint64_t total_offset = 0;
const auto state_size = dl.getTypeAllocSize(state_type);
while (base) {
Expand Down Expand Up @@ -481,9 +481,8 @@ static uint64_t TotalOffset(const llvm::DataLayout &dl, llvm::Value *base,

static llvm::Value *
FinishAddressOf(llvm::IRBuilder<> &ir, const llvm::DataLayout &dl,
llvm::Type *state_type, size_t state_size,
const Register *reg, unsigned addr_space,
llvm::Value *gep) {
llvm::StructType *state_type, size_t state_size,
const Register *reg, unsigned addr_space, llvm::Value *gep) {


auto gep_offset = TotalOffset(dl, gep, state_type);
Expand Down Expand Up @@ -548,11 +547,15 @@ FinishAddressOf(llvm::IRBuilder<> &ir, const llvm::DataLayout &dl,
} // namespace

void Register::ComputeGEPAccessors(const llvm::DataLayout &dl,
llvm::Type *state_type) {
if (gep_type_at_offset || !state_type) {
llvm::StructType *state_type) {
if (gep_type_at_offset) {
return;
}

if (!state_type) {
state_type = arch->state_type;
}

auto &context = state_type->getContext();

gep_index_list.push_back(
Expand Down

0 comments on commit e266fa9

Please sign in to comment.