This is an archive of the discontinued LLVM Phabricator instance.

[LazyValueInfo] Avoid unnecessary copies of ConstantRanges
ClosedPublic

Authored by craig.topper on May 4 2017, 3:35 PM.

Details

Summary

ConstantRange contains two APInts which can allocate memory if their width is larger than 64-bits. So we shouldn't copy it when we can avoid it.

This changes LVILatticeVal::getConstantRange() to return its internal ConstantRange by reference. This allows many places that just need a ConstantRange reference to avoid making a copy.

Several places now capture the return value of getConstantRange() by reference so they can call methods on it that don't need a new object.

Lastly it adds std::move in one place to capture to move a local ConstantRange into an LVILatticeVal.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.May 4 2017, 3:35 PM

if anyone is interested, I wrote a clang plugin for the LibreOffice codebase to find methods that can return a const ref.

Make a big reference to some of our code.

https://cgit.freedesktop.org/libreoffice/core/tree/compilerplugins/clang/store/returnbyref.cxx

Note that the output of this plugin is not 100% perfect, needs manual confirmation

reames accepted this revision.May 5 2017, 6:11 PM

LGTM

This revision is now accepted and ready to land.May 5 2017, 6:11 PM
This revision was automatically updated to reflect the committed changes.