diff --git a/src/script_opt/ProfileFunc.cc b/src/script_opt/ProfileFunc.cc index 6d4072473c..7b1d421d03 100644 --- a/src/script_opt/ProfileFunc.cc +++ b/src/script_opt/ProfileFunc.cc @@ -522,11 +522,10 @@ void ProfileFunc::TrackID(const ID* id) { // Already tracked. return; - if ( id->IsGlobal() ) - { - globals.insert(id); - all_globals.insert(id); - } + if ( id->IsGlobal() ) { + globals.insert(id); + all_globals.insert(id); + } ordered_ids.push_back(id); } diff --git a/src/script_opt/ZAM/ZBody.cc b/src/script_opt/ZAM/ZBody.cc index 03677d9d42..3c751fa47c 100644 --- a/src/script_opt/ZAM/ZBody.cc +++ b/src/script_opt/ZAM/ZBody.cc @@ -591,6 +591,11 @@ TraversalCode ZBody::Traverse(TraversalCallback* cb) const { TraversalCode tc = cb->PreStmt(this); HANDLE_TC_STMT_PRE(tc); + for ( auto& gi : globals ) { + tc = gi.id->Traverse(cb); + HANDLE_TC_STMT_PRE(tc); + } + for ( size_t i = 0; i < NumInsts(); ++i ) { tc = insts[i].Traverse(cb); HANDLE_TC_STMT_PRE(tc);