-/// isValidDebugInfoIntrinsic - Return true if SPI is a valid debug
-/// info intrinsic.
-bool llvm::isValidDebugInfoIntrinsic(DbgStopPointInst &SPI, unsigned OptLev) {
- return DIDescriptor::ValidDebugInfo(SPI.getContext(), OptLev);
-}
-
-/// isValidDebugInfoIntrinsic - Return true if FSI is a valid debug
-/// info intrinsic.
-bool llvm::isValidDebugInfoIntrinsic(DbgFuncStartInst &FSI, unsigned OptLev) {
- return DIDescriptor::ValidDebugInfo(FSI.getSubprogram(), OptLev);
-}
-
-/// isValidDebugInfoIntrinsic - Return true if RSI is a valid debug
-/// info intrinsic.
-bool llvm::isValidDebugInfoIntrinsic(DbgRegionStartInst &RSI, unsigned OptLev) {
- return DIDescriptor::ValidDebugInfo(RSI.getContext(), OptLev);
-}
-
-/// isValidDebugInfoIntrinsic - Return true if REI is a valid debug
-/// info intrinsic.
-bool llvm::isValidDebugInfoIntrinsic(DbgRegionEndInst &REI, unsigned OptLev) {
- return DIDescriptor::ValidDebugInfo(REI.getContext(), OptLev);
-}
-
-/// isValidDebugInfoIntrinsic - Return true if DI is a valid debug
-/// info intrinsic.
-bool llvm::isValidDebugInfoIntrinsic(DbgDeclareInst &DI, unsigned OptLev) {
- return DIDescriptor::ValidDebugInfo(DI.getVariable(), OptLev);
-}
-
-/// ExtractDebugLocation - Extract debug location information
-/// from llvm.dbg.stoppoint intrinsic.
-DebugLoc llvm::ExtractDebugLocation(DbgStopPointInst &SPI,
- DebugLocTracker &DebugLocInfo) {
- DebugLoc DL;
- Value *Context = SPI.getContext();
-
- // If this location is already tracked then use it.
- DebugLocTuple Tuple(cast<MDNode>(Context), NULL, SPI.getLine(),
- SPI.getColumn());
- DenseMap<DebugLocTuple, unsigned>::iterator II
- = DebugLocInfo.DebugIdMap.find(Tuple);
- if (II != DebugLocInfo.DebugIdMap.end())
- return DebugLoc::get(II->second);
-
- // Add a new location entry.
- unsigned Id = DebugLocInfo.DebugLocations.size();
- DebugLocInfo.DebugLocations.push_back(Tuple);
- DebugLocInfo.DebugIdMap[Tuple] = Id;
-
- return DebugLoc::get(Id);
-}
-
-/// ExtractDebugLocation - Extract debug location information
-/// from DILocation.
-DebugLoc llvm::ExtractDebugLocation(DILocation &Loc,
- DebugLocTracker &DebugLocInfo) {
- DebugLoc DL;
- MDNode *Context = Loc.getScope().getNode();
- MDNode *InlinedLoc = NULL;
- if (!Loc.getOrigLocation().isNull())
- InlinedLoc = Loc.getOrigLocation().getNode();
- // If this location is already tracked then use it.
- DebugLocTuple Tuple(Context, InlinedLoc, Loc.getLineNumber(),
- Loc.getColumnNumber());
- DenseMap<DebugLocTuple, unsigned>::iterator II
- = DebugLocInfo.DebugIdMap.find(Tuple);
- if (II != DebugLocInfo.DebugIdMap.end())
- return DebugLoc::get(II->second);
-
- // Add a new location entry.
- unsigned Id = DebugLocInfo.DebugLocations.size();
- DebugLocInfo.DebugLocations.push_back(Tuple);
- DebugLocInfo.DebugIdMap[Tuple] = Id;
-
- return DebugLoc::get(Id);
-}
-
-/// ExtractDebugLocation - Extract debug location information
-/// from llvm.dbg.func_start intrinsic.
-DebugLoc llvm::ExtractDebugLocation(DbgFuncStartInst &FSI,
- DebugLocTracker &DebugLocInfo) {
- DebugLoc DL;
- Value *SP = FSI.getSubprogram();
-
- DISubprogram Subprogram(cast<MDNode>(SP));
- unsigned Line = Subprogram.getLineNumber();
- DICompileUnit CU(Subprogram.getCompileUnit());
-
- // If this location is already tracked then use it.
- DebugLocTuple Tuple(CU.getNode(), NULL, Line, /* Column */ 0);
- DenseMap<DebugLocTuple, unsigned>::iterator II
- = DebugLocInfo.DebugIdMap.find(Tuple);
- if (II != DebugLocInfo.DebugIdMap.end())
- return DebugLoc::get(II->second);
-
- // Add a new location entry.
- unsigned Id = DebugLocInfo.DebugLocations.size();
- DebugLocInfo.DebugLocations.push_back(Tuple);
- DebugLocInfo.DebugIdMap[Tuple] = Id;
-
- return DebugLoc::get(Id);
-}
-