diff --git a/ir/function.cpp b/ir/function.cpp index fe3630fe4..309d82192 100644 --- a/ir/function.cpp +++ b/ir/function.cpp @@ -225,7 +225,7 @@ void Function::addConstant(unique_ptr &&c) { constants.emplace_back(std::move(c)); } -Value* Function::getConstant(string_view name) const { +Value* Function::getGlobalVar(string_view name) const { for (auto &c : constants) { if (c->getName() == name) return c.get(); @@ -300,7 +300,7 @@ void Function::syncDataWithSrc(Function &src) { auto copy_fns = [](const auto &src, auto &dst) { for (auto &c : src.getConstants()) { auto *gv = dynamic_cast(&c); - if (gv && gv->isArbitrarySize() && !dst.getConstant(gv->getName())) + if (gv && gv->isArbitrarySize() && !dst.getGlobalVar(gv->getName())) dst.addConstant(make_unique(*gv)); } }; diff --git a/ir/function.h b/ir/function.h index faa33dff6..24a09f0fb 100644 --- a/ir/function.h +++ b/ir/function.h @@ -142,7 +142,7 @@ class Function final { } unsigned numConstants() const { return constants.size(); } Value &getConstant(int idx) const { return *constants[idx]; } - Value* getConstant(std::string_view name) const; + Value* getGlobalVar(std::string_view name) const; std::vector getGlobalVars() const; std::vector getGlobalVarNames() const; diff --git a/ir/instr.cpp b/ir/instr.cpp index 10214f91f..fdc845dd5 100644 --- a/ir/instr.cpp +++ b/ir/instr.cpp @@ -2329,7 +2329,7 @@ StateValue FnCall::toSMT(State &s) const { // This is a direct call, but check if there are indirect calls elsewhere // to this function. If so, call it indirectly to match the other calls. if (!ptr) - ptr = s.getFn().getConstant(string_view(fnName).substr(1)); + ptr = s.getFn().getGlobalVar(string_view(fnName).substr(1)); ostringstream fnName_mangled; if (ptr) { diff --git a/ir/state.cpp b/ir/state.cpp index 2afed61b5..065d2c919 100644 --- a/ir/state.cpp +++ b/ir/state.cpp @@ -976,7 +976,7 @@ State::addFnCall(const string &name, vector &&inputs, } auto isgvar = [&](const auto &decl) { - if (auto gv = getFn().getConstant(string_view(decl.name).substr(1))) + if (auto gv = getFn().getGlobalVar(string_view(decl.name).substr(1))) return Pointer::mkPointerFromNoAttrs(memory, fn_ptr).getAddress() == Pointer(memory, (*this)[*gv].value).getAddress(); return expr(); @@ -1306,7 +1306,7 @@ void State::mkAxioms(State &tgt) { if (has_indirect_fncalls) { for (auto &decl : f.getFnDecls()) { - if (auto gv = f.getConstant(string_view(decl.name).substr(1))) + if (auto gv = f.getGlobalVar(string_view(decl.name).substr(1))) addAxiom( expr::mkUF("#fndeclty", { Pointer(memory, (*this)[*gv].value).reprWithoutAttrs() }, diff --git a/tools/transform.cpp b/tools/transform.cpp index ce7874935..405b35d33 100644 --- a/tools/transform.cpp +++ b/tools/transform.cpp @@ -1659,15 +1659,17 @@ void Transform::preprocess() { } // increase size of global variables to be a multiple of alignment - for (auto p : { &src, &tgt }) { - for (auto gv : p->getGlobalVars()) { - if (gv->isArbitrarySize()) - continue; - auto align = gv->getAlignment(); - auto sz = gv->size(); - auto newsize = round_up(sz, align); - if (newsize != sz) - gv->increaseSize(newsize); + for (auto gv : tgt.getGlobalVars()) { + if (gv->isArbitrarySize()) + continue; + auto align = gv->getAlignment(); + auto sz = gv->size(); + auto newsize = round_up(sz, align); + if (newsize != sz) { + gv->increaseSize(newsize); + if (auto src_gv = dynamic_cast( + src.getGlobalVar(gv->getName()))) + src_gv->increaseSize(newsize); } } }