[llvm] [AMDGPU] Avoid resource propagation for recursion through multiple functions (PR #111004)
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 09:10:37 PDT 2024
================
@@ -91,13 +91,75 @@ MCSymbol *MCResourceInfo::getMaxSGPRSymbol(MCContext &OutContext) {
return OutContext.getOrCreateSymbol("amdgpu.max_num_sgpr");
}
+// The (partially complete) expression should have no recursion in it. After
+// all, we're trying to avoid recursion using this codepath.
+static bool findSymbolInExpr(MCSymbol *Sym, const MCExpr *Expr,
+ SmallVectorImpl<const MCExpr *> &Exprs,
+ SmallPtrSetImpl<const MCExpr *> &Visited) {
+ // Assert if any of the expressions is already visited (i.e., there is
+ // existing recursion).
+ if (!Visited.insert(Expr).second)
----------------
jhuber6 wrote:
I guess the compiler will optimize out the unused variable if `llvm_unreachable` is a no-op. Guess it's
```c++
if (!Visited.insert(Expr).second)
llvm_unreachable("already visited expression");
```
vs
```c++
[[maybe_unused]] bool AlreadyVisited = Visited.insert(Expr).second;
assert(!AlreadyVisited && "already visited expression");
```
Roughly equivalent so I guess it's up to taste.
https://github.com/llvm/llvm-project/pull/111004
More information about the llvm-commits
mailing list