This is an archive of the discontinued LLVM Phabricator instance.

Make static constructors + destructors minsize + cold (except for in -O0)
Needs ReviewPublic

Authored by paquette on Mar 18 2019, 1:28 PM.

Details

Reviewers
rsmith
jyknight
Summary

Since these are only ever run once, they can be marked as cold. On top of that, since they're only ever run once, they might as well be minsize.

I observed a 0.21% code size improvement in a standard release build of clang for x86 with this change.

Diff Detail

Event Timeline

paquette created this revision.Mar 18 2019, 1:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 18 2019, 1:28 PM
lebedev.ri added inline comments.
clang/test/CodeGen/static-attr.cpp
5

This is fragile, it may have false-negative if they appear in other order.

Looks reasonable to me.

clang/test/CodeGen/static-attr.cpp
5

I think we guarantee it's emitted in the same order, but it's certainly the case that nobody will ever notice if this is failing to fail the test, if other attributes get emitted in between in the future.

You can use 3 separate WITHOUT-NOT lines, instead, to avoid both of this kind of issue.

paquette updated this revision to Diff 196085.Apr 22 2019, 10:01 AM

Made the test less fragile by splitting the WITHOUT-NOT into three lines.

(Thanks for the suggestion!)