mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Coverage] Refactor SIL generation for profiling
This patch moves the ownership of profiling state from SILGenProfiling to SILFunction, where it always belonged. Similarly, it moves ownership of the profile reader from SILGenModule to SILModule. The refactor sets us up to fix a few outstanding code coverage bugs and does away with sad hacks like ProfilerRAII. It also allows us to locally guarantee that a profile counter increment actually corresponds to the SILFunction at hand. That local guarantee causes a bugfix to accidentally fall out of this refactor: we now set up the profiling state for delayed functions correctly. Previously, we would set up a ProfilerRAII for the delayed function, but its counter increment would never be emitted :(. This fix constitutes the only functional change in this patch -- the rest is NFC. As a follow-up, I plan on removing some dead code in the profiling logic and fixing a few naming inconsistencies. I've left that for later to keep this patch simple.
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
#include "llvm/ADT/PointerIntPair.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/ADT/ilist.h"
|
||||
#include "llvm/ProfileData/InstrProfReader.h"
|
||||
#include "llvm/Support/Allocator.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <functional>
|
||||
@@ -220,7 +221,10 @@ private:
|
||||
/// constructed. In certain cases this was before all Modules had been loaded
|
||||
/// causing us to not
|
||||
std::unique_ptr<SerializedSILLoader> SILLoader;
|
||||
|
||||
|
||||
/// The indexed profile data to be used for PGO, or nullptr.
|
||||
std::unique_ptr<llvm::IndexedInstrProfReader> PGOReader;
|
||||
|
||||
/// True if this SILModule really contains the whole module, i.e.
|
||||
/// optimizations can assume that they see the whole module.
|
||||
bool wholeModule;
|
||||
@@ -626,6 +630,12 @@ public:
|
||||
Stage = s;
|
||||
}
|
||||
|
||||
llvm::IndexedInstrProfReader *getPGOReader() const { return PGOReader.get(); }
|
||||
|
||||
void setPGOReader(std::unique_ptr<llvm::IndexedInstrProfReader> IPR) {
|
||||
PGOReader = std::move(IPR);
|
||||
}
|
||||
|
||||
/// \brief Run the SIL verifier to make sure that all Functions follow
|
||||
/// invariants.
|
||||
void verify() const;
|
||||
|
||||
Reference in New Issue
Block a user