[PATCH] D123283: [MC] Improve st_size propagation rule

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 7 16:43:29 PDT 2022


MaskRay added inline comments.


================
Comment at: llvm/lib/MC/ELFObjectWriter.cpp:558
+    // st_size for `z1 = z` but such chained assignments are rare.
+    if (Symbol.isVariable())
+      if (auto *Sym = dyn_cast<MCSymbolRefExpr>(Symbol.getVariableValue(false)))
----------------
peter.smith wrote:
> Would it be possible to follow the chain to get to the last non-zero size. This is assuming that in the case
> ```
> .size x, 2
> y = x
> .size y, 1
> z = y
> z1 = z
> ```
> `*Sym = dyn_cast<MCSymbolRefExpr>(Symbol.getVariableValue(false)` for z1 will give z
> and `Symbol.isVariable()` is true for `Sym`, in that case can we use another `if (auto *Sym = dyn_cast<MCSymbolRefExpr>(Symbol.getVariableValue(false))` to get to `y`, check that size is non zero and use that?
> 
> If this is possible I don't think it would be too much more complex.
Thanks for the suggestion. Adopted.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123283/new/

https://reviews.llvm.org/D123283



More information about the llvm-commits mailing list