Kill the id-to-func map after wrap-opkill (#3055)

Wrap-opkill will create a new function, invalidating the id-to-func map.
The preserved analyses for the pass have been updated to reflect that.

Also adding consistency check for the id-to-func map.  With this new
check, old tests identify this problem.  No new tests are needed.

Fixes #3038
This commit is contained in:
Steven Perron 2019-11-19 09:44:53 -05:00 committed by GitHub
parent 57b4cb40b2
commit ca703c8877
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -273,6 +273,14 @@ bool IRContext::IsConsistent() {
}
}
if (AreAnalysesValid(kAnalysisIdToFuncMapping)) {
for (auto& fn : *module_) {
if (id_to_func_[fn.result_id()] != &fn) {
return false;
}
}
}
if (AreAnalysesValid(kAnalysisInstrToBlockMapping)) {
for (auto& func : *module()) {
for (auto& block : func) {
@ -818,6 +826,7 @@ bool IRContext::ProcessCallTreeFromRoots(ProcessFunction& pfn,
roots->pop();
if (done.insert(fi).second) {
Function* fn = GetFunction(fi);
assert(fn && "Trying to process a function that does not exist.");
modified = pfn(fn) || modified;
AddCalls(fn, roots);
}

View File

@ -34,8 +34,7 @@ class WrapOpKill : public Pass {
IRContext::kAnalysisInstrToBlockMapping |
IRContext::kAnalysisDecorations | IRContext::kAnalysisCombinators |
IRContext::kAnalysisNameMap | IRContext::kAnalysisBuiltinVarId |
IRContext::kAnalysisIdToFuncMapping | IRContext::kAnalysisConstants |
IRContext::kAnalysisTypes;
IRContext::kAnalysisConstants | IRContext::kAnalysisTypes;
}
private: