Skip to content

Commit 056be95

Browse files
committed
More fixes
1 parent fd82a20 commit 056be95

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

include/remill/BC/Compat/PointerType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace remill {
2121

2222
// TODO(alex): Just remove this function entirely
2323
inline static llvm::Type *PointerElementType(llvm::PointerType *type) {
24-
assert(type->isOpaque());
24+
// assert(type->isOpaque());
2525
return nullptr;
2626
}
2727

lib/Arch/Arch.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,7 @@ FinishAddressOf(llvm::IRBuilder<> &ir, const llvm::DataLayout &dl,
496496
// Best case: we've found a value field in the structure that
497497
// is located at the correct byte offset.
498498
if (gep_offset == reg->offset) {
499-
if (gep->getType()->isPointerTy()) {
500-
return gep;
501-
502-
} else if (auto const_gep = llvm::dyn_cast<llvm::Constant>(gep);
503-
const_gep) {
499+
if (auto const_gep = llvm::dyn_cast<llvm::Constant>(gep); const_gep) {
504500
return llvm::ConstantExpr::getBitCast(const_gep, goal_ptr_type);
505501

506502
} else {
@@ -574,8 +570,7 @@ llvm::Value *Register::AddressOf(llvm::Value *state_ptr,
574570
return AddressOf(state_ptr, ir);
575571
}
576572

577-
llvm::Value *
578-
Register::AddressOf(llvm::Value *state_ptr,
573+
llvm::Value *Register::AddressOf(llvm::Value *state_ptr,
579574
llvm::IRBuilder<> &ir) const {
580575
auto &context = type->getContext();
581576
CHECK_EQ(&context, &(state_ptr->getContext()));

lib/BC/Util.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,9 @@ llvm::GlobalVariable *DeclareVarInModule(llvm::GlobalVariable *var,
14641464
return llvm::dyn_cast<llvm::GlobalVariable>(moved_var);
14651465
}
14661466

1467+
// NOTE(alex): This looks difficult to reproduce without querying `PointerElementType`.
1468+
// It appears to be transferring global variables from one LLVM module to another. The
1469+
// variables are pointer types.
14671470
auto &dest_context = dest_module->getContext();
14681471
const auto type = ::remill::RecontextualizeType(
14691472
PointerElementType(var->getType()), dest_context);
@@ -2433,6 +2436,7 @@ llvm::Value *BuildPointerToOffset(llvm::IRBuilder<> &ir, llvm::Value *ptr,
24332436
}
24342437
}
24352438

2439+
// NOTE(alex): Same here
24362440
const auto dest_elem_type = PointerElementType(dest_elem_ptr_type);
24372441
const auto ptr_elem_type = PointerElementType(ptr_type);
24382442
const auto ptr_elem_size = dl.getTypeAllocSize(ptr_elem_type);

0 commit comments

Comments
 (0)