summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenPGO.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2017-06-30 21:02:14 +0000
committerVedant Kumar <vsk@apple.com>2017-06-30 21:02:14 +0000
commit33d0a1ccd31dd10f227cba98e3daa4561b41ad71 (patch)
tree049a7268c67047ccbbe78564d22fd5a33252bf65 /clang/lib/CodeGen/CodeGenPGO.cpp
parentc4ad41385374cfbd89bd1b4f2b0198029f472c4d (diff)
downloadbcm5719-llvm-33d0a1ccd31dd10f227cba98e3daa4561b41ad71.tar.gz
bcm5719-llvm-33d0a1ccd31dd10f227cba98e3daa4561b41ad71.zip
[Profile] Do not assign counters to functions without bodies
The root cause of the issues reported in D32406 and D34680 is that clang instruments functions without bodies. Make it stop doing that, and also teach it how to use old (incorrectly generated) profiles without crashing. llvm-svn: 306883
Diffstat (limited to 'clang/lib/CodeGen/CodeGenPGO.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenPGO.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index 9e193531d0f..c3d66c1dabc 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -617,6 +617,9 @@ uint64_t PGOHash::finalize() {
void CodeGenPGO::assignRegionCounters(GlobalDecl GD, llvm::Function *Fn) {
const Decl *D = GD.getDecl();
+ if (!D->hasBody())
+ return;
+
bool InstrumentRegions = CGM.getCodeGenOpts().hasProfileClangInstr();
llvm::IndexedInstrProfReader *PGOReader = CGM.getPGOReader();
if (!InstrumentRegions && !PGOReader)
OpenPOWER on IntegriCloud