[Mlir-commits] [mlir] Add a null pointer check in symbol lookup (PR #115165)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Nov 6 06:52:44 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Shlomi Regev (shlmregev)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/115165.diff


1 Files Affected:

- (modified) mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp (+2) 


``````````diff
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());
     }

``````````

</details>


https://github.com/llvm/llvm-project/pull/115165


More information about the Mlir-commits mailing list