[Mlir-commits] [mlir] Add a null pointer check in symbol lookup (PR #115165)
Shlomi Regev
llvmlistbot at llvm.org
Wed Nov 6 06:51:52 PST 2024
https://github.com/shlmregev created https://github.com/llvm/llvm-project/pull/115165
We (TensorFlow project) ran into a case where a dead code analysis crashed because a symbol that is called/used didn't appear in the symbol table. Added a nullptr check after symbol table lookup.
>From 18eed3a68d30fdf6b738ce1562cf3edaf85f2c92 Mon Sep 17 00:00:00 2001
From: Shlomi Regev <regevs at google.com>
Date: Wed, 6 Nov 2024 14:43:22 +0000
Subject: [PATCH] Add a null pointer check in symbol lookup
We (TensorFlow project) ran into a case where a dead code analysis
crashed because a symbol that is called/used didn't appear in the symbol
table. Added a nullptr check after symbol table lookup.
---
mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp | 2 ++
1 file changed, 2 insertions(+)
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());
}
More information about the Mlir-commits
mailing list