Page MenuHomePhabricator

Constant folding support for load from GlobalAlias
ClosedPublic

Authored by andrew.zhogin on Jul 17 2015, 1:01 PM.

Details

Summary

Clang generates alias for getelementptr for vtable access. But the function ConstantFoldLoadFromConstPtr fails for GlobalAlias. It breaks devirtualization even in simple cases.
This patch fixes the problem.

Devirtualization fails only for MicrosoftCXXABI because it generates aliases for vtable access.

Problem was found during investigation of https://llvm.org/bugs/show_bug.cgi?id=20801.

Event Timeline

andrew.zhogin retitled this revision from to Constant folding support for load from GlobalAlias.
andrew.zhogin updated this object.
andrew.zhogin added a reviewer: majnemer.
andrew.zhogin added a subscriber: zinovy.nis.
andrew.zhogin added a subscriber: llvm-commits.
asl added a subscriber: asl.Jul 17 2015, 4:03 PM
majnemer accepted this revision.Jul 17 2015, 4:14 PM
majnemer edited edge metadata.

LGTM

lib/Analysis/ConstantFolding.cpp
535 ↗(On Diff #30050)

You can use auto for the LHS.

535–538 ↗(On Diff #30050)

No need for the braces.

This revision is now accepted and ready to land.Jul 17 2015, 4:14 PM
andrew.zhogin edited edge metadata.

Addressed the review comments.

andrew.zhogin marked 2 inline comments as done.Jul 17 2015, 4:49 PM

I don't have commit access so could you please commit the patch?

Ping. Could someone please commit approved patch?

This revision was automatically updated to reflect the committed changes.