This is an archive of the discontinued LLVM Phabricator instance.

[CallPromotionUtils] Add tryPromoteCall.
ClosedPublic

Authored by hjyamauchi on Dec 10 2019, 3:25 PM.

Details

Summary

It attempts to devirtualize a call on alloca through vtable loads.

Event Timeline

hjyamauchi created this revision.Dec 10 2019, 3:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 10 2019, 3:25 PM

This is split off of D69591.

davidxl added inline comments.Jan 9 2020, 12:22 PM
llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
476

nit: VTableLoad --> VTablePointerLoad

489

VTable --> VTablePtr

508

Is this possible?

hjyamauchi marked 4 inline comments as done.

Address comments and rebase.

llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
508

I think so. It's possible that some ill-formed vtable or the entry contains a null (function) pointer.

davidxl accepted this revision.Jan 16 2020, 3:09 PM

lgtm

This revision is now accepted and ready to land.Jan 16 2020, 3:09 PM

This depends on D71307 and wouldn't work without it. Can you take a look at that again?

davidxl added inline comments.Jan 30 2020, 2:14 PM
llvm/unittests/Transforms/Utils/CallPromotionUtilsTest.cpp
37

Can you also add a negative test case?

hjyamauchi marked an inline comment as done.

Address comment.

Add negative tests.

Also add a new test is derived from
clang/test/CodeGenCXX/member-function-pointer-calls.cpp which this change
combined with D69591 enables nice inlining/simplification.

This revision was automatically updated to reflect the committed changes.