summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2014-02-05 20:40:15 +0000
committerManman Ren <manman.ren@gmail.com>2014-02-05 20:40:15 +0000
commit67a28136ad7b54e4d188d903dd9ff86a05f7e74f (patch)
tree361313a8add4bfa1e80be5c229c30e331931bf24 /clang/lib/CodeGen/CodeGenFunction.cpp
parentefefe5e22522b6f8f5c4e1fd52d2b190de51db8e (diff)
downloadbcm5719-llvm-67a28136ad7b54e4d188d903dd9ff86a05f7e74f.tar.gz
bcm5719-llvm-67a28136ad7b54e4d188d903dd9ff86a05f7e74f.zip
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. llvm-svn: 200874
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 7d451e8f6d0..c0b4d8926a9 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/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.
OpenPOWER on IntegriCloud