DebugInfo: Gut DISubprogram and DILexicalBlock*
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 14 Apr 2015 03:40:37 +0000 (03:40 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 14 Apr 2015 03:40:37 +0000 (03:40 +0000)
Gut the `DIDescriptor` wrappers around `MDLocalScope` subclasses.  Note
that `DILexicalBlock` wraps `MDLexicalBlockBase`, not `MDLexicalBlock`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234850 91177308-0d34-0410-b5e6-96231b3b80d8

23 files changed:
include/llvm/IR/DebugInfo.h
lib/Analysis/ModuleDebugInfoPrinter.cpp
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp
lib/CodeGen/LexicalScopes.cpp
lib/IR/DIBuilder.cpp
lib/IR/DebugInfo.cpp
lib/IR/DebugLoc.cpp
lib/IR/Verifier.cpp
lib/Linker/LinkModules.cpp
lib/Target/NVPTX/NVPTXAsmPrinter.cpp
lib/Transforms/IPO/ArgumentPromotion.cpp
lib/Transforms/IPO/DeadArgumentElimination.cpp
lib/Transforms/IPO/StripSymbols.cpp
lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
lib/Transforms/Instrumentation/GCOVProfiling.cpp
lib/Transforms/Scalar/SampleProfile.cpp
lib/Transforms/Utils/CloneFunction.cpp
tools/opt/BreakpointPrinter.cpp
unittests/Transforms/Utils/Cloning.cpp

index 2108830d2a1553a767e78e62b6418be791f1ab1b..8abc514a8aa656283393a0e68b93a494a383ba66 100644 (file)
@@ -425,98 +425,43 @@ public:
   unsigned getEmissionKind() const { return get()->getEmissionKind(); }
 };
 
   unsigned getEmissionKind() const { return get()->getEmissionKind(); }
 };
 
-/// \brief This is a wrapper for a subprogram (e.g. a function).
-class DISubprogram : public DIScope {
-public:
-  DISubprogram() = default;
-  DISubprogram(const MDSubprogram *N) : DIScope(N) {}
-
-  MDSubprogram *get() const {
-    return cast_or_null<MDSubprogram>(DIDescriptor::get());
-  }
-  operator MDSubprogram *() const { return get(); }
-  MDSubprogram *operator->() const { return get(); }
-  MDSubprogram &operator*() const { return *get(); }
-
-  StringRef getName() const { return get()->getName(); }
-  StringRef getDisplayName() const { return get()->getDisplayName(); }
-  StringRef getLinkageName() const { return get()->getLinkageName(); }
-  unsigned getLineNumber() const { return get()->getLine(); }
-
-  /// \brief Check if this is local (like 'static' in C).
-  unsigned isLocalToUnit() const { return get()->isLocalToUnit(); }
-  unsigned isDefinition() const { return get()->isDefinition(); }
-
-  unsigned getVirtuality() const { return get()->getVirtuality(); }
-  unsigned getVirtualIndex() const { return get()->getVirtualIndex(); }
-
-  unsigned getFlags() const { return get()->getFlags(); }
-
-  unsigned isOptimized() const { return get()->isOptimized(); }
-
-  /// \brief Get the beginning of the scope of the function (not the name).
-  unsigned getScopeLineNumber() const { return get()->getScopeLine(); }
-
-  DIScopeRef getContext() const { return get()->getScope(); }
-  DISubroutineType getType() const { return get()->getType(); }
-
-  DITypeRef getContainingType() const { return get()->getContainingType(); }
-
-  /// \brief Check if this provides debugging information for the function F.
-  bool describes(const Function *F) const { return get()->describes(F); }
-
-  Function *getFunction() const { return get()->getFunction(); }
+class DISubprogram {
+  MDSubprogram *N;
 
 
-  void replaceFunction(Function *F) { get()->replaceFunction(F); }
-  DIArray getTemplateParams() const { return get()->getTemplateParams(); }
-  DISubprogram getFunctionDeclaration() const {
-    return get()->getDeclaration();
-  }
-  DIArray getVariables() const { return DIArray(get()->getVariables()); }
+public:
+  DISubprogram(const MDSubprogram *N = nullptr)
+      : N(const_cast<MDSubprogram *>(N)) {}
 
 
-  unsigned isArtificial() const { return get()->isArtificial(); }
-  bool isPrivate() const { return get()->isPrivate(); }
-  bool isProtected() const { return get()->isProtected(); }
-  bool isPublic() const { return get()->isPublic(); }
-  bool isExplicit() const { return get()->isExplicit(); }
-  bool isPrototyped() const { return get()->isPrototyped(); }
-  unsigned isLValueReference() const { return get()->isLValueReference(); }
-  unsigned isRValueReference() const { return get()->isRValueReference(); }
+  operator DIDescriptor() const { return N; }
+  operator MDSubprogram *() const { return N; }
+  MDSubprogram *operator->() const { return N; }
+  MDSubprogram &operator*() const { return *N; }
 };
 
 };
 
-/// \brief This is a wrapper for a lexical block.
-class DILexicalBlock : public DIScope {
-public:
-  DILexicalBlock() = default;
-  DILexicalBlock(const MDLexicalBlockBase *N) : DIScope(N) {}
+class DILexicalBlock {
+  MDLexicalBlockBase *N;
 
 
-  MDLexicalBlockBase *get() const {
-    return cast_or_null<MDLexicalBlockBase>(DIDescriptor::get());
-  }
-  operator MDLexicalBlockBase *() const { return get(); }
-  MDLexicalBlockBase *operator->() const { return get(); }
-  MDLexicalBlockBase &operator*() const { return *get(); }
+public:
+  DILexicalBlock(const MDLexicalBlockBase *N = nullptr)
+      : N(const_cast<MDLexicalBlockBase *>(N)) {}
 
 
-  DIScope getContext() const { return get()->getScope(); }
-  unsigned getLineNumber() const { return get()->getLine(); }
-  unsigned getColumnNumber() const { return get()->getColumn(); }
+  operator DIDescriptor() const { return N; }
+  operator MDLexicalBlockBase *() const { return N; }
+  MDLexicalBlockBase *operator->() const { return N; }
+  MDLexicalBlockBase &operator*() const { return *N; }
 };
 
 };
 
-/// \brief This is a wrapper for a lexical block with a filename change.
-class DILexicalBlockFile : public DIScope {
-public:
-  DILexicalBlockFile() = default;
-  DILexicalBlockFile(const MDLexicalBlockFile *N) : DIScope(N) {}
+class DILexicalBlockFile {
+  MDLexicalBlockFile *N;
 
 
-  MDLexicalBlockFile *get() const {
-    return cast_or_null<MDLexicalBlockFile>(DIDescriptor::get());
-  }
-  operator MDLexicalBlockFile *() const { return get(); }
-  MDLexicalBlockFile *operator->() const { return get(); }
-  MDLexicalBlockFile &operator*() const { return *get(); }
+public:
+  DILexicalBlockFile(const MDLexicalBlockFile *N = nullptr)
+      : N(const_cast<MDLexicalBlockFile *>(N)) {}
 
 
-  DIScope getContext() const { return get()->getScope(); }
-  unsigned getDiscriminator() const { return get()->getDiscriminator(); }
+  operator DIDescriptor() const { return N; }
+  operator MDLexicalBlockFile *() const { return N; }
+  MDLexicalBlockFile *operator->() const { return N; }
+  MDLexicalBlockFile &operator*() const { return *N; }
 };
 
 class DINameSpace {
 };
 
 class DINameSpace {
index f305f13c1aa95a215a214c7230fd3b0182f3ea99..1b50bf025708568cc08deda64e88ada87fa67ca7 100644 (file)
@@ -82,11 +82,11 @@ void ModuleDebugInfoPrinter::print(raw_ostream &O, const Module *M) const {
     O << '\n';
   }
 
     O << '\n';
   }
 
-  for (DISubprogram S : Finder.subprograms()) {
-    O << "Subprogram: " << S.getName();
-    printFile(O, S.getFilename(), S.getDirectory(), S.getLineNumber());
-    if (!S.getLinkageName().empty())
-      O << " ('" << S.getLinkageName() << "')";
+  for (MDSubprogram *S : Finder.subprograms()) {
+    O << "Subprogram: " << S->getName();
+    printFile(O, S->getFilename(), S->getDirectory(), S->getLine());
+    if (!S->getLinkageName().empty())
+      O << " ('" << S->getLinkageName() << "')";
     O << '\n';
   }
 
     O << '\n';
   }
 
index 7bf28a62af5ad10e18e900efcec74bc85cf32b50..43d7a38e04aed79aa94fe14c015fb9267cc0a29d 100644 (file)
@@ -671,8 +671,8 @@ static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) {
   OS << "DEBUG_VALUE: ";
 
   DIVariable V = MI->getDebugVariable();
   OS << "DEBUG_VALUE: ";
 
   DIVariable V = MI->getDebugVariable();
-  if (DISubprogram SP = dyn_cast<MDSubprogram>(V->getScope())) {
-    StringRef Name = SP.getDisplayName();
+  if (auto *SP = dyn_cast<MDSubprogram>(V->getScope())) {
+    StringRef Name = SP->getDisplayName();
     if (!Name.empty())
       OS << Name << ":";
   }
     if (!Name.empty())
       OS << Name << ":";
   }
index 3ba33af293344a507613553bd3efa4ef44f2094c..555d40bb8c221011f5828dcd508f7a91be7e855e 100644 (file)
@@ -568,7 +568,7 @@ void DwarfCompileUnit::constructSubprogramScopeDIE(LexicalScope *Scope) {
   DIE &ScopeDIE = updateSubprogramScopeDIE(Sub);
 
   // If this is a variadic function, add an unspecified parameter.
   DIE &ScopeDIE = updateSubprogramScopeDIE(Sub);
 
   // If this is a variadic function, add an unspecified parameter.
-  DITypeArray FnArgs = Sub.getType().getTypeArray();
+  DITypeArray FnArgs = Sub->getType()->getTypeArray();
 
   // Collect lexical scope children first.
   // ObjectPointer might be a local (non-argument) local variable if it's a
 
   // Collect lexical scope children first.
   // ObjectPointer might be a local (non-argument) local variable if it's a
@@ -613,11 +613,11 @@ DwarfCompileUnit::constructAbstractSubprogramScopeDIE(LexicalScope *Scope) {
   // the important distinction that the DIDescriptor is not associated with the
   // DIE (since the DIDescriptor will be associated with the concrete DIE, if
   // any). It could be refactored to some common utility function.
   // the important distinction that the DIDescriptor is not associated with the
   // DIE (since the DIDescriptor will be associated with the concrete DIE, if
   // any). It could be refactored to some common utility function.
-  else if (DISubprogram SPDecl = SP.getFunctionDeclaration()) {
+  else if (auto *SPDecl = SP->getDeclaration()) {
     ContextDIE = &getUnitDie();
     getOrCreateSubprogramDIE(SPDecl);
   } else
     ContextDIE = &getUnitDie();
     getOrCreateSubprogramDIE(SPDecl);
   } else
-    ContextDIE = getOrCreateContextDIE(resolve(SP.getContext()));
+    ContextDIE = getOrCreateContextDIE(resolve(SP->getScope()));
 
   // Passing null as the associated DIDescriptor because the abstract definition
   // shouldn't be found by lookup.
 
   // Passing null as the associated DIDescriptor because the abstract definition
   // shouldn't be found by lookup.
@@ -677,7 +677,7 @@ void DwarfCompileUnit::finishSubprogramDefinition(DISubprogram SP) {
 }
 void DwarfCompileUnit::collectDeadVariables(DISubprogram SP) {
   assert(SP && "CU's subprogram list contains a non-subprogram");
 }
 void DwarfCompileUnit::collectDeadVariables(DISubprogram SP) {
   assert(SP && "CU's subprogram list contains a non-subprogram");
-  assert(SP.isDefinition() &&
+  assert(SP->isDefinition() &&
          "CU's subprogram list contains a subprogram declaration");
   auto Variables = SP->getVariables();
   if (Variables.size() == 0)
          "CU's subprogram list contains a subprogram declaration");
   auto Variables = SP->getVariables();
   if (Variables.size() == 0)
@@ -807,10 +807,10 @@ void DwarfCompileUnit::addExpr(DIELoc &Die, dwarf::Form Form,
 
 void DwarfCompileUnit::applySubprogramAttributesToDefinition(DISubprogram SP,
                                                              DIE &SPDie) {
 
 void DwarfCompileUnit::applySubprogramAttributesToDefinition(DISubprogram SP,
                                                              DIE &SPDie) {
-  DISubprogram SPDecl = SP.getFunctionDeclaration();
-  DIScope Context = resolve(SPDecl ? SPDecl.getContext() : SP.getContext());
+  auto *SPDecl = SP->getDeclaration();
+  DIScope Context = resolve(SPDecl ? SPDecl->getScope() : SP->getScope());
   applySubprogramAttributes(SP, SPDie, includeMinimalInlineScopes());
   applySubprogramAttributes(SP, SPDie, includeMinimalInlineScopes());
-  addGlobalName(SP.getName(), SPDie, Context);
+  addGlobalName(SP->getName(), SPDie, Context);
 }
 
 bool DwarfCompileUnit::isDwoUnit() const {
 }
 
 bool DwarfCompileUnit::isDwoUnit() const {
index 5785b5ebfafdd9c4055ded016280c8446991b5e2..527c1af88f8ed4c90d3ded3575f41d7c97b44673 100644 (file)
@@ -277,25 +277,25 @@ static StringRef getObjCMethodName(StringRef In) {
 // that do not have a DW_AT_name or DW_AT_linkage_name field - this
 // is only slightly different than the lookup of non-standard ObjC names.
 void DwarfDebug::addSubprogramNames(DISubprogram SP, DIE &Die) {
 // that do not have a DW_AT_name or DW_AT_linkage_name field - this
 // is only slightly different than the lookup of non-standard ObjC names.
 void DwarfDebug::addSubprogramNames(DISubprogram SP, DIE &Die) {
-  if (!SP.isDefinition())
+  if (!SP->isDefinition())
     return;
     return;
-  addAccelName(SP.getName(), Die);
+  addAccelName(SP->getName(), Die);
 
   // If the linkage name is different than the name, go ahead and output
   // that as well into the name table.
 
   // If the linkage name is different than the name, go ahead and output
   // that as well into the name table.
-  if (SP.getLinkageName() != "" && SP.getName() != SP.getLinkageName())
-    addAccelName(SP.getLinkageName(), Die);
+  if (SP->getLinkageName() != "" && SP->getName() != SP->getLinkageName())
+    addAccelName(SP->getLinkageName(), Die);
 
   // If this is an Objective-C selector name add it to the ObjC accelerator
   // too.
 
   // If this is an Objective-C selector name add it to the ObjC accelerator
   // too.
-  if (isObjCClass(SP.getName())) {
+  if (isObjCClass(SP->getName())) {
     StringRef Class, Category;
     StringRef Class, Category;
-    getObjCClassCategory(SP.getName(), Class, Category);
+    getObjCClassCategory(SP->getName(), Class, Category);
     addAccelObjC(Class, Die);
     if (Category != "")
       addAccelObjC(Category, Die);
     // Also add the base method name to the name table.
     addAccelObjC(Class, Die);
     if (Category != "")
       addAccelObjC(Category, Die);
     // Also add the base method name to the name table.
-    addAccelName(getObjCMethodName(SP.getName()), Die);
+    addAccelName(getObjCMethodName(SP->getName()), Die);
   }
 }
 
   }
 }
 
@@ -1129,7 +1129,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
     // label, so arguments are visible when breaking at function entry.
     DIVariable DIVar = Ranges.front().first->getDebugVariable();
     if (DIVar->getTag() == dwarf::DW_TAG_arg_variable &&
     // label, so arguments are visible when breaking at function entry.
     DIVariable DIVar = Ranges.front().first->getDebugVariable();
     if (DIVar->getTag() == dwarf::DW_TAG_arg_variable &&
-        getDISubprogram(DIVar->getScope()).describes(MF->getFunction())) {
+        getDISubprogram(DIVar->getScope())->describes(MF->getFunction())) {
       LabelsBeforeInsn[Ranges.front().first] = Asm->getFunctionBegin();
       if (Ranges.front().first->getDebugExpression()->isBitPiece()) {
         // Mark all non-overlapping initial pieces.
       LabelsBeforeInsn[Ranges.front().first] = Asm->getFunctionBegin();
       if (Ranges.front().first->getDebugExpression()->isBitPiece()) {
         // Mark all non-overlapping initial pieces.
@@ -1255,8 +1255,8 @@ void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S,
   if (DIScope Scope = cast_or_null<MDScope>(S)) {
     Fn = Scope.getFilename();
     Dir = Scope.getDirectory();
   if (DIScope Scope = cast_or_null<MDScope>(S)) {
     Fn = Scope.getFilename();
     Dir = Scope.getDirectory();
-    if (DILexicalBlockFile LBF = dyn_cast<MDLexicalBlockFile>(Scope))
-      Discriminator = LBF.getDiscriminator();
+    if (auto *LBF = dyn_cast<MDLexicalBlockFile>(Scope))
+      Discriminator = LBF->getDiscriminator();
 
     unsigned CUID = Asm->OutStreamer.getContext().getDwarfCompileUnitID();
     Src = static_cast<DwarfCompileUnit &>(*InfoHolder.getUnits()[CUID])
 
     unsigned CUID = Asm->OutStreamer.getContext().getDwarfCompileUnitID();
     Src = static_cast<DwarfCompileUnit &>(*InfoHolder.getUnits()[CUID])
index f2e3b8feefaebf2fe9ef7a80155133b1239ebff0..5beccaa86d6f78941eabb719f74ab35270f0ffda 100644 (file)
@@ -416,7 +416,7 @@ void DwarfUnit::addSourceLine(DIE &Die, DIGlobalVariable G) {
 void DwarfUnit::addSourceLine(DIE &Die, DISubprogram SP) {
   assert(SP);
 
 void DwarfUnit::addSourceLine(DIE &Die, DISubprogram SP) {
   assert(SP);
 
-  addSourceLine(Die, SP.getLineNumber(), SP.getFilename(), SP.getDirectory());
+  addSourceLine(Die, SP->getLine(), SP->getFilename(), SP->getDirectory());
 }
 
 /// addSourceLine - Add location information to specified debug information
 }
 
 /// addSourceLine - Add location information to specified debug information
@@ -1213,12 +1213,12 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP, bool Minimal) {
   // such construction creates the DIE (as is the case for member function
   // declarations).
   DIE *ContextDIE =
   // such construction creates the DIE (as is the case for member function
   // declarations).
   DIE *ContextDIE =
-      Minimal ? &getUnitDie() : getOrCreateContextDIE(resolve(SP.getContext()));
+      Minimal ? &getUnitDie() : getOrCreateContextDIE(resolve(SP->getScope()));
 
   if (DIE *SPDie = getDIE(SP))
     return SPDie;
 
 
   if (DIE *SPDie = getDIE(SP))
     return SPDie;
 
-  if (DISubprogram SPDecl = SP.getFunctionDeclaration()) {
+  if (auto *SPDecl = SP->getDeclaration()) {
     if (!Minimal) {
       // Add subprogram definitions to the CU die directly.
       ContextDIE = &getUnitDie();
     if (!Minimal) {
       // Add subprogram definitions to the CU die directly.
       ContextDIE = &getUnitDie();
@@ -1232,7 +1232,7 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP, bool Minimal) {
 
   // Stop here and fill this in later, depending on whether or not this
   // subprogram turns out to have inlined instances or not.
 
   // Stop here and fill this in later, depending on whether or not this
   // subprogram turns out to have inlined instances or not.
-  if (SP.isDefinition())
+  if (SP->isDefinition())
     return &SPDie;
 
   applySubprogramAttributes(SP, SPDie);
     return &SPDie;
 
   applySubprogramAttributes(SP, SPDie);
@@ -1243,19 +1243,19 @@ bool DwarfUnit::applySubprogramDefinitionAttributes(DISubprogram SP,
                                                     DIE &SPDie) {
   DIE *DeclDie = nullptr;
   StringRef DeclLinkageName;
                                                     DIE &SPDie) {
   DIE *DeclDie = nullptr;
   StringRef DeclLinkageName;
-  if (DISubprogram SPDecl = SP.getFunctionDeclaration()) {
+  if (auto *SPDecl = SP->getDeclaration()) {
     DeclDie = getDIE(SPDecl);
     assert(DeclDie && "This DIE should've already been constructed when the "
                       "definition DIE was created in "
                       "getOrCreateSubprogramDIE");
     DeclDie = getDIE(SPDecl);
     assert(DeclDie && "This DIE should've already been constructed when the "
                       "definition DIE was created in "
                       "getOrCreateSubprogramDIE");
-    DeclLinkageName = SPDecl.getLinkageName();
+    DeclLinkageName = SPDecl->getLinkageName();
   }
 
   // Add function template parameters.
   }
 
   // Add function template parameters.
-  addTemplateParams(SPDie, SP.getTemplateParams());
+  addTemplateParams(SPDie, SP->getTemplateParams());
 
   // Add the linkage name if we have one and it isn't in the Decl.
 
   // Add the linkage name if we have one and it isn't in the Decl.
-  StringRef LinkageName = SP.getLinkageName();
+  StringRef LinkageName = SP->getLinkageName();
   assert(((LinkageName.empty() || DeclLinkageName.empty()) ||
           LinkageName == DeclLinkageName) &&
          "decl has a linkage name and it is different");
   assert(((LinkageName.empty() || DeclLinkageName.empty()) ||
           LinkageName == DeclLinkageName) &&
          "decl has a linkage name and it is different");
@@ -1278,8 +1278,8 @@ void DwarfUnit::applySubprogramAttributes(DISubprogram SP, DIE &SPDie,
       return;
 
   // Constructors and operators for anonymous aggregates do not have names.
       return;
 
   // Constructors and operators for anonymous aggregates do not have names.
-  if (!SP.getName().empty())
-    addString(SPDie, dwarf::DW_AT_name, SP.getName());
+  if (!SP->getName().empty())
+    addString(SPDie, dwarf::DW_AT_name, SP->getName());
 
   // Skip the rest of the attributes under -gmlt to save space.
   if (Minimal)
 
   // Skip the rest of the attributes under -gmlt to save space.
   if (Minimal)
@@ -1290,12 +1290,12 @@ void DwarfUnit::applySubprogramAttributes(DISubprogram SP, DIE &SPDie,
   // Add the prototype if we have a prototype and we have a C like
   // language.
   uint16_t Language = getLanguage();
   // Add the prototype if we have a prototype and we have a C like
   // language.
   uint16_t Language = getLanguage();
-  if (SP.isPrototyped() &&
+  if (SP->isPrototyped() &&
       (Language == dwarf::DW_LANG_C89 || Language == dwarf::DW_LANG_C99 ||
        Language == dwarf::DW_LANG_ObjC))
     addFlag(SPDie, dwarf::DW_AT_prototyped);
 
       (Language == dwarf::DW_LANG_C89 || Language == dwarf::DW_LANG_C99 ||
        Language == dwarf::DW_LANG_ObjC))
     addFlag(SPDie, dwarf::DW_AT_prototyped);
 
-  DISubroutineType SPTy = SP.getType();
+  DISubroutineType SPTy = SP->getType();
   assert(SPTy.getTag() == dwarf::DW_TAG_subroutine_type &&
          "the type of a subprogram should be a subroutine");
 
   assert(SPTy.getTag() == dwarf::DW_TAG_subroutine_type &&
          "the type of a subprogram should be a subroutine");
 
@@ -1306,18 +1306,18 @@ void DwarfUnit::applySubprogramAttributes(DISubprogram SP, DIE &SPDie,
     if (auto Ty = resolve(Args[0]))
       addType(SPDie, Ty);
 
     if (auto Ty = resolve(Args[0]))
       addType(SPDie, Ty);
 
-  unsigned VK = SP.getVirtuality();
+  unsigned VK = SP->getVirtuality();
   if (VK) {
     addUInt(SPDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1, VK);
     DIELoc *Block = getDIELoc();
     addUInt(*Block, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
   if (VK) {
     addUInt(SPDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1, VK);
     DIELoc *Block = getDIELoc();
     addUInt(*Block, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
-    addUInt(*Block, dwarf::DW_FORM_udata, SP.getVirtualIndex());
+    addUInt(*Block, dwarf::DW_FORM_udata, SP->getVirtualIndex());
     addBlock(SPDie, dwarf::DW_AT_vtable_elem_location, Block);
     ContainingTypeMap.insert(
     addBlock(SPDie, dwarf::DW_AT_vtable_elem_location, Block);
     ContainingTypeMap.insert(
-        std::make_pair(&SPDie, resolve(SP.getContainingType())));
+        std::make_pair(&SPDie, resolve(SP->getContainingType())));
   }
 
   }
 
-  if (!SP.isDefinition()) {
+  if (!SP->isDefinition()) {
     addFlag(SPDie, dwarf::DW_AT_declaration);
 
     // Add arguments. Do not add arguments for subprogram definition. They will
     addFlag(SPDie, dwarf::DW_AT_declaration);
 
     // Add arguments. Do not add arguments for subprogram definition. They will
@@ -1325,35 +1325,35 @@ void DwarfUnit::applySubprogramAttributes(DISubprogram SP, DIE &SPDie,
     constructSubprogramArguments(SPDie, Args);
   }
 
     constructSubprogramArguments(SPDie, Args);
   }
 
-  if (SP.isArtificial())
+  if (SP->isArtificial())
     addFlag(SPDie, dwarf::DW_AT_artificial);
 
     addFlag(SPDie, dwarf::DW_AT_artificial);
 
-  if (!SP.isLocalToUnit())
+  if (!SP->isLocalToUnit())
     addFlag(SPDie, dwarf::DW_AT_external);
 
     addFlag(SPDie, dwarf::DW_AT_external);
 
-  if (SP.isOptimized())
+  if (SP->isOptimized())
     addFlag(SPDie, dwarf::DW_AT_APPLE_optimized);
 
   if (unsigned isa = Asm->getISAEncoding())
     addUInt(SPDie, dwarf::DW_AT_APPLE_isa, dwarf::DW_FORM_flag, isa);
 
     addFlag(SPDie, dwarf::DW_AT_APPLE_optimized);
 
   if (unsigned isa = Asm->getISAEncoding())
     addUInt(SPDie, dwarf::DW_AT_APPLE_isa, dwarf::DW_FORM_flag, isa);
 
-  if (SP.isLValueReference())
+  if (SP->isLValueReference())
     addFlag(SPDie, dwarf::DW_AT_reference);
 
     addFlag(SPDie, dwarf::DW_AT_reference);
 
-  if (SP.isRValueReference())
+  if (SP->isRValueReference())
     addFlag(SPDie, dwarf::DW_AT_rvalue_reference);
 
     addFlag(SPDie, dwarf::DW_AT_rvalue_reference);
 
-  if (SP.isProtected())
+  if (SP->isProtected())
     addUInt(SPDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
             dwarf::DW_ACCESS_protected);
     addUInt(SPDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
             dwarf::DW_ACCESS_protected);
-  else if (SP.isPrivate())
+  else if (SP->isPrivate())
     addUInt(SPDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
             dwarf::DW_ACCESS_private);
     addUInt(SPDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
             dwarf::DW_ACCESS_private);
-  else if (SP.isPublic())
+  else if (SP->isPublic())
     addUInt(SPDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
             dwarf::DW_ACCESS_public);
 
     addUInt(SPDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
             dwarf::DW_ACCESS_public);
 
-  if (SP.isExplicit())
+  if (SP->isExplicit())
     addFlag(SPDie, dwarf::DW_AT_explicit);
 }
 
     addFlag(SPDie, dwarf::DW_AT_explicit);
 }
 
index 2bd311bc7d8f2a51370b3b0008d89e18acd08fa6..d859ee1a083afe09e57ba942dc6fcb11ffb00d6f 100644 (file)
@@ -192,7 +192,7 @@ void WinCodeViewLineTables::emitDebugInfoForFunction(const Function *GV) {
   StringRef GVName = GV->getName();
   StringRef FuncName;
   if (DISubprogram SP = getDISubprogram(GV))
   StringRef GVName = GV->getName();
   StringRef FuncName;
   if (DISubprogram SP = getDISubprogram(GV))
-    FuncName = SP.getDisplayName();
+    FuncName = SP->getDisplayName();
 
   // FIXME Clang currently sets DisplayName to "bar" for a C++
   // "namespace_foo::bar" function, see PR21528.  Luckily, dbghelp.dll is trying
 
   // FIXME Clang currently sets DisplayName to "bar" for a C++
   // "namespace_foo::bar" function, see PR21528.  Luckily, dbghelp.dll is trying
index 938fa0a8de33207dfe4dce018dc42261ef45e04b..d6998d6e1c5599e146e4e8032a1726828e8396d6 100644 (file)
@@ -157,8 +157,7 @@ LexicalScopes::getOrCreateRegularScope(const MDLocalScope *Scope) {
                                                     false)).first;
 
   if (!Parent) {
                                                     false)).first;
 
   if (!Parent) {
-    assert(
-        DISubprogram(cast<MDSubprogram>(Scope)).describes(MF->getFunction()));
+    assert(cast<MDSubprogram>(Scope)->describes(MF->getFunction()));
     assert(!CurrentFnLexicalScope);
     CurrentFnLexicalScope = &I->second;
   }
     assert(!CurrentFnLexicalScope);
     CurrentFnLexicalScope = &I->second;
   }
index 4fbe388799a0ed4c90e58dd65d6d008b0d107464..1f0878880289bdc4d8366a9fd72e81897fc87a78 100644 (file)
@@ -93,7 +93,7 @@ void DIBuilder::finalize() {
   TempSubprograms->replaceAllUsesWith(SPs.get());
   for (unsigned i = 0, e = SPs.size(); i != e; ++i) {
     DISubprogram SP = cast<MDSubprogram>(SPs[i]);
   TempSubprograms->replaceAllUsesWith(SPs.get());
   for (unsigned i = 0, e = SPs.size(); i != e; ++i) {
     DISubprogram SP = cast<MDSubprogram>(SPs[i]);
-    if (MDTuple *Temp = SP.getVariables().get()) {
+    if (MDTuple *Temp = SP->getVariables().get()) {
       const auto &PV = PreservedVariables.lookup(SP);
       SmallVector<Metadata *, 4> Variables(PV.begin(), PV.end());
       DIArray AV = getOrCreateArray(Variables);
       const auto &PV = PreservedVariables.lookup(SP);
       SmallVector<Metadata *, 4> Variables(PV.begin(), PV.end());
       DIArray AV = getOrCreateArray(Variables);
index 2b7d7f0408309b723093fd82ba03de40acdec15f..3ffd13064d4d4b2f487bf50e0714507184a31bca 100644 (file)
@@ -74,7 +74,7 @@ DISubprogram llvm::getDISubprogram(const Function *F) {
     DebugLoc DLoc = Inst->getDebugLoc();
     const MDNode *Scope = DLoc.getInlinedAtScope();
     DISubprogram Subprogram = getDISubprogram(Scope);
     DebugLoc DLoc = Inst->getDebugLoc();
     const MDNode *Scope = DLoc.getInlinedAtScope();
     DISubprogram Subprogram = getDISubprogram(Scope);
-    return Subprogram.describes(F) ? Subprogram : DISubprogram();
+    return Subprogram->describes(F) ? Subprogram : DISubprogram();
   }
 
   return DISubprogram();
   }
 
   return DISubprogram();
@@ -222,8 +222,8 @@ void DebugInfoFinder::processScope(DIScope Scope) {
   }
   if (!addScope(Scope))
     return;
   }
   if (!addScope(Scope))
     return;
-  if (DILexicalBlock LB = dyn_cast<MDLexicalBlockBase>(Scope)) {
-    processScope(LB.getContext());
+  if (auto *LB = dyn_cast<MDLexicalBlockBase>(Scope)) {
+    processScope(LB->getScope());
   } else if (auto *NS = dyn_cast<MDNamespace>(Scope)) {
     processScope(NS->getScope());
   }
   } else if (auto *NS = dyn_cast<MDNamespace>(Scope)) {
     processScope(NS->getScope());
   }
@@ -232,9 +232,9 @@ void DebugInfoFinder::processScope(DIScope Scope) {
 void DebugInfoFinder::processSubprogram(DISubprogram SP) {
   if (!addSubprogram(SP))
     return;
 void DebugInfoFinder::processSubprogram(DISubprogram SP) {
   if (!addSubprogram(SP))
     return;
-  processScope(SP.getContext().resolve(TypeIdentifierMap));
-  processType(SP.getType());
-  for (auto *Element : SP.getTemplateParams()) {
+  processScope(SP->getScope().resolve(TypeIdentifierMap));
+  processType(SP->getType());
+  for (auto *Element : SP->getTemplateParams()) {
     if (auto *TType = dyn_cast<MDTemplateTypeParameter>(Element)) {
       processType(TType->getType().resolve(TypeIdentifierMap));
     } else if (auto *TVal = dyn_cast<MDTemplateValueParameter>(Element)) {
     if (auto *TType = dyn_cast<MDTemplateTypeParameter>(Element)) {
       processType(TType->getType().resolve(TypeIdentifierMap));
     } else if (auto *TVal = dyn_cast<MDTemplateValueParameter>(Element)) {
@@ -434,7 +434,7 @@ llvm::makeSubprogramMap(const Module &M) {
   for (MDNode *N : CU_Nodes->operands()) {
     DICompileUnit CUNode = cast<MDCompileUnit>(N);
     for (DISubprogram SP : CUNode->getSubprograms()) {
   for (MDNode *N : CU_Nodes->operands()) {
     DICompileUnit CUNode = cast<MDCompileUnit>(N);
     for (DISubprogram SP : CUNode->getSubprograms()) {
-      if (Function *F = SP.getFunction())
+      if (Function *F = SP->getFunction())
         R.insert(std::make_pair(F, SP));
     }
   }
         R.insert(std::make_pair(F, SP));
     }
   }
index df4802d95497534239e5a3dd823fb39dfeb162f4..984ee24883668fd8437c6cf993cdb5a8dc9fd42a 100644 (file)
@@ -51,7 +51,7 @@ DebugLoc DebugLoc::getFnDebugLoc() const {
   // FIXME: Add a method on \a MDLocation that does this work.
   const MDNode *Scope = getInlinedAtScope();
   if (DISubprogram SP = getDISubprogram(Scope))
   // FIXME: Add a method on \a MDLocation that does this work.
   const MDNode *Scope = getInlinedAtScope();
   if (DISubprogram SP = getDISubprogram(Scope))
-    return DebugLoc::get(SP.getScopeLineNumber(), 0, SP);
+    return DebugLoc::get(SP->getScopeLine(), 0, SP);
 
   return DebugLoc();
 }
 
   return DebugLoc();
 }
index ba1a8e8b762d3569f4310537b0f47fa286ad75b9..2034f8b54f8d8329bd30354f0cbc948479775a2c 100644 (file)
@@ -991,7 +991,7 @@ void Verifier::visitMDSubprogram(const MDSubprogram &N) {
         continue;
 
       // FIXME: Once N is canonical, check "SP == &N".
         continue;
 
       // FIXME: Once N is canonical, check "SP == &N".
-      Assert(DISubprogram(SP).describes(F),
+      Assert(SP->describes(F),
              "!dbg attachment points at wrong subprogram for function", &N, F,
              &I, DL, Scope, SP);
     }
              "!dbg attachment points at wrong subprogram for function", &N, F,
              &I, DL, Scope, SP);
     }
index 75849db49993c7a8944bd694c93acf846ae12548..03ab9fbd83cab8e0380d30cfe98d4e7f0a3f3a4c 100644 (file)
@@ -1272,12 +1272,8 @@ void ModuleLinker::stripReplacedSubprograms() {
     DICompileUnit CU = cast<MDCompileUnit>(CompileUnits->getOperand(I));
     assert(CU && "Expected valid compile unit");
 
     DICompileUnit CU = cast<MDCompileUnit>(CompileUnits->getOperand(I));
     assert(CU && "Expected valid compile unit");
 
-    MDSubprogramArray SPs(CU.getSubprograms());
-    assert(SPs && "Expected valid subprogram array");
-
-    for (unsigned S = 0, SE = SPs.size(); S != SE; ++S) {
-      DISubprogram SP = SPs[S];
-      if (!SP || !SP.getFunction() || !Functions.count(SP.getFunction()))
+    for (MDSubprogram *SP : CU->getSubprograms()) {
+      if (!SP || !SP->getFunction() || !Functions.count(SP->getFunction()))
         continue;
 
       // Prevent DebugInfoFinder from tagging this as the canonical subprogram,
         continue;
 
       // Prevent DebugInfoFinder from tagging this as the canonical subprogram,
index 22178f635b1183578cd81e85372c6973713b1740..6c9092ee5600e853693f767ac5d2f5737e89080f 100644 (file)
@@ -788,9 +788,9 @@ void NVPTXAsmPrinter::recordAndEmitFilenames(Module &M) {
     ++i;
   }
 
     ++i;
   }
 
-  for (DISubprogram SP : DbgFinder.subprograms()) {
-    StringRef Filename(SP.getFilename());
-    StringRef Dirname(SP.getDirectory());
+  for (MDSubprogram *SP : DbgFinder.subprograms()) {
+    StringRef Filename = SP->getFilename();
+    StringRef Dirname = SP->getDirectory();
     SmallString<128> FullPathName = Dirname;
     if (!Dirname.empty() && !sys::path::is_absolute(Filename)) {
       sys::path::append(FullPathName, Filename);
     SmallString<128> FullPathName = Dirname;
     if (!Dirname.empty() && !sys::path::is_absolute(Filename)) {
       sys::path::append(FullPathName, Filename);
index 728ee98ad7033d96361732071c820cb9d8f5980f..56975eabaee275c81c3c2dc6ca5ad85be9bee8df 100644 (file)
@@ -706,7 +706,7 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
   auto DI = FunctionDIs.find(F);
   if (DI != FunctionDIs.end()) {
     DISubprogram SP = DI->second;
   auto DI = FunctionDIs.find(F);
   if (DI != FunctionDIs.end()) {
     DISubprogram SP = DI->second;
-    SP.replaceFunction(NF);
+    SP->replaceFunction(NF);
     // Ensure the map is updated so it can be reused on subsequent argument
     // promotions of the same function.
     FunctionDIs.erase(DI);
     // Ensure the map is updated so it can be reused on subsequent argument
     // promotions of the same function.
     FunctionDIs.erase(DI);
index de323b92cc281af9ceb9c3cd8a0637e81f07ce78..3be23d55f5a9adfaa00786839e3517ed996ec55a 100644 (file)
@@ -304,7 +304,7 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
   auto DI = FunctionDIs.find(&Fn);
   if (DI != FunctionDIs.end()) {
     DISubprogram SP = DI->second;
   auto DI = FunctionDIs.find(&Fn);
   if (DI != FunctionDIs.end()) {
     DISubprogram SP = DI->second;
-    SP.replaceFunction(NF);
+    SP->replaceFunction(NF);
     // Ensure the map is updated so it can be reused on non-varargs argument
     // eliminations of the same function.
     FunctionDIs.erase(DI);
     // Ensure the map is updated so it can be reused on non-varargs argument
     // eliminations of the same function.
     FunctionDIs.erase(DI);
@@ -1092,7 +1092,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
   // Patch the pointer to LLVM function in debug info descriptor.
   auto DI = FunctionDIs.find(F);
   if (DI != FunctionDIs.end())
   // Patch the pointer to LLVM function in debug info descriptor.
   auto DI = FunctionDIs.find(F);
   if (DI != FunctionDIs.end())
-    DI->second.replaceFunction(NF);
+    DI->second->replaceFunction(NF);
 
   // Now that the old function is dead, delete it.
   F->eraseFromParent();
 
   // Now that the old function is dead, delete it.
   F->eraseFromParent();
index b507f972c8b97c56a61c98636bc73830eeed3efb..817f49fecd32f7205f627f2422e5ff8ad3af8764 100644 (file)
@@ -317,7 +317,7 @@ bool StripDeadDebugInfo::runOnModule(Module &M) {
         continue;
 
       // If the function referenced by DISP is not null, the function is live.
         continue;
 
       // If the function referenced by DISP is not null, the function is live.
-      if (DISP.getFunction())
+      if (DISP->getFunction())
         LiveSubprograms.push_back(DISP);
       else
         SubprogramChange = true;
         LiveSubprograms.push_back(DISP);
       else
         SubprogramChange = true;
index a838bdacc56d2cb020e2b0f3c41ba8ff969f15f6..06d5aed0c5f86dbc56b8ed49bbeb61a20c411b8d 100644 (file)
@@ -753,7 +753,7 @@ bool DataFlowSanitizer::runOnModule(Module &M) {
       // Patch the pointer to LLVM function in debug info descriptor.
       auto DI = FunctionDIs.find(&F);
       if (DI != FunctionDIs.end())
       // Patch the pointer to LLVM function in debug info descriptor.
       auto DI = FunctionDIs.find(&F);
       if (DI != FunctionDIs.end())
-        DI->second.replaceFunction(&F);
+        DI->second->replaceFunction(&F);
 
       UnwrappedFnMap[WrappedFnCst] = &F;
       *i = NewF;
 
       UnwrappedFnMap[WrappedFnCst] = &F;
       *i = NewF;
index b94124fb2f64be04ee0481ea9298d869b1d2f61b..5791ae10e85cd5818d85597137ec2ff86e365cc8 100644 (file)
@@ -149,10 +149,10 @@ ModulePass *llvm::createGCOVProfilerPass(const GCOVOptions &Options) {
   return new GCOVProfiler(Options);
 }
 
   return new GCOVProfiler(Options);
 }
 
-static StringRef getFunctionName(DISubprogram SP) {
-  if (!SP.getLinkageName().empty())
-    return SP.getLinkageName();
-  return SP.getName();
+static StringRef getFunctionName(MDSubprogram *SP) {
+  if (!SP->getLinkageName().empty())
+    return SP->getLinkageName();
+  return SP->getName();
 }
 
 namespace {
 }
 
 namespace {
@@ -315,7 +315,7 @@ namespace {
            ReturnBlock(1, os) {
       this->os = os;
 
            ReturnBlock(1, os) {
       this->os = os;
 
-      Function *F = SP.getFunction();
+      Function *F = SP->getFunction();
       DEBUG(dbgs() << "Function: " << getFunctionName(SP) << "\n");
 
       uint32_t i = 0;
       DEBUG(dbgs() << "Function: " << getFunctionName(SP) << "\n");
 
       uint32_t i = 0;
@@ -330,7 +330,7 @@ namespace {
 
       std::string FunctionNameAndLine;
       raw_string_ostream FNLOS(FunctionNameAndLine);
 
       std::string FunctionNameAndLine;
       raw_string_ostream FNLOS(FunctionNameAndLine);
-      FNLOS << getFunctionName(SP) << SP.getLineNumber();
+      FNLOS << getFunctionName(SP) << SP->getLine();
       FNLOS.flush();
       FuncChecksum = hash_value(FunctionNameAndLine);
     }
       FNLOS.flush();
       FuncChecksum = hash_value(FunctionNameAndLine);
     }
@@ -366,7 +366,7 @@ namespace {
     void writeOut() {
       writeBytes(FunctionTag, 4);
       uint32_t BlockLen = 1 + 1 + 1 + lengthOfGCOVString(getFunctionName(SP)) +
     void writeOut() {
       writeBytes(FunctionTag, 4);
       uint32_t BlockLen = 1 + 1 + 1 + lengthOfGCOVString(getFunctionName(SP)) +
-          1 + lengthOfGCOVString(SP.getFilename()) + 1;
+                          1 + lengthOfGCOVString(SP->getFilename()) + 1;
       if (UseCfgChecksum)
         ++BlockLen;
       write(BlockLen);
       if (UseCfgChecksum)
         ++BlockLen;
       write(BlockLen);
@@ -375,8 +375,8 @@ namespace {
       if (UseCfgChecksum)
         write(CfgChecksum);
       writeGCOVString(getFunctionName(SP));
       if (UseCfgChecksum)
         write(CfgChecksum);
       writeGCOVString(getFunctionName(SP));
-      writeGCOVString(SP.getFilename());
-      write(SP.getLineNumber());
+      writeGCOVString(SP->getFilename());
+      write(SP->getLine());
 
       // Emit count of blocks.
       writeBytes(BlockTag, 4);
 
       // Emit count of blocks.
       writeBytes(BlockTag, 4);
@@ -493,8 +493,8 @@ void GCOVProfiler::emitProfileNotes() {
     std::string EdgeDestinations;
 
     unsigned FunctionIdent = 0;
     std::string EdgeDestinations;
 
     unsigned FunctionIdent = 0;
-    for (DISubprogram SP : CU->getSubprograms()) {
-      Function *F = SP.getFunction();
+    for (auto *SP : CU->getSubprograms()) {
+      Function *F = SP->getFunction();
       if (!F) continue;
       if (!functionHasLines(F)) continue;
 
       if (!F) continue;
       if (!functionHasLines(F)) continue;
 
@@ -541,7 +541,7 @@ void GCOVProfiler::emitProfileNotes() {
           if (SP != getDISubprogram(Loc.getScope()))
             continue;
 
           if (SP != getDISubprogram(Loc.getScope()))
             continue;
 
-          GCOVLines &Lines = Block.getFile(SP.getFilename());
+          GCOVLines &Lines = Block.getFile(SP->getFilename());
           Lines.addLine(Loc.getLine());
         }
       }
           Lines.addLine(Loc.getLine());
         }
       }
@@ -572,8 +572,8 @@ bool GCOVProfiler::emitProfileArcs() {
   for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
     DICompileUnit CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i));
     SmallVector<std::pair<GlobalVariable *, MDNode *>, 8> CountersBySP;
   for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
     DICompileUnit CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i));
     SmallVector<std::pair<GlobalVariable *, MDNode *>, 8> CountersBySP;
-    for (DISubprogram SP : CU->getSubprograms()) {
-      Function *F = SP.getFunction();
+    for (auto *SP : CU->getSubprograms()) {
+      Function *F = SP->getFunction();
       if (!F) continue;
       if (!functionHasLines(F)) continue;
       if (!Result) Result = true;
       if (!F) continue;
       if (!functionHasLines(F)) continue;
       if (!Result) Result = true;
@@ -593,7 +593,7 @@ bool GCOVProfiler::emitProfileArcs() {
                            GlobalValue::InternalLinkage,
                            Constant::getNullValue(CounterTy),
                            "__llvm_gcov_ctr");
                            GlobalValue::InternalLinkage,
                            Constant::getNullValue(CounterTy),
                            "__llvm_gcov_ctr");
-      CountersBySP.push_back(std::make_pair(Counters, (MDNode*)SP));
+      CountersBySP.push_back(std::make_pair(Counters, SP));
 
       UniqueVector<BasicBlock *> ComplexEdgePreds;
       UniqueVector<BasicBlock *> ComplexEdgeSuccs;
 
       UniqueVector<BasicBlock *> ComplexEdgePreds;
       UniqueVector<BasicBlock *> ComplexEdgeSuccs;
@@ -854,7 +854,7 @@ Function *GCOVProfiler::insertCounterWriteout(
                           Builder.CreateGlobalStringPtr(ReversedVersion),
                           Builder.getInt32(CfgChecksum));
       for (unsigned j = 0, e = CountersBySP.size(); j != e; ++j) {
                           Builder.CreateGlobalStringPtr(ReversedVersion),
                           Builder.getInt32(CfgChecksum));
       for (unsigned j = 0, e = CountersBySP.size(); j != e; ++j) {
-        DISubprogram SP = cast_or_null<MDSubprogram>(CountersBySP[j].second);
+        auto *SP = cast_or_null<MDSubprogram>(CountersBySP[j].second);
         uint32_t FuncChecksum = Funcs.empty() ? 0 : Funcs[j]->getFuncChecksum();
         Builder.CreateCall5(
             EmitFunction, Builder.getInt32(j),
         uint32_t FuncChecksum = Funcs.empty() ? 0 : Funcs[j]->getFuncChecksum();
         Builder.CreateCall5(
             EmitFunction, Builder.getInt32(j),
index 6487ea64da52187123f7f9681cd407bd98a42e53..f99fe3f5512120156154d6fa4128e357a6ec803f 100644 (file)
@@ -642,8 +642,8 @@ void SampleProfileLoader::propagateWeights(Function &F) {
 /// \returns the line number where \p F is defined. If it returns 0,
 ///          it means that there is no debug information available for \p F.
 unsigned SampleProfileLoader::getFunctionLoc(Function &F) {
 /// \returns the line number where \p F is defined. If it returns 0,
 ///          it means that there is no debug information available for \p F.
 unsigned SampleProfileLoader::getFunctionLoc(Function &F) {
-  if (DISubprogram S = getDISubprogram(&F))
-    return S.getLineNumber();
+  if (MDSubprogram *S = getDISubprogram(&F))
+    return S->getLine();
 
   // If could not find the start of \p F, emit a diagnostic to inform the user
   // about the missed opportunity.
 
   // If could not find the start of \p F, emit a diagnostic to inform the user
   // about the missed opportunity.
index a376c3df74477457902e287f58c89420e9f76204..5cc8c6df686b5f8443e9b38f7f3208c505156f52 100644 (file)
@@ -157,7 +157,8 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
 // Find the MDNode which corresponds to the DISubprogram data that described F.
 static MDNode* FindSubprogram(const Function *F, DebugInfoFinder &Finder) {
   for (DISubprogram Subprogram : Finder.subprograms()) {
 // Find the MDNode which corresponds to the DISubprogram data that described F.
 static MDNode* FindSubprogram(const Function *F, DebugInfoFinder &Finder) {
   for (DISubprogram Subprogram : Finder.subprograms()) {
-    if (Subprogram.describes(F)) return Subprogram;
+    if (Subprogram->describes(F))
+      return Subprogram;
   }
   return nullptr;
 }
   }
   return nullptr;
 }
index 846211ba781eb13e60d2277830f90a580ded6325..8031d56a82650a685bf2d2e413fc7ca874b24f69 100644 (file)
@@ -53,11 +53,11 @@ struct BreakpointPrinter : public ModulePass {
     if (NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.sp"))
       for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
         std::string Name;
     if (NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.sp"))
       for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
         std::string Name;
-        DISubprogram SP = cast_or_null<MDSubprogram>(NMD->getOperand(i));
+        auto *SP = cast_or_null<MDSubprogram>(NMD->getOperand(i));
         if (!SP)
           continue;
         if (!SP)
           continue;
-        getContextName(SP.getContext().resolve(TypeIdentifierMap), Name);
-        Name = Name + SP.getDisplayName().str();
+        getContextName(SP->getScope().resolve(TypeIdentifierMap), Name);
+        Name = Name + SP->getDisplayName().str();
         if (!Name.empty() && Processed.insert(Name).second) {
           Out << Name << "\n";
         }
         if (!Name.empty() && Processed.insert(Name).second) {
           Out << Name << "\n";
         }
index b2f71c9953feb80f37681bf24950160b1da9e490..807a2f0315240cadf046bde56e32a9168fb06a01 100644 (file)
@@ -304,8 +304,9 @@ TEST_F(CloneFunc, Subprogram) {
   Iter++;
   DISubprogram Sub2 = cast<MDSubprogram>(*Iter);
 
   Iter++;
   DISubprogram Sub2 = cast<MDSubprogram>(*Iter);
 
-  EXPECT_TRUE((Sub1.getFunction() == OldFunc && Sub2.getFunction() == NewFunc)
-           || (Sub1.getFunction() == NewFunc && Sub2.getFunction() == OldFunc));
+  EXPECT_TRUE(
+      (Sub1->getFunction() == OldFunc && Sub2->getFunction() == NewFunc) ||
+      (Sub1->getFunction() == NewFunc && Sub2->getFunction() == OldFunc));
 }
 
 // Test that the new subprogram entry was not added to the CU which doesn't
 }
 
 // Test that the new subprogram entry was not added to the CU which doesn't
@@ -347,10 +348,10 @@ TEST_F(CloneFunc, InstructionOwnership) {
       EXPECT_EQ(OldDL.getCol(), NewDL.getCol());
 
       // But that they belong to different functions
       EXPECT_EQ(OldDL.getCol(), NewDL.getCol());
 
       // But that they belong to different functions
-      DISubprogram OldSubprogram = cast<MDSubprogram>(OldDL.getScope());
-      DISubprogram NewSubprogram = cast<MDSubprogram>(NewDL.getScope());
-      EXPECT_EQ(OldFunc, OldSubprogram.getFunction());
-      EXPECT_EQ(NewFunc, NewSubprogram.getFunction());
+      auto *OldSubprogram = cast<MDSubprogram>(OldDL.getScope());
+      auto *NewSubprogram = cast<MDSubprogram>(NewDL.getScope());
+      EXPECT_EQ(OldFunc, OldSubprogram->getFunction());
+      EXPECT_EQ(NewFunc, NewSubprogram->getFunction());
     }
 
     ++OldIter;
     }
 
     ++OldIter;
@@ -384,25 +385,25 @@ TEST_F(CloneFunc, DebugIntrinsics) {
                          getParent()->getParent());
 
       // Old variable must belong to the old function
                          getParent()->getParent());
 
       // Old variable must belong to the old function
-      EXPECT_EQ(OldFunc, DISubprogram(cast<MDSubprogram>(
-                                          OldIntrin->getVariable()->getScope()))
-                             .getFunction());
+      EXPECT_EQ(OldFunc,
+                cast<MDSubprogram>(OldIntrin->getVariable()->getScope())
+                    ->getFunction());
       // New variable must belong to the New function
       // New variable must belong to the New function
-      EXPECT_EQ(NewFunc, DISubprogram(cast<MDSubprogram>(
-                                          NewIntrin->getVariable()->getScope()))
-                             .getFunction());
+      EXPECT_EQ(NewFunc,
+                cast<MDSubprogram>(NewIntrin->getVariable()->getScope())
+                    ->getFunction());
     } else if (DbgValueInst* OldIntrin = dyn_cast<DbgValueInst>(&OldI)) {
       DbgValueInst* NewIntrin = dyn_cast<DbgValueInst>(&NewI);
       EXPECT_TRUE(NewIntrin);
 
       // Old variable must belong to the old function
     } else if (DbgValueInst* OldIntrin = dyn_cast<DbgValueInst>(&OldI)) {
       DbgValueInst* NewIntrin = dyn_cast<DbgValueInst>(&NewI);
       EXPECT_TRUE(NewIntrin);
 
       // Old variable must belong to the old function
-      EXPECT_EQ(OldFunc, DISubprogram(cast<MDSubprogram>(
-                                          OldIntrin->getVariable()->getScope()))
-                             .getFunction());
+      EXPECT_EQ(OldFunc,
+                cast<MDSubprogram>(OldIntrin->getVariable()->getScope())
+                    ->getFunction());
       // New variable must belong to the New function
       // New variable must belong to the New function
-      EXPECT_EQ(NewFunc, DISubprogram(cast<MDSubprogram>(
-                                          NewIntrin->getVariable()->getScope()))
-                             .getFunction());
+      EXPECT_EQ(NewFunc,
+                cast<MDSubprogram>(NewIntrin->getVariable()->getScope())
+                    ->getFunction());
     }
 
     ++OldIter;
     }
 
     ++OldIter;