durin42 updated this revision to Diff 420915.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123085/new/

https://reviews.llvm.org/D123085

Files:
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
  clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
  clang/test/CodeGenCXX/delete-two-arg.cpp
  clang/test/CodeGenCXX/delete.cpp
  clang/test/CodeGenCXX/exceptions.cpp
  clang/test/CodeGenCXX/microsoft-abi-structors.cpp

Index: clang/test/CodeGenCXX/microsoft-abi-structors.cpp
===================================================================
--- clang/test/CodeGenCXX/microsoft-abi-structors.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-structors.cpp
@@ -57,7 +57,7 @@
 //
 // DTORS:      [[CALL_DELETE_LABEL]]
 // DTORS-NEXT:   %[[THIS_AS_VOID:[0-9a-z]+]] = bitcast %"struct.basic::C"* %[[THIS]] to i8*
-// DTORS-NEXT:   call void @"??3@YAXPAX@Z"(i8* %[[THIS_AS_VOID]])
+// DTORS-NEXT:   call void @"??3@YAXPAX@Z"(i8* allocptr %[[THIS_AS_VOID]])
 // DTORS-NEXT:   br label %[[CONTINUE_LABEL]]
 //
 // DTORS:      [[CONTINUE_LABEL]]
@@ -119,7 +119,7 @@
 // CHECK-NEXT:   %[[PVDTOR:.*]] = getelementptr inbounds i8* (%"struct.basic::C"*, i32)*, i8* (%"struct.basic::C"*, i32)** %[[VTABLE]], i64 0
 // CHECK-NEXT:   %[[VDTOR:.*]] = load i8* (%"struct.basic::C"*, i32)*, i8* (%"struct.basic::C"*, i32)** %[[PVDTOR]]
 // CHECK-NEXT:   %[[CALL:.*]] = call x86_thiscallcc i8* %[[VDTOR]](%"struct.basic::C"* {{[^,]*}} %[[OBJ_PTR_VALUE]], i32 0)
-// CHECK-NEXT:   call void @"??3@YAXPAX@Z"(i8* %[[CALL]])
+// CHECK-NEXT:   call void @"??3@YAXPAX@Z"(i8* allocptr %[[CALL]])
 // CHECK:      ret void
 }
 
Index: clang/test/CodeGenCXX/exceptions.cpp
===================================================================
--- clang/test/CodeGenCXX/exceptions.cpp
+++ clang/test/CodeGenCXX/exceptions.cpp
@@ -37,7 +37,7 @@
     // CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
     // CHECK-NEXT: invoke void @_ZN5test11AC1Ei([[A]]* {{[^,]*}} [[CAST]], i32 5)
     // CHECK:      ret [[A]]* [[CAST]]
-    // CHECK:      call void @_ZdlPv(i8* [[NEW]])
+    // CHECK:      call void @_ZdlPv(i8* allocptr [[NEW]])
     return new A(5);
   }
 
@@ -48,7 +48,7 @@
     // CHECK-NEXT: [[FOO:%.*]] = invoke i32 @_ZN5test13fooEv()
     // CHECK:      invoke void @_ZN5test11AC1Ei([[A]]* {{[^,]*}} [[CAST]], i32 [[FOO]])
     // CHECK:      ret [[A]]* [[CAST]]
-    // CHECK:      call void @_ZdlPv(i8* [[NEW]])
+    // CHECK:      call void @_ZdlPv(i8* allocptr [[NEW]])
     extern int foo();
     return new A(foo());
   }
@@ -74,7 +74,7 @@
     // CHECK:      ret [[A]]* [[CAST]]
     // CHECK:      [[ISACTIVE:%.*]] = load i1, i1* [[ACTIVE]]
     // CHECK-NEXT: br i1 [[ISACTIVE]]
-    // CHECK:      call void @_ZdlPv(i8* [[NEW]])
+    // CHECK:      call void @_ZdlPv(i8* allocptr [[NEW]])
     return new A(B().x);
   }
 
@@ -102,7 +102,7 @@
     // CHECK:      ret [[A]]* [[CAST]]
     // CHECK:      [[ISACTIVE:%.*]] = load i1, i1* [[ACTIVE]]
     // CHECK-NEXT: br i1 [[ISACTIVE]]
-    // CHECK:      call void @_ZdlPv(i8* [[NEW]])
+    // CHECK:      call void @_ZdlPv(i8* allocptr [[NEW]])
     return new A(B());
   }
 
@@ -128,7 +128,7 @@
     // CHECK:      ret [[A]]* [[CAST]]
     // CHECK:      [[ISACTIVE:%.*]] = load i1, i1* [[ACTIVE]]
     // CHECK-NEXT: br i1 [[ISACTIVE]]
-    // CHECK:      call void @_ZdlPv(i8* [[NEW]])
+    // CHECK:      call void @_ZdlPv(i8* allocptr [[NEW]])
     return new A(B(), B());
   }
   A *f() {
@@ -165,7 +165,7 @@
     // CHECK:      ret [[A]]* [[RET]]
     // CHECK:      [[ISACTIVE:%.*]] = load i1, i1* [[ACTIVE]]
     // CHECK-NEXT: br i1 [[ISACTIVE]]
-    // CHECK:      call void @_ZdlPv(i8* [[NEW]])
+    // CHECK:      call void @_ZdlPv(i8* allocptr [[NEW]])
     A *x;
     return (x = new A(makeB()), makeB(), x);
   }
@@ -458,7 +458,7 @@
   }
   // CHECK: define{{.*}} {{%.*}}* @_ZN5test94testEv
   // CHECK: [[TEST9_NEW:%.*]] = call noalias nonnull i8* @_Znam
-  // CHECK: call void @_ZdaPv(i8* [[TEST9_NEW]])
+  // CHECK: call void @_ZdaPv(i8* allocptr [[TEST9_NEW]])
 }
 
 // In a destructor with a function-try-block, a return statement in a
Index: clang/test/CodeGenCXX/delete.cpp
===================================================================
--- clang/test/CodeGenCXX/delete.cpp
+++ clang/test/CodeGenCXX/delete.cpp
@@ -100,7 +100,7 @@
     // CHECK-NEXT: call void @_ZN5test11AD1Ev([[A]]* {{[^,]*}} [[CUR]])
     // CHECK-NEXT: [[ISDONE:%.*]] = icmp eq [[A]]* [[CUR]], [[BEGIN]]
     // CHECK-NEXT: br i1 [[ISDONE]]
-    // CHECK:      call void @_ZdaPv(i8* noundef [[ALLOC]])
+    // CHECK:      call void @_ZdaPv(i8* allocptr noundef [[ALLOC]])
   }
 }
 
@@ -146,7 +146,7 @@
     // CHECK-NEXT: [[DTOR:%.*]] = load void ([[X]]*)*, void ([[X]]*)** [[T0]]
     // CHECK-NEXT: call void [[DTOR]]([[X]]* {{[^,]*}} [[OBJ:%.*]])
     //   Call the global operator delete.
-    // CHECK-NEXT: call void @_ZdlPv(i8* noundef [[ALLOCATED]]) [[NUW:#[0-9]+]]
+    // CHECK-NEXT: call void @_ZdlPv(i8* allocptr noundef [[ALLOCATED]]) [[NUW:#[0-9]+]]
     ::delete xp;
   }
 }
Index: clang/test/CodeGenCXX/delete-two-arg.cpp
===================================================================
--- clang/test/CodeGenCXX/delete-two-arg.cpp
+++ clang/test/CodeGenCXX/delete-two-arg.cpp
@@ -47,7 +47,7 @@
     // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8, i8* [[T2]], i32 -4
     // CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i32*
     // CHECK-NEXT: [[T5:%.*]] = load i32, i32* [[T4]]
-    // CHECK-NEXT: call void @_ZdaPv(i8* noundef [[T3]])
+    // CHECK-NEXT: call void @_ZdaPv(i8* allocptr noundef [[T3]])
     // CHECK-NEXT: br label
     ::delete[] p;
   }
Index: clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
===================================================================
--- clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
+++ clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
@@ -28,11 +28,11 @@
 
 // CHECK-LABEL: define {{.*}} @_Z2a0v()
 // CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 i8* @_ZnwmSt11align_val_t(i64 noundef 512, i64 noundef 32)
-// CHECK: call void @_ZdlPvSt11align_val_t(i8* noundef %[[ALLOC]], i64 noundef 32)
+// CHECK: call void @_ZdlPvSt11align_val_t(i8* allocptr noundef %[[ALLOC]], i64 noundef 32)
 // CHECK-MS-LABEL: define {{.*}} @"?a0@@YAPEAXXZ"()
 // CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 i8* @"??2@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef 512, i64 noundef 32)
 // CHECK-MS: cleanuppad
-// CHECK-MS: call void @"??3@YAXPEAXW4align_val_t@std@@@Z"(i8* noundef %[[ALLOC]], i64 noundef 32)
+// CHECK-MS: call void @"??3@YAXPEAXW4align_val_t@std@@@Z"(i8* allocptr noundef %[[ALLOC]], i64 noundef 32)
 void *a0() { return new A; }
 
 // FIXME: Why don't we call the sized array deallocation overload in this case?
@@ -43,22 +43,22 @@
 // No array cookie.
 // CHECK-NOT: store
 // CHECK: invoke void @_ZN1AC1Ev(
-// CHECK: call void @_ZdaPvSt11align_val_t(i8* noundef %[[ALLOC]], i64 noundef 32)
+// CHECK: call void @_ZdaPvSt11align_val_t(i8* allocptr noundef %[[ALLOC]], i64 noundef 32)
 // CHECK-MS-LABEL: define {{.*}} @"?a1@@YAPEAXJ@Z"(
 // CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 i8* @"??_U@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef %{{.*}}, i64 noundef 32)
 // No array cookie.
 // CHECK-MS-NOT: store
 // CHECK-MS: invoke noundef %struct.A* @"??0A@@QEAA@XZ"(
 // CHECK-MS: cleanuppad
-// CHECK-MS: call void @"??_V@YAXPEAXW4align_val_t@std@@@Z"(i8* noundef %[[ALLOC]], i64 noundef 32)
+// CHECK-MS: call void @"??_V@YAXPEAXW4align_val_t@std@@@Z"(i8* allocptr noundef %[[ALLOC]], i64 noundef 32)
 void *a1(long n) { return new A[n]; }
 
 // CHECK-LABEL: define {{.*}} @_Z2a2P1A(
-// CHECK: call void @_ZdlPvmSt11align_val_t(i8* noundef %{{.*}}, i64 noundef 512, i64 noundef 32) #9
+// CHECK: call void @_ZdlPvmSt11align_val_t(i8* allocptr noundef %{{.*}}, i64 noundef 512, i64 noundef 32) #9
 void a2(A *p) { delete p; }
 
 // CHECK-LABEL: define {{.*}} @_Z2a3P1A(
-// CHECK: call void @_ZdaPvSt11align_val_t(i8* noundef %{{.*}}, i64 noundef 32) #9
+// CHECK: call void @_ZdaPvSt11align_val_t(i8* allocptr noundef %{{.*}}, i64 noundef 32) #9
 void a3(A *p) { delete[] p; }
 
 
@@ -170,7 +170,7 @@
 #ifndef UNALIGNED
 // CHECK-LABEL: define {{.*}} @_Z2e0v(
 // CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 4 i8* @_ZnwmSt11align_val_t(i64 noundef 512, i64 noundef 4)
-// CHECK: call void @_ZdlPvSt11align_val_t(i8* noundef %[[ALLOC]], i64 noundef 4)
+// CHECK: call void @_ZdlPvSt11align_val_t(i8* allocptr noundef %[[ALLOC]], i64 noundef 4)
 void *e0() { return new (std::align_val_t(4)) A; }
 
 // CHECK-LABEL: define {{.*}} @_Z2e1v(
Index: clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
===================================================================
--- clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
+++ clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
@@ -50,59 +50,59 @@
 D::D() {}
 
 // CHECK-LABEL: define weak_odr void @_Z3delIiEvv()
-// CHECK: call void @_ZdlPvm(i8* noundef %{{[^ ]*}}, i64 noundef 4)
-// CHECK: call void @_ZdaPv(i8* noundef %{{[^ ]*}})
+// CHECK: call void @_ZdlPvm(i8* allocptr noundef %{{[^ ]*}}, i64 noundef 4)
+// CHECK: call void @_ZdaPv(i8* allocptr noundef %{{[^ ]*}})
 //
-// CHECK: call void @_ZdlPvm(i8* noundef %{{[^ ]*}}, i64 noundef 4)
-// CHECK: call void @_ZdaPv(i8* noundef %{{[^ ]*}})
+// CHECK: call void @_ZdlPvm(i8* allocptr noundef %{{[^ ]*}}, i64 noundef 4)
+// CHECK: call void @_ZdaPv(i8* allocptr noundef %{{[^ ]*}})
 
 // CHECK-LABEL: declare void @_ZdlPvm(i8*
 
 // CHECK-LABEL: define weak_odr void @_Z3delI1BEvv()
-// CHECK: call void @_ZdlPvm(i8* noundef %{{[^ ]*}}, i64 noundef 4)
-// CHECK: call void @_ZdaPv(i8* noundef %{{[^ ]*}})
+// CHECK: call void @_ZdlPvm(i8* allocptr noundef %{{[^ ]*}}, i64 noundef 4)
+// CHECK: call void @_ZdaPv(i8* allocptr noundef %{{[^ ]*}})
 //
-// CHECK: call void @_ZdlPvm(i8* noundef %{{[^ ]*}}, i64 noundef 4)
-// CHECK: call void @_ZdaPv(i8* noundef %{{[^ ]*}})
+// CHECK: call void @_ZdlPvm(i8* allocptr noundef %{{[^ ]*}}, i64 noundef 4)
+// CHECK: call void @_ZdaPv(i8* allocptr noundef %{{[^ ]*}})
 
 // CHECK-LABEL: define weak_odr void @_Z3delI1CEvv()
-// CHECK: call void @_ZdlPvm(i8* noundef %{{[^ ]*}}, i64 noundef 1)
+// CHECK: call void @_ZdlPvm(i8* allocptr noundef %{{[^ ]*}}, i64 noundef 1)
 // CHECK: mul i64 1, %{{[^ ]*}}
 // CHECK: add i64 %{{[^ ]*}}, 8
-// CHECK: call void @_ZdaPvm(i8* noundef %{{[^ ]*}}, i64 noundef %{{[^ ]*}})
+// CHECK: call void @_ZdaPvm(i8* allocptr noundef %{{[^ ]*}}, i64 noundef %{{[^ ]*}})
 //
-// CHECK: call void @_ZdlPvm(i8* noundef %{{[^ ]*}}, i64 noundef 1)
+// CHECK: call void @_ZdlPvm(i8* allocptr noundef %{{[^ ]*}}, i64 noundef 1)
 // CHECK: mul i64 1, %{{[^ ]*}}
 // CHECK: add i64 %{{[^ ]*}}, 8
-// CHECK: call void @_ZdaPvm(i8* noundef %{{[^ ]*}}, i64 noundef %{{[^ ]*}})
+// CHECK: call void @_ZdaPvm(i8* allocptr noundef %{{[^ ]*}}, i64 noundef %{{[^ ]*}})
 
 // CHECK-LABEL: declare void @_ZdaPvm(i8*
 
 // CHECK-LABEL: define weak_odr void @_Z3delI1DEvv()
-// CHECK: call void @_ZdlPvm(i8* noundef %{{[^ ]*}}, i64 noundef 8)
+// CHECK: call void @_ZdlPvm(i8* allocptr noundef %{{[^ ]*}}, i64 noundef 8)
 // CHECK: mul i64 8, %{{[^ ]*}}
 // CHECK: add i64 %{{[^ ]*}}, 8
-// CHECK: call void @_ZdaPvm(i8* noundef %{{[^ ]*}}, i64 noundef %{{[^ ]*}})
+// CHECK: call void @_ZdaPvm(i8* allocptr noundef %{{[^ ]*}}, i64 noundef %{{[^ ]*}})
 //
 // CHECK-NOT: Zdl
 // CHECK: call void %{{.*}}
 // CHECK-NOT: Zdl
 // CHECK: mul i64 8, %{{[^ ]*}}
 // CHECK: add i64 %{{[^ ]*}}, 8
-// CHECK: call void @_ZdaPvm(i8* noundef %{{[^ ]*}}, i64 noundef %{{[^ ]*}})
+// CHECK: call void @_ZdaPvm(i8* allocptr noundef %{{[^ ]*}}, i64 noundef %{{[^ ]*}})
 
 // CHECK-LABEL: define weak_odr void @_Z3delI1EEvv()
-// CHECK: call void @_ZdlPvm(i8* noundef %{{[^ ]*}}, i64 noundef 1)
-// CHECK: call void @_ZdaPv(i8* noundef %{{[^ ]*}})
+// CHECK: call void @_ZdlPvm(i8* allocptr noundef %{{[^ ]*}}, i64 noundef 1)
+// CHECK: call void @_ZdaPv(i8* allocptr noundef %{{[^ ]*}})
 //
 // CHECK: call void @_ZN1EdlEPv(i8* noundef %{{[^ ]*}})
 // CHECK: call void @_ZN1EdaEPv(i8* noundef %{{[^ ]*}})
 
 // CHECK-LABEL: define weak_odr void @_Z3delI1FEvv()
-// CHECK: call void @_ZdlPvm(i8* noundef %{{[^ ]*}}, i64 noundef 1)
+// CHECK: call void @_ZdlPvm(i8* allocptr noundef %{{[^ ]*}}, i64 noundef 1)
 // CHECK: mul i64 1, %{{[^ ]*}}
 // CHECK: add i64 %{{[^ ]*}}, 8
-// CHECK: call void @_ZdaPvm(i8* noundef %{{[^ ]*}}, i64 noundef %{{[^ ]*}})
+// CHECK: call void @_ZdaPvm(i8* allocptr noundef %{{[^ ]*}}, i64 noundef %{{[^ ]*}})
 //
 // CHECK: call void @_ZN1FdlEPvm(i8* noundef %{{[^ ]*}}, i64 noundef 1)
 // CHECK: mul i64 1, %{{[^ ]*}}
@@ -111,4 +111,4 @@
 
 
 // CHECK-LABEL: define linkonce_odr void @_ZN1DD0Ev(%{{[^ ]*}}* {{[^,]*}} %this)
-// CHECK: call void @_ZdlPvm(i8* noundef %{{[^ ]*}}, i64 noundef 8)
+// CHECK: call void @_ZdlPvm(i8* allocptr noundef %{{[^ ]*}}, i64 noundef 8)
Index: clang/lib/CodeGen/CGExprCXX.cpp
===================================================================
--- clang/lib/CodeGen/CGExprCXX.cpp
+++ clang/lib/CodeGen/CGExprCXX.cpp
@@ -1320,9 +1320,15 @@
   ///
   /// We model such elidable calls with the 'builtin' attribute.
   llvm::Function *Fn = dyn_cast<llvm::Function>(CalleePtr);
-  if (CalleeDecl->isReplaceableGlobalAllocationFunction() &&
-      Fn && Fn->hasFnAttribute(llvm::Attribute::NoBuiltin)) {
-    CallOrInvoke->addFnAttr(llvm::Attribute::Builtin);
+  if (CalleeDecl->isReplaceableGlobalAllocationFunction()) {
+    if (Fn && Fn->hasFnAttribute(llvm::Attribute::NoBuiltin)) {
+      CallOrInvoke->addFnAttr(llvm::Attribute::Builtin);
+    }
+
+    if (CalleeDecl->getOverloadedOperator() == OO_Array_Delete ||
+        CalleeDecl->getOverloadedOperator() == OO_Delete) {
+      CallOrInvoke->addParamAttr(0, llvm::Attribute::AllocatedPointer);
+    }
   }
 
   return RV;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to