Refactor PGO code in preparation for handling non-C/C++ code.
Move the PGO.assignRegionCounters() call out of StartFunction, because that
function is called from many places where it does not make sense to do PGO
instrumentation (e.g., compiler-generated helper functions). Change several
functions to take a StringRef argument for the unique name associated with
a function, so that the name can be set differently for things like Objective-C
methods and block literals.
llvm-svn: 203073
diff --git a/clang/lib/CodeGen/CodeGenPGO.h b/clang/lib/CodeGen/CodeGenPGO.h
index 5f7da4c..6af25b42 100644
--- a/clang/lib/CodeGen/CodeGenPGO.h
+++ b/clang/lib/CodeGen/CodeGenPGO.h
@@ -118,9 +118,9 @@
/// function. Does nothing if instrumentation is not enabled and either
/// generates global variables or associates PGO data with each of the
/// counters depending on whether we are generating or using instrumentation.
- void assignRegionCounters(GlobalDecl &GD);
+ void assignRegionCounters(const Decl *D, StringRef Name);
/// Emit code to write counts for a given function to disk, if necessary.
- void emitWriteoutFunction(GlobalDecl &GD);
+ void emitWriteoutFunction(StringRef Name);
/// Clean up region counter state. Must be called if assignRegionCounters is
/// used.
void destroyRegionCounters();
@@ -131,7 +131,7 @@
private:
void mapRegionCounters(const Decl *D);
void computeRegionCounts(const Decl *D);
- void loadRegionCounts(GlobalDecl &GD, PGOProfileData *PGOData);
+ void loadRegionCounts(StringRef Name, PGOProfileData *PGOData);
void emitCounterVariables();
/// Emit code to increment the counter at the given index