llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.85k stars 11.91k forks source link

implement gcc's Wsuggest-final incl. fixit hints #30939

Open Trass3r opened 7 years ago

Trass3r commented 7 years ago
Bugzilla Link 31591
Version unspecified
OS All
CC @DougGregor

Extended Description

Original patch: https://gcc.gnu.org/ml/gcc-patches/2014-08/msg00119.html

Explained in detail here: http://hubicka.blogspot.ch/2014/08/devirtualization-in-c-part-5-asking.html

Marking certain types final manually had significant performance impact on our code.

Trass3r commented 7 years ago

A function of interest is CodeGenFunction::CanDevirtualizeMemberFunctionCall.

// If that method is marked final, we can devirtualize it. if (DevirtualizedMethod->hasAttr()) return true;

// Similarly, if the class itself is marked 'final' it can't be overridden // and we can therefore devirtualize the member function call. if (BestDynamicDecl->hasAttr()) return true;