Commit 26f2268c authored by David Blaikie's avatar David Blaikie
Browse files

Revert "Recommit r212203: Don't try to construct debug LexicalScopes hierarchy...

Revert "Recommit r212203: Don't try to construct debug LexicalScopes hierarchy for functions that do not have top level debug information."

This reverts commit r212649 while I investigate/reduce/etc PR20367.

llvm-svn: 213581
parent 9c4c3c58
Loading
Loading
Loading
Loading
+1 −16
Original line number Diff line number Diff line
@@ -731,8 +731,6 @@ void DwarfDebug::beginModule() {

  const Module *M = MMI->getModule();

  FunctionDIs = makeSubprogramMap(*M);

  // If module has named metadata anchors then use them, otherwise scan the
  // module using debug info finder to collect debug info.
  NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu");
@@ -1418,10 +1416,6 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
  if (!MMI->hasDebugInfo())
    return;

  auto DI = FunctionDIs.find(MF->getFunction());
  if (DI == FunctionDIs.end())
    return;

  // Grab the lexical scopes for the function, if we don't have any of those
  // then we're not going to be able to do anything.
  LScopes.initialize(*MF);
@@ -1437,14 +1431,6 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
  // belongs to so that we add to the correct per-cu line table in the
  // non-asm case.
  LexicalScope *FnScope = LScopes.getCurrentFunctionScope();
  // FnScope->getScopeNode() and DI->second should represent the same function,
  // though they may not be the same MDNode due to inline functions merged in
  // LTO where the debug info metadata still differs (either due to distinct
  // written differences - two versions of a linkonce_odr function
  // written/copied into two separate files, or some sub-optimal metadata that
  // isn't structurally identical (see: file path/name info from clang, which
  // includes the directory of the cpp file being built, even when the file name
  // is absolute (such as an <> lookup header)))
  DwarfCompileUnit *TheCU = SPMap.lookup(FnScope->getScopeNode());
  assert(TheCU && "Unable to find compile unit!");
  if (Asm->OutStreamer.hasRawTextSupport())
@@ -1542,8 +1528,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
    assert(CurFn == MF);
  assert(CurFn != nullptr);

  if (!MMI->hasDebugInfo() || LScopes.empty() ||
      !FunctionDIs.count(MF->getFunction())) {
  if (!MMI->hasDebugInfo() || LScopes.empty()) {
    // If we don't have a lexical scope for this function then there will
    // be a hole in the range information. Keep note of this by setting the
    // previously used section to nullptr.
+0 −2
Original line number Diff line number Diff line
@@ -330,8 +330,6 @@ class DwarfDebug : public AsmPrinterHandler {
  DwarfAccelTable AccelNamespace;
  DwarfAccelTable AccelTypes;

  DenseMap<const Function *, DISubprogram> FunctionDIs;

  MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);

  void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
+3 −12
Original line number Diff line number Diff line
@@ -329,13 +329,12 @@ class LDVImpl {
  void computeIntervals();

public:
  LDVImpl(LiveDebugVariables *ps)
      : pass(*ps), MF(nullptr), EmitDone(false), ModifiedMF(false) {}
  LDVImpl(LiveDebugVariables *ps) : pass(*ps), EmitDone(false),
                                    ModifiedMF(false) {}
  bool runOnMachineFunction(MachineFunction &mf);

  /// clear - Release all memory.
  void clear() {
    MF = nullptr;
    userValues.clear();
    virtRegToEqClass.clear();
    userVarMap.clear();
@@ -694,11 +693,11 @@ void LDVImpl::computeIntervals() {
}

bool LDVImpl::runOnMachineFunction(MachineFunction &mf) {
  clear();
  MF = &mf;
  LIS = &pass.getAnalysis<LiveIntervals>();
  MDT = &pass.getAnalysis<MachineDominatorTree>();
  TRI = mf.getTarget().getRegisterInfo();
  clear();
  LS.initialize(mf);
  DEBUG(dbgs() << "********** COMPUTING LIVE DEBUG VARIABLES: "
               << mf.getName() << " **********\n");
@@ -713,8 +712,6 @@ bool LDVImpl::runOnMachineFunction(MachineFunction &mf) {
bool LiveDebugVariables::runOnMachineFunction(MachineFunction &mf) {
  if (!EnableLDV)
    return false;
  if (!FunctionDIs.count(mf.getFunction()))
    return false;
  if (!pImpl)
    pImpl = new LDVImpl(this);
  return static_cast<LDVImpl*>(pImpl)->runOnMachineFunction(mf);
@@ -977,8 +974,6 @@ void UserValue::emitDebugValues(VirtRegMap *VRM, LiveIntervals &LIS,

void LDVImpl::emitDebugValues(VirtRegMap *VRM) {
  DEBUG(dbgs() << "********** EMITTING LIVE DEBUG VARIABLES **********\n");
  if (!MF)
    return;
  const TargetInstrInfo *TII = MF->getTarget().getInstrInfo();
  for (unsigned i = 0, e = userValues.size(); i != e; ++i) {
    DEBUG(userValues[i]->print(dbgs(), &MF->getTarget()));
@@ -993,10 +988,6 @@ void LiveDebugVariables::emitDebugValues(VirtRegMap *VRM) {
    static_cast<LDVImpl*>(pImpl)->emitDebugValues(VRM);
}

bool LiveDebugVariables::doInitialization(Module &M) {
  FunctionDIs = makeSubprogramMap(M);
  return Pass::doInitialization(M);
}

#ifndef NDEBUG
void LiveDebugVariables::dump() {
+0 −3
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@
#define LLVM_CODEGEN_LIVEDEBUGVARIABLES_H

#include "llvm/ADT/ArrayRef.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/CodeGen/MachineFunctionPass.h"

namespace llvm {
@@ -33,7 +32,6 @@ class VirtRegMap;

class LiveDebugVariables : public MachineFunctionPass {
  void *pImpl;
  DenseMap<const Function*, DISubprogram> FunctionDIs;
public:
  static char ID; // Pass identification, replacement for typeid

@@ -66,7 +64,6 @@ private:
  bool runOnMachineFunction(MachineFunction &) override;
  void releaseMemory() override;
  void getAnalysisUsage(AnalysisUsage &) const override;
  bool doInitialization(Module &) override;

};

+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
!llvm.dbg.lv = !{!0, !14, !15, !16, !17, !24, !25, !28}

!0 = metadata !{i32 786689, metadata !1, metadata !"this", metadata !3, i32 11, metadata !12, i32 0, null} ; [ DW_TAG_arg_variable ]
!1 = metadata !{i32 786478, metadata !31, metadata !2, metadata !"bar", metadata !"bar", metadata !"_ZN3foo3barEi", i32 11, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 true, i32 (%struct.foo*, i32)* null, null, null, null, i32 11} ; [ DW_TAG_subprogram ]
!1 = metadata !{i32 786478, metadata !31, metadata !2, metadata !"bar", metadata !"bar", metadata !"_ZN3foo3barEi", i32 11, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 true, i32 (%struct.foo*, i32)* @_ZN3foo3bazEi, null, null, null, i32 11} ; [ DW_TAG_subprogram ]
!2 = metadata !{i32 786451, metadata !31, metadata !3, metadata !"foo", i32 3, i64 32, i64 32, i64 0, i32 0, null, metadata !5, i32 0, null, null, null} ; [ DW_TAG_structure_type ] [foo] [line 3, size 32, align 32, offset 0] [def] [from ]
!3 = metadata !{i32 786473, metadata !31} ; [ DW_TAG_file_type ]
!4 = metadata !{i32 786449, metadata !31, i32 4, metadata !"4.2.1 LLVM build", i1 true, metadata !"", i32 0, metadata !32, metadata !32, metadata !33, null, null, metadata !""} ; [ DW_TAG_compile_unit ]
Loading