[PATCH] D29781: Add alias canonicalization pass when preparing for ThinLTO
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 15 13:28:39 PST 2017
On Mon, Feb 13, 2017 at 5:04 PM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:
> > +/// Check if the given user is an alias (looking through bit casts).
> > +static bool userIsAlias(Value *V) {
> > + if (isa<GlobalAlias>(V))
> > + return true;
> > + if (BitCastOperator *BC = dyn_cast<BitCastOperator>(V)) {
> > + for (Use &U : BC->materialized_uses()) {
> > + return userIsAlias(U.getUser());
>
> Using a for that always returns in the first iteration looks a bit odd
> IMHO.
>
Mehdi pointed that out too - will change to assert that there is a single
use without a loop.
>
> > +/// Like replaceAllUsesWith but doesn't replace any uses that are
> > +/// aliases, so that we can just replace uses of the original value
> > +/// with the new private aliasee, but keep the original value name
> > +/// as an alias to it.
> > +static void replaceAllUsesWithExceptAliases(Value *Old, Value *New) {
>
> When first reading the code I got the impression that this would convert
>
> @foo = weak alias @bar
>
> ....
> call @foo
> ...
>
> into calling @bar directly. Please add that to the test to show that it
> is not the case. In fact, I think a good test would be
>
> @bar = global...
> @foo = alias @bar
>
> ...
> use @bar
> ...
> use @foo
>
> and check that we still have a use of @bar and a use of @foo, but now
> @bar and @foo are an alias to a private global.
>
Enhanced the existing test to check that existing references (not from
alias definition) are not renamed. Will upload when I upload the other
fixes.
>
> > +
> > + // Don't make malformed IR (will be caught by verifier) worse.
> > + if (GO->isDeclarationForLinker())
> > + continue;
>
> When is a pass expected to be run on malformed IR?
>
I hit this in a test case. If I don't add this then the test was asserting
somewhere instead of hitting the expected verification error.
Thanks,
Teresa
>
> Cheers,
> Rafael
>
--
Teresa Johnson | Software Engineer | tejohnson at google.com | 408-460-2413
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170215/049971a0/attachment.html>
More information about the llvm-commits
mailing list