This is an archive of the discontinued LLVM Phabricator instance.

[AST] Store the value of CharacterLiteral in the bit-fields of Stmt if possible
AbandonedPublic

Authored by riccibruno on Nov 9 2018, 8:51 AM.

Details

Reviewers
rsmith
shafik
Summary

The vast majority of CharacterLiterals have a value which fits into 8 bits
(in the 2666 CharacterLiterals in all of Boost, only 2 don't).
When possible, use the space in the bit-fields of Stmt to store the value
and otherwise store it in a trailing object.

This saves 1 pointer per CharacterLiteral when the value fits into 8 bits.

Note that in itself this do not save that much space, but this is part of
a larger effort to pack the statements/expressions classes.

Diff Detail

Repository
rC Clang

Event Timeline

riccibruno created this revision.Nov 9 2018, 8:51 AM
riccibruno retitled this revision from [AST] Store the value of CharacterLiteral inline if possible to [AST] Store the value of CharacterLiteral in the bit-fields of Stmt if possible.Nov 12 2018, 4:33 AM
shafik added inline comments.Nov 12 2018, 12:50 PM
include/clang/AST/Expr.h
1407

Minor comment, does it make sense to covert this to a scoped enum since it looks like it is being strictly used as a set of values.

riccibruno added inline comments.Nov 12 2018, 1:03 PM
include/clang/AST/Expr.h
1407

Does it really add anything ?
It means that instead of writing CharacterLiteral::UTF32
you have to write CharacterLiteral::CharacterKind::UTF32

Seems a bit verbose. But I don't have any strong opinion on this.

shafik added inline comments.Nov 15 2018, 10:14 AM
include/clang/AST/Expr.h
1407

It adds the protection against unintended conversions to and from the scoped enum, which in general is a good thing. The other benefits is not having the enumerators leak out into the surrounding scope but is limited in this case.

It does add verbosity though.

riccibruno planned changes to this revision.Nov 19 2018, 8:26 AM
riccibruno abandoned this revision.Jan 18 2019, 8:06 AM

This is not worth doing.