77 #define DEBUG_TYPE "add-discriminators" 83 "no-discriminators",
cl::init(
false),
84 cl::desc(
"Disable generation of discriminator information."));
89 struct AddDiscriminatorsLegacyPass :
public FunctionPass {
104 "Add DWARF path discriminators",
false,
false)
106 "
Add DWARF path discriminators",
false, false)
110 return new AddDiscriminatorsLegacyPass();
114 return !isa<IntrinsicInst>(
I) || isa<MemIntrinsic>(I);
175 bool Changed =
false;
177 using Location = std::pair<StringRef, unsigned>;
184 LocationDiscriminatorMap LDM;
190 for (
auto &
I :
B.getInstList()) {
202 Location L = std::make_pair(DIL->getFilename(), DIL->getLine());
203 auto &BBMap = LBM[L];
204 auto R = BBMap.insert(&
B);
205 if (BBMap.size() == 1)
211 unsigned Discriminator = R.second ? ++LDM[L] : LDM[L];
215 << DIL->getFilename() <<
":" << DIL->getLine() <<
":" 216 << DIL->getColumn() <<
":" << Discriminator <<
" " 219 I.setDebugLoc(NewDIL.getValue());
220 LLVM_DEBUG(
dbgs() << DIL->getFilename() <<
":" << DIL->getLine() <<
":" 221 << DIL->getColumn() <<
":" << Discriminator <<
" " <<
I 233 LocationSet CallLocations;
234 for (
auto &
I :
B.getInstList()) {
239 if (!isa<InvokeInst>(
I) && (!isa<CallInst>(
I) || isa<IntrinsicInst>(
I)))
246 std::make_pair(CurrentDIL->getFilename(), CurrentDIL->getLine());
247 if (!CallLocations.insert(L).second) {
248 unsigned Discriminator = ++LDM[L];
252 <<
"Could not encode discriminator: " 253 << CurrentDIL->getFilename() <<
":" 254 << CurrentDIL->getLine() <<
":" << CurrentDIL->getColumn()
255 <<
":" << Discriminator <<
" " <<
I <<
"\n");
257 I.setDebugLoc(NewDIL.getValue());
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
Implements a dense probed hash-table based set.
void initializeAddDiscriminatorsLegacyPassPass(PassRegistry &)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static bool runOnFunction(Function &F, bool PostInlining)
initializer< Ty > init(const Ty &Val)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
DISubprogram * getSubprogram() const
Get the attached subprogram.
FunctionPass class - This class is used to implement most global optimizations.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
static bool addDiscriminators(Function &F)
Assign DWARF discriminators.
static cl::opt< bool > NoDiscriminators("no-discriminators", cl::init(false), cl::desc("Disable generation of discriminator information."))
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
INITIALIZE_PASS_BEGIN(AddDiscriminatorsLegacyPass, "add-discriminators", "Add DWARF path discriminators", false, false) INITIALIZE_PASS_END(AddDiscriminatorsLegacyPass
Optional< const DILocation * > setBaseDiscriminator(unsigned BD) const
Returns a new DILocation with updated base discriminator BD.
static bool shouldHaveDiscriminator(const Instruction *I)
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.
FunctionPass * createAddDiscriminatorsPass()