Page MenuHomePhabricator

Improve internal StringSwitch code gen with Optional<T>
AbandonedPublic

Authored by davezarzycki on Feb 13 2018, 7:55 AM.

Details

Reviewers
doug.gregor
Summary

StringSwitch currently fakes Optional<T> by storing a pointer to the result. The problem with this approach is that it forces the compiler to store all case results on the stack before entering the string switch just so the address of the result can be temporarily used.

Diff Detail

Repository
rL LLVM

Event Timeline

davezarzycki created this revision.Feb 13 2018, 7:55 AM

Hi Doug! Looks like you created StringSwitch back in 2009. :-)

doug.gregor accepted this revision.Feb 13 2018, 12:04 PM

Heh, I was probably thinking that one might want to produce references, but I don’t anyone does. I do think it would be valuable to make the parameters “T value” instead of “const T value”, and std::move them into place when we find a match.

This revision is now accepted and ready to land.Feb 13 2018, 12:04 PM

Thanks for the feedback Doug. I can certainly make the std::move change. Separately and to the best of my knowledge, I don't have commit privileges to LLVM proper, so somebody else will need to merge this. Thanks :-)

Made requested changes by Doug

davezarzycki abandoned this revision.Feb 26 2018, 10:47 AM