[PATCH] D18763: [ThinLTO] Move summary computation from BitcodeWriter to new pass
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 7 22:18:43 PDT 2016
tejohnson added inline comments.
================
Comment at: lib/Analysis/ModuleSummaryAnalysis.cpp:144
@@ +143,3 @@
+ else if (F.getEntryCount().hasValue()) {
+ Function &Func = const_cast<Function &>(F);
+ LoopInfo LI{DominatorTree(Func)};
----------------
joker.eph wrote:
> tejohnson wrote:
> > joker.eph wrote:
> > > Why is this `const_cast` needed?
> > Because the BlockFrequencyInfo (or BranchProbabilityInfo, can't remember which one) takes a non-const F. When called through the pass the Module is not const. But when this class is constructed from llvm-as the Module is constant so the Module pointer is constant in the builder.
> Ok I update BFI upstream, but DomTree seems a lot more involved...
>
> You should be able to update to:
>
> ```
> LoopInfo LI{DominatorTree(const_cast<Function &>(F))};
> BranchProbabilityInfo BPI{F, LI};
> BFIPtr = llvm::make_unique<BlockFrequencyInfo>(F, BPI, LI);
> ```
Just saw that, thanks! Will do.
http://reviews.llvm.org/D18763
More information about the llvm-commits
mailing list