Commit caf3166d authored by Alexandre Ganea's avatar Alexandre Ganea
Browse files

Revert "re-land [DebugInfo] Add debug location to stubs generated by CGDeclCXX...

Revert "re-land [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial"

This reverts commit 9c1baa23.
parent 50e99563
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ enum class DynamicInitKind : unsigned {
  NoStub = 0,
  Initializer,
  AtExit,
  GlobalArrayDestructor
};

/// GlobalDecl - represents a global declaration. This can either be a
+2 −5
Original line number Diff line number Diff line
@@ -1944,8 +1944,7 @@ StringRef CGDebugInfo::getDynamicInitializerName(const VarDecl *VD,
                                                 llvm::Function *InitFn) {
  // If we're not emitting codeview, use the mangled name. For Itanium, this is
  // arbitrary.
  if (!CGM.getCodeGenOpts().EmitCodeView ||
      StubKind == DynamicInitKind::GlobalArrayDestructor)
  if (!CGM.getCodeGenOpts().EmitCodeView)
    return InitFn->getName();

  // Print the normal qualified name for the variable, then break off the last
@@ -1970,7 +1969,6 @@ StringRef CGDebugInfo::getDynamicInitializerName(const VarDecl *VD,

  switch (StubKind) {
  case DynamicInitKind::NoStub:
  case DynamicInitKind::GlobalArrayDestructor:
    llvm_unreachable("not an initializer");
  case DynamicInitKind::Initializer:
    OS << "`dynamic initializer for '";
@@ -3646,8 +3644,7 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, SourceLocation Loc,
  if (Name.startswith("\01"))
    Name = Name.substr(1);

  if (!HasDecl || D->isImplicit() || D->hasAttr<ArtificialAttr>() ||
      (isa<VarDecl>(D) && GD.getDynamicInitKind() != DynamicInitKind::NoStub)) {
  if (!HasDecl || D->isImplicit() || D->hasAttr<ArtificialAttr>()) {
    Flags |= llvm::DINode::FlagArtificial;
    // Artificial functions should not silently reuse CurLoc.
    CurLoc = SourceLocation();
+3 −9
Original line number Diff line number Diff line
@@ -244,8 +244,6 @@ llvm::Function *CodeGenFunction::createAtExitStub(const VarDecl &VD,

  CGF.StartFunction(GlobalDecl(&VD, DynamicInitKind::AtExit),
                    CGM.getContext().VoidTy, fn, FI, FunctionArgList());
  // Emit an artificial location for this function.
  auto AL = ApplyDebugLocation::CreateArtificial(CGF);

  llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr);

@@ -646,9 +644,8 @@ void CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,

  StartFunction(GlobalDecl(D, DynamicInitKind::Initializer),
                getContext().VoidTy, Fn, getTypes().arrangeNullaryFunction(),
                FunctionArgList());
  // Emit an artificial location for this function.
  auto AL = ApplyDebugLocation::CreateArtificial(*this);
                FunctionArgList(), D->getLocation(),
                D->getInit()->getExprLoc());

  // Use guarded initialization if the global variable is weak. This
  // occurs for, e.g., instantiated static data members and
@@ -773,10 +770,7 @@ llvm::Function *CodeGenFunction::generateDestroyHelper(

  CurEHLocation = VD->getBeginLoc();

  StartFunction(GlobalDecl(VD, DynamicInitKind::GlobalArrayDestructor),
                getContext().VoidTy, fn, FI, args);
  // Emit an artificial location for this function.
  auto AL = ApplyDebugLocation::CreateArtificial(*this);
  StartFunction(VD, getContext().VoidTy, fn, FI, args);

  emitDestroy(addr, type, destroyer, useEHCleanupForArray);

+0 −20
Original line number Diff line number Diff line
// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-windows-msvc -gcodeview -debug-info-kind=limited -o - | FileCheck %s

struct a {
  ~a();
};
template <typename b> struct c : a {
  c(void (b::*)());
};
struct B {
  virtual void e();
};
c<B> *d() { static c<B> f(&B::e); return &f; }

// CHECK: define internal void @"??__Ff@?1??d@@YAPEAU?$c@UB@@@@XZ@YAXXZ"()
// CHECK-SAME: !dbg ![[SUBPROGRAM:[0-9]+]] {
// CHECK: call void @"??1?$c@UB@@@@QEAA@XZ"(%struct.c* @"?f@?1??d@@YAPEAU?$c@UB@@@@XZ@4U2@A"), !dbg ![[LOCATION:[0-9]+]]
// CHECK-NEXT: ret void, !dbg ![[LOCATION]]
// CHECK: ![[SUBPROGRAM]] = distinct !DISubprogram(name: "`dynamic atexit destructor for 'f'"
// CHECK-SAME: flags: DIFlagArtificial
// CHECK: ![[LOCATION]] = !DILocation(line: 0, scope: ![[SUBPROGRAM]])
+0 −24
Original line number Diff line number Diff line
// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-windows-msvc -gcodeview -debug-info-kind=limited -o - | FileCheck %s

struct b {
  b(char *);
  ~b();
};
struct a {
  ~a();
};
struct {
  b c;
  const a &d;
} e[]{nullptr, {}};

// CHECK: define internal void @__cxx_global_array_dtor(i8* %0)
// CHECK-SAME: !dbg ![[SUBPROGRAM:[0-9]+]] {
// CHECK: arraydestroy.body
// CHECK: %arraydestroy.elementPast =
// CHECK-SAME: !dbg ![[LOCATION:[0-9]+]]
// CHECK: call void @"??1<unnamed-type-e>@@QEAA@XZ"(%struct.anon* %arraydestroy.element)
// CHECK-SAME: !dbg ![[LOCATION]]
// CHECK: ![[SUBPROGRAM]] = distinct !DISubprogram(name: "__cxx_global_array_dtor"
// CHECK-SAME: flags: DIFlagArtificial
// CHECK: ![[LOCATION]] = !DILocation(line: 0,
Loading