70 #define DEBUG_TYPE "add-discriminators"
85 "Add DWARF path discriminators",
false,
false)
87 "Add DWARF path discriminators",
false, false)
94 cl::desc("Disable generation of discriminator information."));
97 return new AddDiscriminators();
102 return CUNodes !=
nullptr;
156 bool AddDiscriminators::runOnFunction(
Function &
F) {
167 bool Changed =
false;
192 if (!FirstDIL->canDiscriminate(*LastDIL)) {
195 StringRef Filename = FirstDIL->getFilename();
196 auto *Scope = FirstDIL->getScope();
197 auto *
File = Builder.createFile(Filename, Scope->getDirectory());
206 Builder.createLexicalBlockFile(Scope,
File, Discriminator);
209 NewScope, FirstDIL->getInlinedAt());
216 if (I1->getDebugLoc().get() != FirstDIL)
218 I1->setDebugLoc(newDebugLoc);
219 DEBUG(
dbgs() << NewDIL->getFilename() <<
":" << NewDIL->getLine()
220 <<
":" << NewDIL->getColumn() <<
":"
221 << NewDIL->getDiscriminator() << *I1 <<
"\n");
INITIALIZE_PASS_BEGIN(AddDiscriminators,"add-discriminators","Add DWARF path discriminators", false, false) INITIALIZE_PASS_END(AddDiscriminators
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A Module instance is used to store all the information related to an LLVM module. ...
static bool hasDebugInfo(const Function &F)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
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...
unsigned getNumSuccessors() const
Return the number of successors that this terminator has.
initializer< Ty > init(const Ty &Val)
unsigned computeNewDiscriminator() const
Compute new discriminator in the given context.
Subclasses of this class are all able to terminate a basic block.
LLVM Basic Block Representation.
BasicBlock * getSuccessor(unsigned idx) const
Return the specified successor.
This is an important class for using LLVM in a threaded context.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const DebugLoc & getDebugLoc() const
getDebugLoc - Return the debug location for this node as a DebugLoc.
FunctionPass class - This class is used to implement most global optimizations.
Instruction * getFirstNonPHIOrDbgOrLifetime()
Returns a pointer to the first instruction in this block that is not a PHINode, a debug intrinsic...
unsigned getDwarfVersion() const
Returns the Dwarf Version by checking module flags.
Module.h This file contains the declarations for the Module class.
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.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Module * getParent()
Get the module that this global value is contained inside of...
void initializeAddDiscriminatorsPass(PassRegistry &)
FunctionPass * createAddDiscriminatorsPass()
StringRef - Represent a constant reference to a string, i.e.
LLVMContext & getContext() const
Get the global data context.