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();
163 bool Changed =
false;
165 typedef std::pair<StringRef, unsigned> Location;
172 LocationDiscriminatorMap LDM;
178 for (
auto &
I :
B.getInstList()) {
179 if (isa<IntrinsicInst>(&
I))
184 Location
L = std::make_pair(DIL->getFilename(), DIL->getLine());
185 auto &BBMap = LBM[
L];
186 auto R = BBMap.insert(&
B);
187 if (BBMap.size() == 1)
193 unsigned Discriminator = (R.second ? ++LDM[
L] : LDM[
L]) & 0x7f;
195 DEBUG(
dbgs() << DIL->getFilename() <<
":" << DIL->getLine() <<
":"
196 << DIL->getColumn() <<
":" << Discriminator <<
" " <<
I
207 LocationSet CallLocations;
208 for (
auto &
I :
B.getInstList()) {
210 if (!Current || isa<IntrinsicInst>(&
I))
217 std::make_pair(CurrentDIL->getFilename(), CurrentDIL->getLine());
218 if (!CallLocations.insert(L).second) {
228 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 &)
DILocation * cloneWithDiscriminator(unsigned Discriminator) const
Returns a new DILocation with updated Discriminator.
static bool add(uint64_t *dest, const uint64_t *x, const uint64_t *y, unsigned len)
This function adds the integer array x to the integer array Y and places the result in dest...
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
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.
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()
A container for analyses that lazily runs them and caches their results.