72 #define DEBUG_TYPE "add-discriminators"
76 struct AddDiscriminatorsLegacyPass :
public FunctionPass {
89 "Add DWARF path discriminators",
false,
false)
91 "
Add DWARF path discriminators",
false, false)
97 "no-discriminators", cl::
init(false),
98 cl::desc("Disable
generation of discriminator information."));
102 return new AddDiscriminatorsLegacyPass();
106 return !isa<IntrinsicInst>(
I) || isa<MemIntrinsic>(I);
167 bool Changed =
false;
169 typedef std::pair<StringRef, unsigned> Location;
176 LocationDiscriminatorMap LDM;
182 for (
auto &
I :
B.getInstList()) {
194 Location
L = std::make_pair(DIL->getFilename(), DIL->getLine());
195 auto &BBMap = LBM[
L];
196 auto R = BBMap.insert(&
B);
197 if (BBMap.size() == 1)
203 unsigned Discriminator = R.second ? ++LDM[
L] : LDM[
L];
205 DEBUG(
dbgs() << DIL->getFilename() <<
":" << DIL->getLine() <<
":"
206 << DIL->getColumn() <<
":" << Discriminator <<
" " <<
I
217 LocationSet CallLocations;
218 for (
auto &
I :
B.getInstList()) {
224 if (!Current || isa<IntrinsicInst>(&
I))
231 std::make_pair(CurrentDIL->getFilename(), CurrentDIL->getLine());
232 if (!CallLocations.insert(L).second) {
233 unsigned Discriminator = ++LDM[
L];
242 bool AddDiscriminatorsLegacyPass::runOnFunction(
Function &
F) {
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Implements a dense probed hash-table based set.
This class represents a function call, abstracting a target machine's calling convention.
void initializeAddDiscriminatorsLegacyPassPass(PassRegistry &)
Optimize for code generation
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
initializer< Ty > init(const Ty &Val)
A set of analyses that are preserved following a run of a transformation pass.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
LLVM Basic Block Representation.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
FunctionPass class - This class is used to implement most global optimizations.
const DILocation * setBaseDiscriminator(unsigned BD) const
Returns a new DILocation with updated base discriminator BD.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static bool addDiscriminators(Function &F)
Assign DWARF discriminators.
add Add DWARF path static false 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.
DISubprogram * getSubprogram() const
Get the attached subprogram.
INITIALIZE_PASS_BEGIN(AddDiscriminatorsLegacyPass,"add-discriminators","Add DWARF path discriminators", false, false) INITIALIZE_PASS_END(AddDiscriminatorsLegacyPass
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
FunctionPass * createAddDiscriminatorsPass()
static bool shouldHaveDiscriminator(const Instruction *I)
A container for analyses that lazily runs them and caches their results.