[mlir] Add a null pointer check in symbol lookup (#115165)

Dead code analysis crashed because a symbol that is called/used didn't appear in the symbol
table. 
This patch fixes this by adding a nullptr check after symbol table lookup.
This commit is contained in:
Shlomi Regev 2024-11-12 22:31:25 +00:00 committed by GitHub
parent 5a5122cac6
commit 13317502da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -186,6 +186,8 @@ void DeadCodeAnalysis::initializeSymbolCallables(Operation *top) {
// If a callable symbol has a non-call use, then we can't be guaranteed to
// know all callsites.
Operation *symbol = symbolTable.lookupSymbolIn(top, use.getSymbolRef());
if (!symbol)
continue;
auto *state = getOrCreate<PredecessorState>(getProgramPointAfter(symbol));
propagateIfChanged(state, state->setHasUnknownPredecessors());
}

View File

@ -265,3 +265,7 @@ func.func @test_dca_doesnt_crash() -> () {
}
return
}
func.func @test_dca_doesnt_crash_2() -> () attributes {symbol = @notexistant} {
return
}