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