This is an archive of the discontinued LLVM Phabricator instance.

ParsedAttrInfo: Change spelling to use StringRef instead of const char*
Needs ReviewPublic

Authored by biasmv on Jul 8 2020, 8:55 AM.

Details

Summary

Store available spellings for attributes as a StringRef instead of a naked const char*. On my machine, this seems to be slightly beneficial for compile times on CTMark. Compilations were executed 10x with and without the change

Program                          const char* StringRef   diff

    CTMark/sqlite3/sqlite3.test     0.91        0.90    -0.7%
  typeset/consumer-typeset.test     2.79        2.77    -0.5%
    CTMark/ClamAV/clamscan.test     3.86        3.85    -0.3%
TMark/mafft/pairlocalalign.test     1.47        1.46    -0.2%
      CTMark/Bullet/bullet.test    21.75       21.73    -0.1%
 ark/tramp3d-v4/tramp3d-v4.test    18.17       18.19     0.1%
        CTMark/SPASS/SPASS.test     3.55        3.55    -0.1%
      CTMark/lencod/lencod.test     2.80        2.80    -0.1%
 TMark/7zip/7zip-benchmark.test    31.91       31.94     0.1%
       CTMark/kimwitu++/kc.test    11.45       11.45    -0.1%
 Geomean difference                                     -0.2%

Diff Detail

Event Timeline

biasmv created this revision.Jul 8 2020, 8:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2020, 8:55 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
nikic added a comment.Jul 8 2020, 11:49 AM

This change looks reasonable to me in terms of coding style, however I'm not seeing any compile-time changes in terms of instructions retired myself (https://llvm-compile-time-tracker.com/compare.php?from=8691544a276744474ff04b71d7e220069435c7fe&to=75b126ecf7b5a0ce8c04cb46c37b66233854e931&stat=instructions).

I think the change is safe to make, but I'm slightly uncomfortable with it because storing a StringRef is a somewhat questionable practice given that it's non-owning and it has converting constructors from dangerous types like std::string.