Skip to content

Commit

Permalink
Remove more usages of PointerElementType
Browse files Browse the repository at this point in the history
  • Loading branch information
tetsuo-cpp committed Jun 2, 2022
1 parent 36ff255 commit e3b43d1
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/BC/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1464,16 +1464,13 @@ llvm::GlobalVariable *DeclareVarInModule(llvm::GlobalVariable *var,
return llvm::dyn_cast<llvm::GlobalVariable>(moved_var);
}

// NOTE(alex): This looks difficult to reproduce without querying `PointerElementType`.
// It appears to be transferring global variables from one LLVM module to another. The
// variables are pointer types but we want to move the variable that the pointer is pointing at?
auto &dest_context = dest_module->getContext();
const auto type = ::remill::RecontextualizeType(
PointerElementType(var->getType()), dest_context);
var->getValueType(), dest_context);

auto dest_var = dest_module->getGlobalVariable(var->getName());
if (dest_var) {
CHECK_EQ(type, PointerElementType(dest_var->getType()));
CHECK_EQ(type, dest_var->getValueType());
moved_var = dest_var;
return dest_var;
}
Expand Down Expand Up @@ -1523,7 +1520,7 @@ llvm::GlobalAlias *DeclareAliasInModule(llvm::GlobalAlias *var,
}
}

const auto elem_type = PointerElementType(dest_type);
const auto elem_type = var->getValueType();
const auto dest_var = llvm::GlobalAlias::create(
elem_type, var->getType()->getAddressSpace(), var->getLinkage(),
var->getName(), nullptr, dest_module);
Expand Down

0 comments on commit e3b43d1

Please sign in to comment.