74using namespace sampleprofutil;
76#define DEBUG_TYPE "add-discriminators"
82 "no-discriminators",
cl::init(
false),
83 cl::desc(
"Disable generation of discriminator information."));
86 return !isa<IntrinsicInst>(
I) || isa<MemIntrinsic>(
I);
151 bool Changed =
false;
153 using Location = std::pair<StringRef, unsigned>;
160 LocationDiscriminatorMap LDM;
178 Location L = std::make_pair(DIL->getFilename(), DIL->getLine());
179 auto &BBMap = LBM[L];
180 auto R = BBMap.insert(&
B);
181 if (BBMap.size() == 1)
187 unsigned Discriminator = R.second ? ++LDM[L] : LDM[L];
191 << DIL->getFilename() <<
":" << DIL->getLine() <<
":"
192 << DIL->getColumn() <<
":" << Discriminator <<
" "
195 I.setDebugLoc(*NewDIL);
196 LLVM_DEBUG(
dbgs() << DIL->getFilename() <<
":" << DIL->getLine() <<
":"
197 << DIL->getColumn() <<
":" << Discriminator <<
" " <<
I
209 LocationSet CallLocations;
215 if (!isa<InvokeInst>(
I) && (!isa<CallInst>(
I) || isa<IntrinsicInst>(
I)))
222 std::make_pair(CurrentDIL->getFilename(), CurrentDIL->getLine());
223 if (!CallLocations.insert(L).second) {
224 unsigned Discriminator = ++LDM[L];
228 <<
"Could not encode discriminator: "
229 << CurrentDIL->getFilename() <<
":"
230 << CurrentDIL->getLine() <<
":" << CurrentDIL->getColumn()
231 <<
":" << Discriminator <<
" " <<
I <<
"\n");
233 I.setDebugLoc(*NewDIL);
static cl::opt< bool > NoDiscriminators("no-discriminators", cl::init(false), cl::desc("Disable generation of discriminator information."))
static bool addDiscriminators(Function &F)
Assign DWARF discriminators.
static bool shouldHaveDiscriminator(const Instruction *I)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This header defines various interfaces for pass management in LLVM.
This file provides the utility functions for the sampled PGO loader base implementation.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
A container for analyses that lazily runs them and caches their results.
LLVM Basic Block Representation.
std::optional< const DILocation * > cloneWithBaseDiscriminator(unsigned BD) const
Returns a new DILocation with updated base discriminator BD.
Implements a dense probed hash-table based set.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
initializer< Ty > init(const Ty &Val)
void createFSDiscriminatorVariable(Module *M)
Create a global variable to flag FSDiscriminators are used.
This is an optimization pass for GlobalISel generic memory operations.
cl::opt< bool > EnableFSDiscriminator
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.