[Mlir-commits] [mlir] [MLIR][RemoveDeadValues] Mark arguments of a public function Live (PR #160242)

Andrew Luo llvmlistbot at llvm.org
Thu Sep 25 08:01:47 PDT 2025


================
@@ -376,6 +384,31 @@ static void processFuncOp(FunctionOpInterface funcOp, Operation *module,
   }
 }
 
+static void processCallOp(CallOpInterface callOp, Operation *module,
+                          RunLivenessAnalysis &la, DenseSet<Value> &liveSet) {
+  auto callable = callOp.getCallableForCallee();
+
+  if (auto symbolRef = callable.dyn_cast<SymbolRefAttr>()) {
+    Operation *calleeOp = SymbolTable::lookupSymbolIn(module, symbolRef);
+
+    if (auto funcOp =
+            llvm::dyn_cast_or_null<mlir::FunctionOpInterface>(calleeOp)) {
+      // Ensure the outgoing arguments of PUBLIC functions are live
+      // because processFuncOp can not process them.
+      //
+      // Liveness treats the external function as a blackbox.
+      if (funcOp.isPublic()) {
+        for (Value arg : callOp.getArgOperands()) {
+          const Liveness *liveness = la.getLiveness(arg);
+          if (liveness && !liveness->isLive) {
----------------
AndrewZhaoLuo wrote:

conservatively it seems we can just do 

`liveSet.insert(callOp.getArgOperands().begin(), callOp.getArgOperands().end())`

For now. I believe you gave some justification on why you might not want to do this so this is maybe ok if a follow up is quick.

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


More information about the Mlir-commits mailing list