[PATCH] D99240: [ConstantFolding] Look through local aliases when simplify GEPs

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 25 10:18:30 PDT 2021


aeubanks added a comment.

In D99240#2649567 <https://reviews.llvm.org/D99240#2649567>, @pcc wrote:

> Can you make it so that the load ends up being replaced with the loaded value, without replacing the GEP itself? That would seem to address the MSVC issue.

What's the benefit of that over this approach? We'd have to potentially end up doing the same thing for stores and maybe other places.



================
Comment at: llvm/lib/IR/Value.cpp:612-613
       V = cast<GlobalAlias>(V)->getAliasee();
+    } else if (StripKind == PSK_ZeroIndicesAndLocalAliases &&
+               isa<GlobalAlias>(V) && cast<GlobalAlias>(V)->hasLocalLinkage()) {
+      V = cast<GlobalAlias>(V)->getAliasee();
----------------
pcc wrote:
> rnk wrote:
> > I wonder if it would be safe to power up all of the other versions of pointer stripping to look through local aliases.
> I don't think we should. It wouldn't be safe to allow passes to replace `@alias` with `@aliasee` with this IR:
> ```
> @alias = internal alias @aliasee
> @aliasee = linkonce_odr global i32 42
> ```
> We should also avoid the QoI issue (missing symbol table entry) that would result from such replacement given this IR:
> ```
> @alias = internal alias @aliasee
> @aliasee = private global i32 42
> ```
Why is the first transform not safe?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99240



More information about the llvm-commits mailing list