Skip to content

Commit e266fa9

Browse files
committed
Refine APIs
1 parent 080969e commit e266fa9

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

include/remill/Arch/Arch.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ struct Register {
125125
// The directly enclosed registers.
126126
std::vector<const Register *> children;
127127

128-
void ComputeGEPAccessors(const llvm::DataLayout &dl, llvm::Type *state_type);
128+
void ComputeGEPAccessors(const llvm::DataLayout &dl,
129+
llvm::StructType *state_type);
129130
};
130131

131132
class Arch {

lib/Arch/Arch.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ namespace {
444444

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

482482
static llvm::Value *
483483
FinishAddressOf(llvm::IRBuilder<> &ir, const llvm::DataLayout &dl,
484-
llvm::Type *state_type, size_t state_size,
485-
const Register *reg, unsigned addr_space,
486-
llvm::Value *gep) {
484+
llvm::StructType *state_type, size_t state_size,
485+
const Register *reg, unsigned addr_space, llvm::Value *gep) {
487486

488487

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

550549
void Register::ComputeGEPAccessors(const llvm::DataLayout &dl,
551-
llvm::Type *state_type) {
552-
if (gep_type_at_offset || !state_type) {
550+
llvm::StructType *state_type) {
551+
if (gep_type_at_offset) {
553552
return;
554553
}
555554

555+
if (!state_type) {
556+
state_type = arch->state_type;
557+
}
558+
556559
auto &context = state_type->getContext();
557560

558561
gep_index_list.push_back(

0 commit comments

Comments
 (0)