This is an archive of the discontinued LLVM Phabricator instance.

[TargetTransformInfo] Static alloca has 0 cost
ClosedPublic

Authored by Carrot on Sep 14 2017, 5:32 PM.

Details

Summary

Static alloca usually doesn't generate any machine instructions, so it has 0 cost.

Diff Detail

Event Timeline

Carrot created this revision.Sep 14 2017, 5:32 PM
arsenm added a subscriber: arsenm.Sep 14 2017, 5:36 PM

Maybe should be if it is a statically sized alloca

hfinkel added inline comments.Sep 14 2017, 6:12 PM
include/llvm/Analysis/TargetTransformInfoImpl.h
743

This needs a comment. Also, I think this is only true for static allocas. Dynamic ones will still have a cost. Maybe this should be:

if (auto *A = dyn_cast<AllocaInst>(U))
  if (A->isStaticAlloca())
    return TTI::TTC_Free;
Carrot updated this revision to Diff 115429.Sep 15 2017, 11:12 AM
Carrot marked an inline comment as done.
Carrot retitled this revision from [TargetTransformInfo] Instruction alloca has 0 cost to [TargetTransformInfo] Static alloca has 0 cost.
Carrot edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Sep 15 2017, 11:16 AM
This revision was automatically updated to reflect the committed changes.