[llvm] [AMDGPU] Avoid resource propagation for recursion through multiple functions (PR #111004)
Janek van Oirschot via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 7 06:53:15 PDT 2024
================
@@ -91,13 +91,66 @@ MCSymbol *MCResourceInfo::getMaxSGPRSymbol(MCContext &OutContext) {
return OutContext.getOrCreateSymbol("amdgpu.max_num_sgpr");
}
+static bool findSymbolInExpr(MCSymbol *Sym, const MCExpr *Expr,
+ SmallVectorImpl<const MCExpr *> &Exprs) {
+ switch (Expr->getKind()) {
+ default:
+ return false;
+ case MCExpr::ExprKind::SymbolRef: {
+ const MCSymbolRefExpr *SymRefExpr = cast<MCSymbolRefExpr>(Expr);
+ const MCSymbol &SymRef = SymRefExpr->getSymbol();
+ if (Sym == &SymRef)
+ return true;
+ if (SymRef.isVariable())
+ Exprs.push_back(SymRef.getVariableValue(/*isUsed=*/false));
+ return false;
+ }
+ case MCExpr::ExprKind::Binary: {
+ const MCBinaryExpr *BExpr = cast<MCBinaryExpr>(Expr);
+ return findSymbolInExpr(Sym, BExpr->getLHS(), Exprs) ||
+ findSymbolInExpr(Sym, BExpr->getRHS(), Exprs);
----------------
JanekvO wrote:
Correct me if my interpretation of the comment is wrong but AFAIK, it cannot recurse locally within `findSymbolInExpr` as `Exprs` is only populated with Symbols that are assigned an MCExpr (which is what we're in the middle of doing for MCSymbol `Sym`).
https://github.com/llvm/llvm-project/pull/111004
More information about the llvm-commits
mailing list