This revision was automatically updated to reflect the committed changes. Closed by commit rGcac4d7ff4652: [CodeGen] Only consider innermost cast for !heapallocsite (authored by nikic). Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145788/new/ https://reviews.llvm.org/D145788 Files: clang/lib/CodeGen/CGExprScalar.cpp clang/test/CodeGen/debug-info-codeview-heapallocsite.c Index: clang/test/CodeGen/debug-info-codeview-heapallocsite.c =================================================================== --- clang/test/CodeGen/debug-info-codeview-heapallocsite.c +++ clang/test/CodeGen/debug-info-codeview-heapallocsite.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -no-opaque-pointers -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 -o - | FileCheck %s struct Foo; struct Bar; @@ -14,10 +14,10 @@ } // 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 [[DBG3:!.*]] +// CHECK: call ptr {{.*}}@alloc_void{{.*}} !heapallocsite [[DBG1:!.*]] +// CHECK: call ptr {{.*}}@alloc_foo{{.*}} !heapallocsite [[DBG2:!.*]] +// CHECK: call ptr {{.*}}@alloc_void{{.*}} !heapallocsite [[DBG2]] +// CHECK: call ptr {{.*}}@alloc_void{{.*}} !heapallocsite [[DBG3:!.*]] // CHECK: [[DBG2]] = !DICompositeType(tag: DW_TAG_structure_type, // CHECK-SAME: name: "Foo" Index: clang/lib/CodeGen/CGExprScalar.cpp =================================================================== --- clang/lib/CodeGen/CGExprScalar.cpp +++ clang/lib/CodeGen/CGExprScalar.cpp @@ -2098,7 +2098,8 @@ // 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)) { + if (CI->getMetadata("heapallocsite") && isa<ExplicitCastExpr>(CE) && + !isa<CastExpr>(E)) { QualType PointeeType = DestTy->getPointeeType(); if (!PointeeType.isNull()) CGF.getDebugInfo()->addHeapAllocSiteMetadata(CI, PointeeType,
Index: clang/test/CodeGen/debug-info-codeview-heapallocsite.c =================================================================== --- clang/test/CodeGen/debug-info-codeview-heapallocsite.c +++ clang/test/CodeGen/debug-info-codeview-heapallocsite.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -no-opaque-pointers -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 -o - | FileCheck %s struct Foo; struct Bar; @@ -14,10 +14,10 @@ } // 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 [[DBG3:!.*]] +// CHECK: call ptr {{.*}}@alloc_void{{.*}} !heapallocsite [[DBG1:!.*]] +// CHECK: call ptr {{.*}}@alloc_foo{{.*}} !heapallocsite [[DBG2:!.*]] +// CHECK: call ptr {{.*}}@alloc_void{{.*}} !heapallocsite [[DBG2]] +// CHECK: call ptr {{.*}}@alloc_void{{.*}} !heapallocsite [[DBG3:!.*]] // CHECK: [[DBG2]] = !DICompositeType(tag: DW_TAG_structure_type, // CHECK-SAME: name: "Foo" Index: clang/lib/CodeGen/CGExprScalar.cpp =================================================================== --- clang/lib/CodeGen/CGExprScalar.cpp +++ clang/lib/CodeGen/CGExprScalar.cpp @@ -2098,7 +2098,8 @@ // 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)) { + if (CI->getMetadata("heapallocsite") && isa<ExplicitCastExpr>(CE) && + !isa<CastExpr>(E)) { QualType PointeeType = DestTy->getPointeeType(); if (!PointeeType.isNull()) CGF.getDebugInfo()->addHeapAllocSiteMetadata(CI, PointeeType,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits