This is an archive of the discontinued LLVM Phabricator instance.

[clang/Sema] Follow-up for fix of non-deterministic order of `-Wunused-variable` diagnostic
ClosedPublic

Authored by akyrtzi on Oct 7 2022, 2:31 PM.

Details

Summary

Commit 371883f46dc23f8464cbf578e2d12a4f92e61917 caused a noticeable compile-time regression (about 0.4% geomean at -O0):
http://llvm-compile-time-tracker.com/compare.php?from=92233159035d1b50face95d886901cf99035bd99&to=371883f46dc23f8464cbf578e2d12a4f92e61917&stat=instructions

To address this switch Scope::DeclSetTy back to a SmallPtrSet and change Sema::ActOnPopScope to explicitly order the diagnostics that this function emits.

Diff Detail

Event Timeline

akyrtzi created this revision.Oct 7 2022, 2:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 7 2022, 2:31 PM
Herald added a subscriber: mgrang. · View Herald Transcript
akyrtzi requested review of this revision.Oct 7 2022, 2:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 7 2022, 2:31 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

I don't know too much about this. I guess have a DiagReceiver to force the emitting order is a good thing but it is kind of weird to have this just for unused warning.

I am guessing my suspect of removing decl from the scope is the cause of the slow down. Maybe we just force order on iteration?

clang/include/clang/Sema/Scope.h
310

I wonder if it would be easy if you just sort here and provide a consistent ordering when iterating?

I don't know too much about this. I guess have a DiagReceiver to force the emitting order is a good thing but it is kind of weird to have this just for unused warning.

I am guessing my suspect of removing decl from the scope is the cause of the slow down. Maybe we just force order on iteration?

Ordering the decls every time ActOnPopScope is called is not cheap; ordering only the diagnostics (if any is emitted) is the most efficient way I could find.

steven_wu accepted this revision.Oct 11 2022, 10:42 AM

Ok with me

This revision is now accepted and ready to land.Oct 11 2022, 10:42 AM