This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Inline callee if its target-features are a subset of the caller
ClosedPublic

Authored by fhahn on Jun 27 2017, 9:33 AM.

Details

Summary

Similar to X86, it should be safe to inline callees if their
target-features are a subset of the caller. As some subtarget features
provide different instructions depending on whether they are set or
unset (e.g. ThumbMode and ModeSoftFloat), we use a whitelist of
target-features describing hardware capabilities only.

Diff Detail

Event Timeline

fhahn created this revision.Jun 27 2017, 9:33 AM

Ping, any thoughts on this? I committed a similar patch for AArch64 recently (D34698).

SjoerdMeijer accepted this revision.Jul 5 2017, 8:50 AM

This looks like a straight forward and sensible implementation of a target hook to me. But before committing, perhaps someone with more inlining experience than me can have a quick look as well.

This revision is now accepted and ready to land.Jul 5 2017, 8:50 AM
fhahn added a comment.Jul 6 2017, 9:02 AM

Thanks Sjoerd! I'll hold of committing this until tomorrow so people in other timezones can voice concerns.

efriedma added inline comments.
lib/Target/ARM/ARMTargetTransformInfo.cpp
31

Are you sure ModeThumb is the only feature we need to check for? ModeSoftFloat in particular seems suspicious: VFP intrinsics in the callee could fail to compile. (I'd be much happier if we were whitelisting features; I'm afraid of missing something.)

fhahn updated this revision to Diff 106044.Jul 11 2017, 9:06 AM

Use whitelist, excludes ModeThumb, ModeSoftFloat and FeatureNoARM.

fhahn added inline comments.Jul 11 2017, 9:10 AM
lib/Target/ARM/ARMTargetTransformInfo.cpp
31

Thanks for pointing out ModeSoftFloat, which behaves similar to ModeThumb. They both force different modes, with different instructions available, depending whether they are set or unset.

I think ideally they shouldn't be subtarget features, as my understanding was that subtarget features should only provide additional capabilities/instructions when they are enabled. But I guess that would a far bigger change and a whitelist should be fine for now.

efriedma accepted this revision.Jul 11 2017, 11:40 AM
efriedma added inline comments.
lib/Target/ARM/ARMTargetTransformInfo.cpp
34

ARM::FeatureD16 and FeatureVFPOnlySP are also suspicious... not because they're different modes, but because having the feature enabled does the opposite of what you would expect.

fhahn updated this revision to Diff 106175.Jul 12 2017, 4:51 AM
fhahn edited the summary of this revision. (Show Details)

Removed FeatureD16 and FeatureVFPOnlySP from the whitelist, thanks again @efriedma . I've also moved the whitelist to ARMTargetTransformInfo::InlineFeatureWhitelist so it does only get instantiated once.

I'll hold off committing this until tomorrow, to give people a chance to raise concerns with moving the whitelist to a member variable in ARMTargetTransformInfo.

fhahn closed this revision.Jul 13 2017, 1:26 AM