[Mlir-commits] [mlir] 1331750 - [mlir] Add a null pointer check in symbol lookup (#115165)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Nov 12 14:31:28 PST 2024
Author: Shlomi Regev
Date: 2024-11-12T23:31:25+01:00
New Revision: 13317502da8ee3885854f67700140586c0edafee
URL: https://github.com/llvm/llvm-project/commit/13317502da8ee3885854f67700140586c0edafee
DIFF: https://github.com/llvm/llvm-project/commit/13317502da8ee3885854f67700140586c0edafee.diff
LOG: [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.
Added:
Modified:
mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp
mlir/test/Analysis/DataFlow/test-dead-code-analysis.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp b/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp
index 3c190d4e991919..e805e21d878bf9 100644
--- a/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp
@@ -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());
}
diff --git a/mlir/test/Analysis/DataFlow/test-dead-code-analysis.mlir b/mlir/test/Analysis/DataFlow/test-dead-code-analysis.mlir
index 70becc72beb96a..1ae68553515067 100644
--- a/mlir/test/Analysis/DataFlow/test-dead-code-analysis.mlir
+++ b/mlir/test/Analysis/DataFlow/test-dead-code-analysis.mlir
@@ -265,3 +265,7 @@ func.func @test_dca_doesnt_crash() -> () {
}
return
}
+
+func.func @test_dca_doesnt_crash_2() -> () attributes {symbol = @notexistant} {
+ return
+}
More information about the Mlir-commits
mailing list