print global variables when printing a function/transform
MODIFY
ir/function.cpp
ir/function.cpp
@@ -183,6 +183,17 @@ void Function::instr_iterator::operator++(void) {
}
void Function::print(ostream &os, bool print_header) const {
+ {
+ const auto &gvars = getGlobalVars();
+ if (!gvars.empty()) {
+ for (auto &v : gvars) {
+ v->print(os);
+ os << '\n';
+ }
+ os << '\n';
+ }
+ }
+
if (print_header) {
os << "define " << getType() << " @" << name << '(';
bool first = true;

MODIFY
ir/value.cpp
ir/value.cpp
@@ -78,7 +78,8 @@ StateValue NullPointerValue::toSMT(State &s) const {
void GlobalVariable::print(ostream &os) const {
- UNREACHABLE();
+ os << getName() << " = " << (isconst ? "constant " : "global ") << getType()
+ << ", align " << align;
}
StateValue GlobalVariable::toSMT(State &s) const {

print global variables when printing a function/transform