diff options
| author | Manman Ren <manman.ren@gmail.com> | 2014-02-05 20:40:15 +0000 |
|---|---|---|
| committer | Manman Ren <manman.ren@gmail.com> | 2014-02-05 20:40:15 +0000 |
| commit | 94328b6925a1710ccdc18c7053af3ffd39a26d79 (patch) | |
| tree | 1fdd4f2b38ef7a69b212496708c928681faa83cf /lib/CodeGen/CodeGenFunction.cpp | |
| parent | cf956c43e15b4860922b242785417fcb34afb5af (diff) | |
| download | clang-94328b6925a1710ccdc18c7053af3ffd39a26d79.tar.gz clang-94328b6925a1710ccdc18c7053af3ffd39a26d79.tar.bz2 clang-94328b6925a1710ccdc18c7053af3ffd39a26d79.tar.xz | |
PGO: instrumentation based profiling sets function attributes.
We collect a maximal function count among all functions in the pgo data file.
For functions that are hot, we set its InlineHint attribute. For functions that
are cold, we set its Cold attribute.
We currently treat functions with >= 30% of the maximal function count as hot
and functions with <= 1% of the maximal function count are treated as cold.
These two numbers are from preliminary tuning on SPEC.
This commit should not affect non-PGO builds and should boost performance on
instrumentation based PGO.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200874 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
| -rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 7d451e8f6d..c0b4d8926a 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -591,6 +591,16 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, EmitMCountInstrumentation(); PGO.assignRegionCounters(GD); + if (CGM.getPGOData()) { + if (const Decl *D = GD.getDecl()) { + // Turn on InlineHint attribute for hot functions. + if (CGM.getPGOData()->isHotFunction(CGM.getMangledName(GD))) + Fn->addFnAttr(llvm::Attribute::InlineHint); + // Turn on Cold attribute for cold functions. + else if (CGM.getPGOData()->isColdFunction(CGM.getMangledName(GD))) + Fn->addFnAttr(llvm::Attribute::Cold); + } + } if (RetTy->isVoidType()) { // Void type; nothing to return. |
