I've been working on some patches which add basic support for PGO to swift .
What I have so far is just a proof-of-concept. I'd like to get some feedback on
the approach I've taken.
I've added support for loading profile data, matching up execution counts to
the right parts of the AST, and attaching those execution counts to conditional
branches. I added two fields to CondBranchInst (in SIL):
/// The number of times the True branch was executed.
/// The number of times the False branch was executed.
I fixed up the SILCloner and a few other sites where conditional branches are
created to propagate the branch taken counts. I have a patch to propagate
branch taken counts through the SILOptimizer, but I didn't include it in 
because I don't know how to write tests for it.
In IRGen, I added some logic to scale execution counts and create llvm
1. Is it acceptable to make some SIL objects larger in order to store
execution counts (e.g CondBranchInst)? If not, what's the best way to make
this information visible to SILOptimizer and IRGen?
2. Is it better to associate counts with SIL instructions, or with
3. Does anyone have tips on modifying swift/benchmark? I'd like to add a
benchmark driver which generates profile data, and another driver which
uses that data to turn on PGO.