This is an archive of the discontinued LLVM Phabricator instance.

[Inliner] Try to inline if some blocks in the callee have address taken, but not used in a meaningful.
Needs ReviewPublic

Authored by trentxintong on Jun 18 2018, 7:57 PM.

Details

Summary

This patch introduces the hasAddressTakenAndUsed() API for
BasicBlock and make use it in InlineCost and JumpThreading.

I can also split this into 2 patches, i.e. introduce
hasAddressTakenAndUsed() first and make InlineCost use it, then
rewrite Jumpthreading to use it in the second patch.

Diff Detail

Event Timeline

trentxintong created this revision.Jun 18 2018, 7:57 PM
trentxintong edited the summary of this revision. (Show Details)Jun 18 2018, 8:02 PM
trentxintong edited the summary of this revision. (Show Details)Jun 18 2018, 8:10 PM
trentxintong edited the summary of this revision. (Show Details)Jun 18 2018, 9:14 PM
trentxintong edited the summary of this revision. (Show Details)
davidxl added inline comments.Jul 13 2018, 11:43 AM
include/llvm/IR/BasicBlock.h
390

Perhaps change this to: Return true if the basic block address is taken and used by other instructions that can not be proved to be dead.

efriedma added inline comments.
include/llvm/IR/BasicBlock.h
391

Could we just replace hasAddressTaken() with this function? I don't think anything calling hasAddressTaken() actually cares if there are dead uses.

lib/IR/BasicBlock.cpp
446

Please use isConstantUsed instead; mutating the IR in a function named "hasAddressTakenAndUsed" is confusing.

trentxintong added inline comments.Jul 13 2018, 3:35 PM
include/llvm/IR/BasicBlock.h
390

Will do so.

391

I feel this is a good way to go.

However, I feel we still need an API to only check whether getSubclassDataFromValue() is 0 or not. This is needed because BlockAddress::lookup(const BasicBlock *BB) uses it for early exit. And there are other similar uses in the code base.

I feel we should keep hasAddressTaken() as it is now and make passes use hasAddressTakenAndUsed() because they do not actually cares if there are dead uses (I suspect most passes if not all).

lib/IR/BasicBlock.cpp
446

Will do so.

asbirlea resigned from this revision.Sep 15 2021, 12:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 15 2021, 12:29 PM