[PATCH] D101100: [ConstFold] Simplify a load's GEP operand through local aliases

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 4 17:59:34 PDT 2021


aeubanks added inline comments.


================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:877
+    while (isa<GlobalAlias>(Ptr) && !cast<GlobalAlias>(Ptr)->isInterposable() &&
+           !cast<GlobalAlias>(Ptr)->getBaseObject()->isInterposable()) {
+      Ptr = cast<GlobalAlias>(Ptr)->getAliasee();
----------------
nikic wrote:
> This code uses a different check than the top-level case (https://github.com/llvm/llvm-project/blob/26223af256bb8f0aa1a82989882c81ffae44c6d1/llvm/lib/Analysis/ConstantFolding.cpp#L682-L684). Namely it also checks that the base object is not interposable. What's the reason for the difference? I'd expect both of them to use the same conditions.
See the discussions in https://reviews.llvm.org/D99240, https://reviews.llvm.org/D65118, https://bugs.llvm.org/show_bug.cgi?id=27866.

I keep getting confused by these explanations. But as I understand it right now, we are only allowed to replace an alias with its aliasee if both are not interposable (but we may not want to do this anyway). However, we can look through an alias to get the aliasee's contents if the alias is not interposable. So this patch is probably overly restrictive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101100



More information about the llvm-commits mailing list