diff --git a/llvm/lib/Transforms/Instrumentation/CFGMST.h b/llvm/lib/Transforms/Instrumentation/CFGMST.h --- a/llvm/lib/Transforms/Instrumentation/CFGMST.h +++ b/llvm/lib/Transforms/Instrumentation/CFGMST.h @@ -100,7 +100,7 @@ void buildEdges() { LLVM_DEBUG(dbgs() << "Build Edge on " << F.getName() << "\n"); - const BasicBlock *Entry = &(F.getEntryBlock()); + BasicBlock *Entry = &(F.getEntryBlock()); uint64_t EntryWeight = (BFI != nullptr ? BFI->getEntryFreq() : 2); // If we want to instrument the entry count, lower the weight to 0. if (InstrumentFuncEntry) @@ -257,7 +257,7 @@ } // Add an edge to AllEdges with weight W. - Edge &addEdge(const BasicBlock *Src, const BasicBlock *Dest, uint64_t W) { + Edge &addEdge(BasicBlock *Src, BasicBlock *Dest, uint64_t W) { uint32_t Index = BBInfos.size(); auto Iter = BBInfos.end(); bool Inserted; diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -490,14 +490,14 @@ struct PGOEdge { // This class implements the CFG edges. Note the CFG can be a multi-graph. // So there might be multiple edges with same SrcBB and DestBB. - const BasicBlock *SrcBB; - const BasicBlock *DestBB; + BasicBlock *SrcBB; + BasicBlock *DestBB; uint64_t Weight; bool InMST = false; bool Removed = false; bool IsCritical = false; - PGOEdge(const BasicBlock *Src, const BasicBlock *Dest, uint64_t W = 1) + PGOEdge(BasicBlock *Src, BasicBlock *Dest, uint64_t W = 1) : SrcBB(Src), DestBB(Dest), Weight(W) {} // Return the information string of an edge. @@ -809,8 +809,8 @@ if (E->InMST || E->Removed) return nullptr; - BasicBlock *SrcBB = const_cast(E->SrcBB); - BasicBlock *DestBB = const_cast(E->DestBB); + BasicBlock *SrcBB = E->SrcBB; + BasicBlock *DestBB = E->DestBB; // For a fake edge, instrument the real BB. if (SrcBB == nullptr) return DestBB; @@ -1011,12 +1011,11 @@ // This class represents a CFG edge in profile use compilation. struct PGOUseEdge : public PGOEdge { + using PGOEdge::PGOEdge; + bool CountValid = false; uint64_t CountValue = 0; - PGOUseEdge(const BasicBlock *Src, const BasicBlock *Dest, uint64_t W = 1) - : PGOEdge(Src, Dest, W) {} - // Set edge count value void setEdgeCount(uint64_t Value) { CountValue = Value;