[clang] 059ba74 - Revert "[codeview] Put !heapallocsite on calls to operator new"

Eric Christopher via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 9 10:08:29 PDT 2020


FWIW before you reapply this let me know. I've seen some other failures
associated and would like to give it a run through.

-eric

On Sat, Jun 6, 2020 at 4:38 PM Douglas Yung via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

>
> Author: Douglas Yung
> Date: 2020-06-06T23:30:46Z
> New Revision: 059ba74bb6f6166ca7c1783ef81dd37a5209b758
>
> URL:
> https://github.com/llvm/llvm-project/commit/059ba74bb6f6166ca7c1783ef81dd37a5209b758
> DIFF:
> https://github.com/llvm/llvm-project/commit/059ba74bb6f6166ca7c1783ef81dd37a5209b758.diff
>
> LOG: Revert "[codeview] Put !heapallocsite on calls to operator new"
>
> This reverts commit 672ed5386024ba5cee53e19d637b7920a4889837.
>
> This commit is hitting an assertion failure across multiple bots in the
> test:
> Profile-<arch> :: instrprof-gcov-multithread_fork.test
>
> Failing bots include:
> http://lab.llvm.org:8011/builders/llvm-avr-linux/builds/2205
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/8967
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/10789
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/27750
> http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/16751
>
> Added:
>
>
> Modified:
>     clang/lib/CodeGen/CGCall.cpp
>     clang/lib/CodeGen/CGDebugInfo.cpp
>     clang/lib/CodeGen/CGDebugInfo.h
>     clang/lib/CodeGen/CGExprCXX.cpp
>     clang/lib/CodeGen/CGExprScalar.cpp
>     clang/test/CodeGen/debug-info-codeview-heapallocsite.c
>
> Removed:
>     clang/test/CodeGenCXX/debug-info-codeview-heapallocsite.cpp
>
>
>
> ################################################################################
> diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
> index 136782fccf40..6bde3124555b 100644
> --- a/clang/lib/CodeGen/CGCall.cpp
> +++ b/clang/lib/CodeGen/CGCall.cpp
> @@ -4951,7 +4951,7 @@ RValue CodeGenFunction::EmitCall(const
> CGFunctionInfo &CallInfo,
>    // Add metadata for calls to MSAllocator functions
>    if (getDebugInfo() && TargetDecl &&
>        TargetDecl->hasAttr<MSAllocatorAttr>())
> -    getDebugInfo()->addHeapAllocSiteMetadata(CI, RetTy->getPointeeType(),
> Loc);
> +    getDebugInfo()->addHeapAllocSiteMetadata(CI, RetTy, Loc);
>
>    // 4. Finish the call.
>
>
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp
> b/clang/lib/CodeGen/CGDebugInfo.cpp
> index 1737154d179a..cc50ec6a8c89 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.cpp
> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
> @@ -2146,14 +2146,16 @@ llvm::DIType
> *CGDebugInfo::getOrCreateStandaloneType(QualType D,
>    return T;
>  }
>
> -void CGDebugInfo::addHeapAllocSiteMetadata(llvm::CallBase *CI,
> -                                           QualType AllocatedTy,
> +void CGDebugInfo::addHeapAllocSiteMetadata(llvm::Instruction *CI,
> +                                           QualType D,
>                                             SourceLocation Loc) {
>    llvm::MDNode *node;
> -  if (AllocatedTy->isVoidType())
> +  if (D.getTypePtr()->isVoidPointerType()) {
>      node = llvm::MDNode::get(CGM.getLLVMContext(), None);
> -  else
> -    node = getOrCreateType(AllocatedTy, getOrCreateFile(Loc));
> +  } else {
> +    QualType PointeeTy = D.getTypePtr()->getPointeeType();
> +    node = getOrCreateType(PointeeTy, getOrCreateFile(Loc));
> +  }
>
>    CI->setMetadata("heapallocsite", node);
>  }
>
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.h
> b/clang/lib/CodeGen/CGDebugInfo.h
> index 96ef6c7c1d27..367047e79dc9 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.h
> +++ b/clang/lib/CodeGen/CGDebugInfo.h
> @@ -509,7 +509,7 @@ class CGDebugInfo {
>    llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation
> Loc);
>
>    /// Add heapallocsite metadata for MSAllocator calls.
> -  void addHeapAllocSiteMetadata(llvm::CallBase *CallSite, QualType
> AllocatedTy,
> +  void addHeapAllocSiteMetadata(llvm::Instruction *CallSite, QualType Ty,
>                                  SourceLocation Loc);
>
>    void completeType(const EnumDecl *ED);
>
> diff  --git a/clang/lib/CodeGen/CGExprCXX.cpp
> b/clang/lib/CodeGen/CGExprCXX.cpp
> index dfae2bc5e47a..d0012337cdd3 100644
> --- a/clang/lib/CodeGen/CGExprCXX.cpp
> +++ b/clang/lib/CodeGen/CGExprCXX.cpp
> @@ -1638,13 +1638,6 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const
> CXXNewExpr *E) {
>      RValue RV =
>        EmitNewDeleteCall(*this, allocator, allocatorType, allocatorArgs);
>
> -    // Set !heapallocsite metadata on the call to operator new.
> -    if (getDebugInfo()) {
> -      if (auto *newCall = dyn_cast<llvm::CallBase>(RV.getScalarVal()))
> -        getDebugInfo()->addHeapAllocSiteMetadata(newCall, allocType,
> -                                                 E->getExprLoc());
> -    }
> -
>      // If this was a call to a global replaceable allocation function
> that does
>      // not take an alignment argument, the allocator is known to produce
>      // storage that's suitably aligned for any object that fits, up to a
> known
>
> diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp
> b/clang/lib/CodeGen/CGExprScalar.cpp
> index 612a2ecef843..b169462f535a 100644
> --- a/clang/lib/CodeGen/CGExprScalar.cpp
> +++ b/clang/lib/CodeGen/CGExprScalar.cpp
> @@ -2065,15 +2065,11 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr
> *CE) {
>        }
>      }
>
> -    // Update heapallocsite metadata when there is an explicit pointer
> cast.
> -    if (auto *CI = dyn_cast<llvm::CallBase>(Src)) {
> -      if (CI->getMetadata("heapallocsite") && isa<ExplicitCastExpr>(CE)) {
> -        QualType PointeeType = DestTy->getPointeeType();
> -        if (!PointeeType.isNull())
> -          CGF.getDebugInfo()->addHeapAllocSiteMetadata(CI, PointeeType,
> -                                                       CE->getExprLoc());
> -      }
> -    }
> +    // Update heapallocsite metadata when there is an explicit cast.
> +    if (llvm::CallInst *CI = dyn_cast<llvm::CallInst>(Src))
> +      if (CI->getMetadata("heapallocsite") && isa<ExplicitCastExpr>(CE))
> +          CGF.getDebugInfo()->
> +              addHeapAllocSiteMetadata(CI, CE->getType(),
> CE->getExprLoc());
>
>      return Builder.CreateBitCast(Src, DstTy);
>    }
>
> diff  --git a/clang/test/CodeGen/debug-info-codeview-heapallocsite.c
> b/clang/test/CodeGen/debug-info-codeview-heapallocsite.c
> index 25c102b1c37d..dfc0d19b25e8 100644
> --- a/clang/test/CodeGen/debug-info-codeview-heapallocsite.c
> +++ b/clang/test/CodeGen/debug-info-codeview-heapallocsite.c
> @@ -1,22 +1,19 @@
> -// RUN: %clang_cc1 -triple x86_64-windows-msvc -debug-info-kind=limited
> -gcodeview -fdeclspec -S -emit-llvm %s -o - | FileCheck %s
> +// RUN: %clang_cc1 -triple x86_64-windows-msvc -debug-info-kind=limited
> -gcodeview -fdeclspec -S -emit-llvm < %s | FileCheck %s
>
>  struct Foo;
>  struct Bar;
>
>  __declspec(allocator) void *alloc_void();
> -__declspec(allocator) struct Foo *alloc_foo();
>
>  void call_alloc() {
>    struct Foo *p = alloc_void();
> -  struct Foo *w = alloc_foo();
>    struct Foo *q = (struct Foo*)alloc_void();
>    struct Foo *r = (struct Foo*)(struct Bar*)alloc_void();
>  }
>
>  // CHECK-LABEL: define {{.*}}void @call_alloc
>  // CHECK: call i8* {{.*}}@alloc_void{{.*}} !heapallocsite [[DBG1:!.*]]
> -// CHECK: call %struct.Foo* {{.*}}@alloc_foo{{.*}} !heapallocsite
> [[DBG2:!.*]]
> -// CHECK: call i8* {{.*}}@alloc_void{{.*}} !heapallocsite [[DBG2]]
> +// CHECK: call i8* {{.*}}@alloc_void{{.*}} !heapallocsite [[DBG2:!.*]]
>  // CHECK: call i8* {{.*}}@alloc_void{{.*}} !heapallocsite [[DBG3:!.*]]
>
>  // CHECK: [[DBG1]] = !{}
>
> diff  --git a/clang/test/CodeGenCXX/debug-info-codeview-heapallocsite.cpp
> b/clang/test/CodeGenCXX/debug-info-codeview-heapallocsite.cpp
> deleted file mode 100644
> index ab1101c67094..000000000000
> --- a/clang/test/CodeGenCXX/debug-info-codeview-heapallocsite.cpp
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -// RUN: %clang_cc1 -fexceptions -triple x86_64-windows-msvc
> -debug-info-kind=limited -gcodeview -fdeclspec -S -emit-llvm %s -o - |
> FileCheck %s
> -
> -struct Foo {
> -  int x;
> -};
> -struct Bar {
> -  int y;
> -};
> -extern Foo *gv_foo;
> -extern Bar *gv_bar;
> -extern "C" void doit() {
> -  gv_foo = new Foo();
> -  gv_bar = new Bar();
> -}
> -
> -// CHECK-LABEL: define {{.*}}void @doit
> -// CHECK: call {{.*}} i8* {{.*}}@"??2 at YAPEAX_K@Z"(i64 4) {{.*}}
> !heapallocsite [[DBG_FOO:!.*]]
> -// CHECK: call {{.*}} i8* {{.*}}@"??2 at YAPEAX_K@Z"(i64 4) {{.*}}
> !heapallocsite [[DBG_BAR:!.*]]
> -
> -extern "C" void useinvoke() {
> -  struct HasDtor {
> -    ~HasDtor() { delete gv_foo; }
> -  } o;
> -  gv_foo = new Foo();
> -}
> -
> -// CHECK-LABEL: define {{.*}}void @useinvoke
> -// CHECK: invoke {{.*}} i8* {{.*}}@"??2 at YAPEAX_K@Z"(i64 4)
> -// CHECK-NEXT: to label {{.*}} unwind label {{.*}} !heapallocsite
> [[DBG_FOO]]
> -
> -// CHECK: [[DBG_FOO]] = distinct !DICompositeType(tag:
> DW_TAG_structure_type,
> -// CHECK-SAME:                                 name: "Foo"
> -// CHECK: [[DBG_BAR]] = distinct !DICompositeType(tag:
> DW_TAG_structure_type,
> -// CHECK-SAME:                                 name: "Bar"
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200609/962d2e0f/attachment.html>


More information about the cfe-commits mailing list