DianQK created this revision.
Herald added subscribers: atanasyan, jrtc27.
Herald added a reviewer: aaron.ballman.
Herald added a project: All.
DianQK requested review of this revision.
Herald added subscribers: cfe-commits, wangpc.
Herald added a project: clang.

The current implementation of `operator new` under -fno-exceptions 
returns`nullptr`.
This is undefined behavior. D150610 <https://reviews.llvm.org/D150610> may take 
longer to complete.
Removing the undef attribute may be a solution without changing libcxx.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157227

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CodeGen/noundef-analysis.cpp
  clang/test/CodeGenCXX/aix-alignment.cpp
  clang/test/CodeGenCXX/align-avx-complete-objects.cpp
  clang/test/CodeGenCXX/builtin-calling-conv.cpp
  clang/test/CodeGenCXX/builtin-is-constant-evaluated.cpp
  clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
  clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp
  clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
  clang/test/CodeGenCXX/delete-two-arg.cpp
  clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp
  clang/test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp
  clang/test/CodeGenCXX/multi-dim-operator-new.cpp
  clang/test/CodeGenCXX/new-alias.cpp
  clang/test/CodeGenCXX/new-array-init.cpp
  clang/test/CodeGenCXX/new-infallible.cpp
  clang/test/CodeGenCXX/new-overflow.cpp
  clang/test/CodeGenCXX/new.cpp
  clang/test/CodeGenCXX/new_hot_cold.cpp
  clang/test/CodeGenCXX/operator-new.cpp
  clang/test/CodeGenCXX/static-init.cpp
  clang/test/CodeGenCoroutines/coro-alloc.cpp
  clang/test/CodeGenCoroutines/coro-gro.cpp
  clang/test/CodeGenCoroutines/coro-gro2.cpp
  clang/test/CodeGenCoroutines/coro-return.cpp
  clang/test/CodeGenObjCXX/arc-new-delete.mm
  clang/test/CodeGenObjCXX/copy.mm
  clang/test/OpenMP/reduction_implicit_map.cpp

Index: clang/test/OpenMP/reduction_implicit_map.cpp
===================================================================
--- clang/test/OpenMP/reduction_implicit_map.cpp
+++ clang/test/OpenMP/reduction_implicit_map.cpp
@@ -2101,7 +2101,7 @@
 // CHECK2-NEXT:    [[RESULT:%.*]] = alloca i32, align 4
 // CHECK2-NEXT:    store i32 0, ptr [[RETVAL]], align 4
 // CHECK2-NEXT:    store i32 100, ptr [[SIZE]], align 4
-// CHECK2-NEXT:    [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znaj(i32 noundef 400) #[[ATTR10:[0-9]+]]
+// CHECK2-NEXT:    [[CALL:%.*]] = call noalias nonnull ptr @_Znaj(i32 noundef 400) #[[ATTR10:[0-9]+]]
 // CHECK2-NEXT:    store ptr [[CALL]], ptr [[ARRAY]], align 4
 // CHECK2-NEXT:    store i32 0, ptr [[RESULT]], align 4
 // CHECK2-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[ARRAY]], align 4
Index: clang/test/CodeGenObjCXX/copy.mm
===================================================================
--- clang/test/CodeGenObjCXX/copy.mm
+++ clang/test/CodeGenObjCXX/copy.mm
@@ -11,7 +11,7 @@
   // CHECK:      alloca
   // CHECK-NEXT: getelementptr
   // CHECK-NEXT: store
-  // CHECK-NEXT: [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znwm(
+  // CHECK-NEXT: [[CALL:%.*]] = call noalias nonnull ptr @_Znwm(
   // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(
   // CHECK-NEXT: ret
   A *test(A a) {
Index: clang/test/CodeGenObjCXX/arc-new-delete.mm
===================================================================
--- clang/test/CodeGenObjCXX/arc-new-delete.mm
+++ clang/test/CodeGenObjCXX/arc-new-delete.mm
@@ -12,28 +12,28 @@
   // OPT-NEXT: [[T0:%.*]] = call ptr @llvm.objc.retain(ptr [[INVALUE:%.*]])
   // OPT-NEXT: store ptr [[T0]], ptr [[INVALUEADDR]]
 
-  // CHECK: [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znwm
+  // CHECK: [[CALL:%.*]] = call noalias nonnull ptr @_Znwm
   // CHECK-NEXT: store ptr null, ptr
   new strong_id;
-  // CHECK: [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znwm
+  // CHECK: [[CALL:%.*]] = call noalias nonnull ptr @_Znwm
   // UNOPT-NEXT: store ptr null, ptr
   // OPT-NEXT: call ptr @llvm.objc.initWeak(ptr {{.*}}, ptr null)
   new weak_id;
 
-  // CHECK: [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znwm
+  // CHECK: [[CALL:%.*]] = call noalias nonnull ptr @_Znwm
   // CHECK-NEXT: store ptr null, ptr
   new __strong id;
-  // CHECK: [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znwm
+  // CHECK: [[CALL:%.*]] = call noalias nonnull ptr @_Znwm
   // UNOPT-NEXT: store ptr null, ptr
   // OPT-NEXT: call ptr @llvm.objc.initWeak(ptr {{.*}}, ptr null)
   new __weak id;
 
-  // CHECK: [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znwm
+  // CHECK: [[CALL:%.*]] = call noalias nonnull ptr @_Znwm
   // CHECK: call ptr @llvm.objc.retain
   // CHECK: store ptr
   new __strong id(invalue);
 
-  // CHECK: [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znwm
+  // CHECK: [[CALL:%.*]] = call noalias nonnull ptr @_Znwm
   // CHECK: call ptr @llvm.objc.initWeak
   new __weak id(invalue);
 
@@ -44,12 +44,12 @@
 
 // CHECK-LABEL: define{{.*}} void @_Z14test_array_new
 void test_array_new() {
-  // CHECK: call noalias noundef nonnull ptr @_Znam
+  // CHECK: call noalias nonnull ptr @_Znam
   // CHECK: store i64 17, ptr
   // CHECK: call void @llvm.memset.p0.i64
   new strong_id[17];
 
-  // CHECK: call noalias noundef nonnull ptr @_Znam
+  // CHECK: call noalias nonnull ptr @_Znam
   // CHECK: store i64 17, ptr
   // CHECK: call void @llvm.memset.p0.i64
   new weak_id[17];
Index: clang/test/CodeGenCoroutines/coro-return.cpp
===================================================================
--- clang/test/CodeGenCoroutines/coro-return.cpp
+++ clang/test/CodeGenCoroutines/coro-return.cpp
@@ -33,7 +33,7 @@
 // CHECK-LABEL: f0(
 extern "C" void f0() {
   // CHECK: %__promise = alloca %"struct.std::coroutine_traits<void>::promise_type"
-  // CHECK: %call = call noalias noundef nonnull ptr @_Znwm(
+  // CHECK: %call = call noalias nonnull ptr @_Znwm(
   // CHECK: call void @_ZNSt16coroutine_traitsIJvEE12promise_type11return_voidEv(ptr {{[^,]*}} %__promise)
   // CHECK: call void @_ZdlPv
   co_return;
@@ -52,7 +52,7 @@
 // CHECK-LABEL: f1(
 extern "C" int f1() {
   // CHECK: %__promise = alloca %"struct.std::coroutine_traits<int>::promise_type"
-  // CHECK: %call = call noalias noundef nonnull ptr @_Znwm(
+  // CHECK: %call = call noalias nonnull ptr @_Znwm(
   // CHECK: call void @_ZNSt16coroutine_traitsIJiEE12promise_type12return_valueEi(ptr {{[^,]*}} %__promise, i32 noundef 42)
   // CHECK: call void @_ZdlPv
   co_return 42;
Index: clang/test/CodeGenCoroutines/coro-gro2.cpp
===================================================================
--- clang/test/CodeGenCoroutines/coro-gro2.cpp
+++ clang/test/CodeGenCoroutines/coro-gro2.cpp
@@ -36,7 +36,7 @@
 // Verify that the RVO is applied.
 // CHECK-LABEL: define{{.*}} void @_Z1fi(ptr noalias sret(%struct.coro) align 8 %agg.result, i32 noundef %0)
 coro f(int) {
-// CHECK: %call = call noalias noundef nonnull ptr @_Znwm(
+// CHECK: %call = call noalias nonnull ptr @_Znwm(
 // CHECK-NEXT: br label %[[CoroInit:.*]]
 
 // CHECK: {{.*}}[[CoroInit]]:
Index: clang/test/CodeGenCoroutines/coro-gro.cpp
===================================================================
--- clang/test/CodeGenCoroutines/coro-gro.cpp
+++ clang/test/CodeGenCoroutines/coro-gro.cpp
@@ -32,7 +32,7 @@
   // CHECK: %[[GroActive:.+]] = alloca i1
 
   // CHECK: %[[Size:.+]] = call i64 @llvm.coro.size.i64()
-  // CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef %[[Size]])
+  // CHECK: call noalias nonnull ptr @_Znwm(i64 noundef %[[Size]])
   // CHECK: store i1 false, ptr %[[GroActive]]
   // CHECK: call void @_ZNSt16coroutine_traitsIiJEE12promise_typeC1Ev(
   // CHECK: call void @_ZNSt16coroutine_traitsIiJEE12promise_type17get_return_objectEv(
Index: clang/test/CodeGenCoroutines/coro-alloc.cpp
===================================================================
--- clang/test/CodeGenCoroutines/coro-alloc.cpp
+++ clang/test/CodeGenCoroutines/coro-alloc.cpp
@@ -58,7 +58,7 @@
 
   // CHECK: [[AllocBB]]:
   // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
-  // CHECK: %[[MEM:.+]] = call noalias noundef nonnull ptr @_Znwm(i64 noundef %[[SIZE]])
+  // CHECK: %[[MEM:.+]] = call noalias nonnull ptr @_Znwm(i64 noundef %[[SIZE]])
   // CHECK: br label %[[InitBB]]
 
   // CHECK: [[InitBB]]:
@@ -153,7 +153,7 @@
 // within the scope of the promise type's class.
 // CHECK-LABEL: f1b(
 extern "C" void f1b(promise_matching_global_placement_new_tag, dummy *) {
-  // CHECK: call noalias noundef nonnull ptr @_Znwm(i64
+  // CHECK: call noalias nonnull ptr @_Znwm(i64
   co_return;
 }
 
@@ -174,7 +174,7 @@
 extern "C" void f2(promise_delete_tag) {
   // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
   // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
-  // CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef %[[SIZE]])
+  // CHECK: call noalias nonnull ptr @_Znwm(i64 noundef %[[SIZE]])
 
   // CHECK: %[[FRAME:.+]] = call ptr @llvm.coro.begin(
   // CHECK: %[[MEM:.+]] = call ptr @llvm.coro.free(token %[[ID]], ptr %[[FRAME]])
@@ -199,7 +199,7 @@
 extern "C" void f3(promise_sized_delete_tag) {
   // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
   // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
-  // CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef %[[SIZE]])
+  // CHECK: call noalias nonnull ptr @_Znwm(i64 noundef %[[SIZE]])
 
   // CHECK: %[[FRAME:.+]] = call ptr @llvm.coro.begin(
   // CHECK: %[[MEM:.+]] = call ptr @llvm.coro.free(token %[[ID]], ptr %[[FRAME]])
@@ -265,7 +265,7 @@
 extern "C" void f5(promise_sized_delete_tag2) {
   // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
   // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
-  // CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef %[[SIZE]])
+  // CHECK: call noalias nonnull ptr @_Znwm(i64 noundef %[[SIZE]])
 
   // CHECK: %[[FRAME:.+]] = call ptr @llvm.coro.begin(
   // CHECK: %[[MEM:.+]] = call ptr @llvm.coro.free(token %[[ID]], ptr %[[FRAME]])
Index: clang/test/CodeGenCXX/static-init.cpp
===================================================================
--- clang/test/CodeGenCXX/static-init.cpp
+++ clang/test/CodeGenCXX/static-init.cpp
@@ -31,7 +31,7 @@
 }
 
 void g() {
-  // CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef 1)
+  // CHECK: call noalias nonnull ptr @_Znwm(i64 noundef 1)
   // CHECK: call void @_ZN1AC1Ev(
   static A& a = *new A;
 }
Index: clang/test/CodeGenCXX/operator-new.cpp
===================================================================
--- clang/test/CodeGenCXX/operator-new.cpp
+++ clang/test/CodeGenCXX/operator-new.cpp
@@ -10,7 +10,7 @@
 };
 
 void f1() {
-  // ALL: declare noundef nonnull ptr @_Znwj(
+  // ALL: declare nonnull ptr @_Znwj(
   new teste();
 }
 
@@ -22,8 +22,8 @@
   // ALL-NEXT: [[OVER:%.*]] = extractvalue {{.*}} [[UWO]], 1
   // ALL-NEXT: [[SUM:%.*]] = extractvalue {{.*}} [[UWO]], 0
   // ALL-NEXT: [[RESULT:%.*]] = select i1 [[OVER]], i32 -1, i32 [[SUM]]
-  // SANE-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[RESULT]])
-  // SANENOT-NEXT: call noundef nonnull ptr @_Znaj(i32 noundef [[RESULT]])
+  // SANE-NEXT: call noalias nonnull ptr @_Znaj(i32 noundef [[RESULT]])
+  // SANENOT-NEXT: call nonnull ptr @_Znaj(i32 noundef [[RESULT]])
 }
 
-// ALL: declare noundef nonnull ptr @_Znaj(
+// ALL: declare nonnull ptr @_Znaj(
Index: clang/test/CodeGenCXX/new_hot_cold.cpp
===================================================================
--- clang/test/CodeGenCXX/new_hot_cold.cpp
+++ clang/test/CodeGenCXX/new_hot_cold.cpp
@@ -47,22 +47,22 @@
 // declarations should get nobuiltin attributes.
 
 void hot_cold_new() {
-  // CHECK: call noalias noundef nonnull ptr @_Znwm12__hot_cold_t(i64 noundef 1, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
+  // CHECK: call noalias nonnull ptr @_Znwm12__hot_cold_t(i64 noundef 1, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
   operator new(1, (__hot_cold_t)0);
-  // CHECK: call noalias noundef nonnull ptr @_Znwm12__hot_cold_t(i64 noundef 4, i8 noundef zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
+  // CHECK: call noalias nonnull ptr @_Znwm12__hot_cold_t(i64 noundef 4, i8 noundef zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
   new ((__hot_cold_t)0) int;
 }
 
-// CHECK: declare noundef nonnull ptr @_Znwm12__hot_cold_t(i64 noundef, i8 noundef zeroext) [[ATTR_NOBUILTIN:#[^ ]*]]
+// CHECK: declare nonnull ptr @_Znwm12__hot_cold_t(i64 noundef, i8 noundef zeroext) [[ATTR_NOBUILTIN:#[^ ]*]]
 
 void hot_cold_new_array() {
-  // CHECK: call noalias noundef nonnull ptr @_Znam12__hot_cold_t(i64 noundef 1, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
+  // CHECK: call noalias nonnull ptr @_Znam12__hot_cold_t(i64 noundef 1, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
   operator new[](1, (__hot_cold_t)0);
-  // CHECK: call noalias noundef nonnull ptr @_Znam12__hot_cold_t(i64 noundef 4, i8 noundef zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
+  // CHECK: call noalias nonnull ptr @_Znam12__hot_cold_t(i64 noundef 4, i8 noundef zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
   new ((__hot_cold_t)0) int[1];
 }
 
-// CHECK: declare noundef nonnull ptr @_Znam12__hot_cold_t(i64 noundef, i8 noundef zeroext) [[ATTR_NOBUILTIN:#[^ ]*]]
+// CHECK: declare nonnull ptr @_Znam12__hot_cold_t(i64 noundef, i8 noundef zeroext) [[ATTR_NOBUILTIN:#[^ ]*]]
 
 void hot_cold_new_nothrow() {
   // CHECK: call noalias noundef ptr @_ZnwmRKSt9nothrow_t12__hot_cold_t(i64 noundef 1, {{.*}} @nothrow, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_NOTHROW_CALL:#[^ ]*]]
@@ -87,22 +87,22 @@
 };
 
 void hot_cold_new_align() {
-  // CHECK: call noalias noundef nonnull align 32 ptr @_ZnwmSt11align_val_t12__hot_cold_t(i64 noundef 1, i64 noundef 32, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
+  // CHECK: call noalias nonnull align 32 ptr @_ZnwmSt11align_val_t12__hot_cold_t(i64 noundef 1, i64 noundef 32, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
   operator new(1, (std::align_val_t)32, (__hot_cold_t)0);
-  // CHECK: call noalias noundef nonnull align 32 ptr @_ZnwmSt11align_val_t12__hot_cold_t(i64 noundef 32, i64 noundef 32, i8 noundef zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
+  // CHECK: call noalias nonnull align 32 ptr @_ZnwmSt11align_val_t12__hot_cold_t(i64 noundef 32, i64 noundef 32, i8 noundef zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
   new ((__hot_cold_t)0) alignedstruct;
 }
 
-// CHECK: declare noundef nonnull ptr @_ZnwmSt11align_val_t12__hot_cold_t(i64 noundef, i64 noundef, i8 noundef zeroext) [[ATTR_NOBUILTIN:#[^ ]*]]
+// CHECK: declare nonnull ptr @_ZnwmSt11align_val_t12__hot_cold_t(i64 noundef, i64 noundef, i8 noundef zeroext) [[ATTR_NOBUILTIN:#[^ ]*]]
 
 void hot_cold_new_align_array() {
-  // CHECK: call noalias noundef nonnull align 32 ptr @_ZnamSt11align_val_t12__hot_cold_t(i64 noundef 1, i64 noundef 32, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
+  // CHECK: call noalias nonnull align 32 ptr @_ZnamSt11align_val_t12__hot_cold_t(i64 noundef 1, i64 noundef 32, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
   operator new[](1, (std::align_val_t)32, (__hot_cold_t)0);
-  // CHECK: call noalias noundef nonnull align 32 ptr @_ZnamSt11align_val_t12__hot_cold_t(i64 noundef 32, i64 noundef 32, i8 noundef zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
+  // CHECK: call noalias nonnull align 32 ptr @_ZnamSt11align_val_t12__hot_cold_t(i64 noundef 32, i64 noundef 32, i8 noundef zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
   new ((__hot_cold_t)0) alignedstruct[1];
 }
 
-// CHECK: declare noundef nonnull ptr @_ZnamSt11align_val_t12__hot_cold_t(i64 noundef, i64 noundef, i8 noundef zeroext) [[ATTR_NOBUILTIN:#[^ ]*]]
+// CHECK: declare nonnull ptr @_ZnamSt11align_val_t12__hot_cold_t(i64 noundef, i64 noundef, i8 noundef zeroext) [[ATTR_NOBUILTIN:#[^ ]*]]
 
 void hot_cold_new_align_nothrow() {
   // CHECK: call noalias noundef align 32 ptr @_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 noundef 1, i64 noundef 32, {{.*}} @nothrow, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_NOTHROW_CALL:#[^ ]*]]
Index: clang/test/CodeGenCXX/new.cpp
===================================================================
--- clang/test/CodeGenCXX/new.cpp
+++ clang/test/CodeGenCXX/new.cpp
@@ -14,9 +14,9 @@
   delete [] new int [3];
 }
 
-// CHECK: declare noundef nonnull ptr @_Znwm(i64 noundef) [[ATTR_NOBUILTIN:#[^ ]*]]
+// CHECK: declare nonnull ptr @_Znwm(i64 noundef) [[ATTR_NOBUILTIN:#[^ ]*]]
 // CHECK: declare void @_ZdlPv(ptr noundef) [[ATTR_NOBUILTIN_NOUNWIND:#[^ ]*]]
-// CHECK: declare noundef nonnull ptr @_Znam(i64 noundef) [[ATTR_NOBUILTIN]]
+// CHECK: declare nonnull ptr @_Znam(i64 noundef) [[ATTR_NOBUILTIN]]
 // CHECK: declare void @_ZdaPv(ptr noundef) [[ATTR_NOBUILTIN_NOUNWIND]]
 
 namespace std {
@@ -127,15 +127,15 @@
 struct Bmemptr { int Bmemptr::* memptr; int a; };
 
 void t11(int n) {
-  // CHECK: call noalias noundef nonnull ptr @_Znwm
+  // CHECK: call noalias nonnull ptr @_Znwm
   // CHECK: call void @llvm.memset.p0.i64(
   B* b = new B();
 
-  // CHECK: call noalias noundef nonnull ptr @_Znam
+  // CHECK: call noalias nonnull ptr @_Znam
   // CHECK: {{call void.*llvm.memset.p0.i64.*i8 0, i64 %}}
   B *b2 = new B[n]();
 
-  // CHECK: call noalias noundef nonnull ptr @_Znam
+  // CHECK: call noalias nonnull ptr @_Znam
   // CHECK: call void @llvm.memcpy.p0.p0.i64
   // CHECK: br
   Bmemptr *b_memptr = new Bmemptr[n]();
@@ -148,11 +148,11 @@
 // We don't need to initialize an empty class.
 // CHECK-LABEL: define{{.*}} void @_Z3t12v
 void t12() {
-  // CHECK: call noalias noundef nonnull ptr @_Znam
+  // CHECK: call noalias nonnull ptr @_Znam
   // CHECK-NOT: br
   (void)new Empty[10];
 
-  // CHECK: call noalias noundef nonnull ptr @_Znam
+  // CHECK: call noalias nonnull ptr @_Znam
   // CHECK-NOT: br
   (void)new Empty[10]();
 
@@ -162,11 +162,11 @@
 // Zero-initialization
 // CHECK-LABEL: define{{.*}} void @_Z3t13i
 void t13(int n) {
-  // CHECK: call noalias noundef nonnull ptr @_Znwm
+  // CHECK: call noalias nonnull ptr @_Znwm
   // CHECK: store i32 0, ptr
   (void)new int();
 
-  // CHECK: call noalias noundef nonnull ptr @_Znam
+  // CHECK: call noalias nonnull ptr @_Znam
   // CHECK: {{call void.*llvm.memset.p0.i64.*i8 0, i64 %}}
   (void)new int[n]();
 
@@ -191,7 +191,7 @@
   // CHECK-NOT: icmp eq ptr [[P]], null
   // CHECK: store i64 200
   delete[] new (nothrow) Alloc[10][20];
-  // CHECK: call noalias noundef nonnull ptr @_Znwm
+  // CHECK: call noalias nonnull ptr @_Znwm
   // CHECK: call void @_ZdlPv(ptr
   delete new bool;
   // CHECK: ret void
@@ -272,7 +272,7 @@
   // CHECK-LABEL: define weak_odr void @_ZN7PR101971fIiEEvv()
   template<typename T>
   void f() {
-    // CHECK: [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znwm
+    // CHECK: [[CALL:%.*]] = call noalias nonnull ptr @_Znwm
     new T;
     // CHECK-NEXT: ret void
   }
@@ -293,7 +293,7 @@
   struct X { X(); X(const X&); };
   X* a(X* x) { return new X(X()); }
   // CHECK: define {{.*}} @_ZN7PR117571aEPNS_1XE
-  // CHECK: [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znwm
+  // CHECK: [[CALL:%.*]] = call noalias nonnull ptr @_Znwm
   // CHECK: ret {{.*}} [[CALL]]
 }
 
@@ -301,7 +301,7 @@
   struct A { A() {} };
   struct B : public A { int x; };
   // CHECK-LABEL: define{{.*}} ptr @_ZN7PR133801fEv
-  // CHECK: call noalias noundef nonnull ptr @_Znam(
+  // CHECK: call noalias nonnull ptr @_Znam(
   // CHECK: call void @llvm.memset.p0
   // CHECK-NEXT: call void @_ZN7PR133801BC1Ev
   void* f() { return new B[2](); }
@@ -315,12 +315,12 @@
 
   // CHECK-LABEL: define{{.*}} void @_ZN5N36641fEv
   void f() {
-    // CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
+    // CHECK: call noalias nonnull ptr @_Znwm(i64 noundef 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
     int *p = new int; // expected-note {{allocated with 'new' here}}
     // CHECK: call void @_ZdlPv({{.*}}) [[ATTR_BUILTIN_DELETE:#[^ ]*]]
     delete p;
 
-    // CHECK: call noalias noundef nonnull ptr @_Znam(i64 noundef 12) [[ATTR_BUILTIN_NEW]]
+    // CHECK: call noalias nonnull ptr @_Znam(i64 noundef 12) [[ATTR_BUILTIN_NEW]]
     int *q = new int[3];
     // CHECK: call void @_ZdaPv({{.*}}) [[ATTR_BUILTIN_DELETE]]
     delete[] p; // expected-warning {{'delete[]' applied to a pointer that was allocated with 'new'; did you mean 'delete'?}}
@@ -338,12 +338,12 @@
   void g() {
     // It's OK for there to be attributes here, so long as we don't have a
     // 'builtin' attribute.
-    // CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef 4) {{#[^ ]*}}{{$}}
+    // CHECK: call noalias nonnull ptr @_Znwm(i64 noundef 4) {{#[^ ]*}}{{$}}
     int *p = (int*)operator new(4);
     // CHECK: call void @_ZdlPv({{.*}}) [[ATTR_NOUNWIND:#[^ ]*]]
     operator delete(p);
 
-    // CHECK: call noalias noundef nonnull ptr @_Znam(i64 noundef 12) {{#[^ ]*}}{{$}}
+    // CHECK: call noalias nonnull ptr @_Znam(i64 noundef 12) {{#[^ ]*}}{{$}}
     int *q = (int*)operator new[](12);
     // CHECK: call void @_ZdaPv({{.*}}) [[ATTR_NOUNWIND]]
     operator delete [](p);
@@ -356,7 +356,7 @@
 namespace builtins {
   // CHECK-LABEL: define{{.*}} void @_ZN8builtins1fEv
   void f() {
-    // CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef 4) [[ATTR_BUILTIN_NEW]]
+    // CHECK: call noalias nonnull ptr @_Znwm(i64 noundef 4) [[ATTR_BUILTIN_NEW]]
     // CHECK: call void @_ZdlPv({{.*}}) [[ATTR_BUILTIN_DELETE]]
     __builtin_operator_delete(__builtin_operator_new(4));
   }
Index: clang/test/CodeGenCXX/new-overflow.cpp
===================================================================
--- clang/test/CodeGenCXX/new-overflow.cpp
+++ clang/test/CodeGenCXX/new-overflow.cpp
@@ -17,7 +17,7 @@
   // CHECK-NEXT: [[T1:%.*]] = extractvalue { i32, i1 } [[T0]], 1
   // CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 0
   // CHECK-NEXT: [[T3:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]
-  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[T3]])
+  // CHECK-NEXT: call noalias nonnull ptr @_Znaj(i32 noundef [[T3]])
   // CHECK:      getelementptr inbounds {{.*}}, i32 [[N]]
   elt *test(short s) {
     return new elt[s];
@@ -40,7 +40,7 @@
   // CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 0
   // CHECK-NEXT: [[T3:%.*]] = mul i32 [[N]], 100
   // CHECK-NEXT: [[T4:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]
-  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[T4]])
+  // CHECK-NEXT: call noalias nonnull ptr @_Znaj(i32 noundef [[T4]])
   // CHECK:      getelementptr inbounds {{.*}}, i32 [[T3]]
   elt *test(short s) {
     return new elt[s];
@@ -68,7 +68,7 @@
   // CHECK-NEXT: [[T6:%.*]] = or i1 [[T1]], [[T5]]
   // CHECK-NEXT: [[T7:%.*]] = extractvalue { i32, i1 } [[T4]], 0
   // CHECK-NEXT: [[T8:%.*]] = select i1 [[T6]], i32 -1, i32 [[T7]]
-  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[T8]])
+  // CHECK-NEXT: call noalias nonnull ptr @_Znaj(i32 noundef [[T8]])
   // CHECK:      getelementptr inbounds {{.*}}, i32 [[T3]]
   elt *test(short s) {
     return new elt[s];
@@ -85,7 +85,7 @@
 
   // CHECK:    define{{.*}} ptr @_ZN5test44testEs(i16 noundef signext
   // CHECK:      [[N:%.*]] = sext i16 {{%.*}} to i32
-  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[N]])
+  // CHECK-NEXT: call noalias nonnull ptr @_Znaj(i32 noundef [[N]])
   // CHECK:      getelementptr inbounds {{.*}}, i32 [[N]]
   elt *test(short s) {
     return new elt[s];
@@ -102,7 +102,7 @@
 
   // CHECK:    define{{.*}} ptr @_ZN5test54testEi(i32
   // CHECK:      [[N:%.*]] = load i32, ptr
-  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[N]])
+  // CHECK-NEXT: call noalias nonnull ptr @_Znaj(i32 noundef [[N]])
   // CHECK:      getelementptr inbounds {{.*}}, i32 [[N]]
   elt *test(int s) {
     return new elt[s];
@@ -124,7 +124,7 @@
   // CHECK-NEXT: [[T1:%.*]] = extractvalue { i32, i1 } [[T0]], 1
   // CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 0
   // CHECK-NEXT: [[T3:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]
-  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[T3]])
+  // CHECK-NEXT: call noalias nonnull ptr @_Znaj(i32 noundef [[T3]])
   // CHECK:      getelementptr inbounds {{.*}}, i32 [[N]]
   elt *test(unsigned short s) {
     return new elt[s];
@@ -147,7 +147,7 @@
   // CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 0
   // CHECK-NEXT: [[T3:%.*]] = mul i32 [[N]], 100
   // CHECK-NEXT: [[T4:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]
-  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[T4]])
+  // CHECK-NEXT: call noalias nonnull ptr @_Znaj(i32 noundef [[T4]])
   // CHECK:      getelementptr inbounds {{.*}}, i32 [[T3]]
   elt *test(unsigned short s) {
     return new elt[s];
@@ -170,7 +170,7 @@
   // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 1
   // CHECK-NEXT: [[T5:%.*]] = extractvalue { i32, i1 } [[T2]], 0
   // CHECK-NEXT: [[T6:%.*]] = select i1 [[T3]], i32 -1, i32 [[T5]]
-  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[T6]])
+  // CHECK-NEXT: call noalias nonnull ptr @_Znaj(i32 noundef [[T6]])
   // CHECK:      getelementptr inbounds {{.*}}, i32 [[T1]]
   elt *test(long long s) {
     return new elt[s];
@@ -193,7 +193,7 @@
   // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 1
   // CHECK-NEXT: [[T5:%.*]] = extractvalue { i32, i1 } [[T2]], 0
   // CHECK-NEXT: [[T6:%.*]] = select i1 [[T3]], i32 -1, i32 [[T5]]
-  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[T6]])
+  // CHECK-NEXT: call noalias nonnull ptr @_Znaj(i32 noundef [[T6]])
   // CHECK:      getelementptr inbounds {{.*}}, i32 [[T1]]
   elt *test(unsigned long long s) {
     return new elt[s];
Index: clang/test/CodeGenCXX/new-infallible.cpp
===================================================================
--- clang/test/CodeGenCXX/new-infallible.cpp
+++ clang/test/CodeGenCXX/new-infallible.cpp
@@ -3,14 +3,14 @@
 // RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fno-new-infallible -o - %s | FileCheck %s --check-prefix=NO-NEW-INFALLIBLE
 // RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fnew-infallible -fno-new-infallible -o - %s | FileCheck %s --check-prefix=NO-NEW-INFALLIBLE
 
-// CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef 4)
+// CHECK: call noalias nonnull ptr @_Znwm(i64 noundef 4)
 
 // CHECK: ; Function Attrs: nobuiltin nounwind allocsize(0)
-// CHECK-NEXT: declare noundef nonnull ptr @_Znwm(i64 noundef)
+// CHECK-NEXT: declare nonnull ptr @_Znwm(i64 noundef)
 
-// NO-NEW-INFALLIBLE: call noalias noundef nonnull ptr @_Znwm(i64 noundef 4)
+// NO-NEW-INFALLIBLE: call noalias nonnull ptr @_Znwm(i64 noundef 4)
 
 // NO-NEW-INFALLIBLE: ; Function Attrs: nobuiltin allocsize(0)
-// NO-NEW-INFALLIBLE-NEXT: declare noundef nonnull ptr @_Znwm(i64 noundef)
+// NO-NEW-INFALLIBLE-NEXT: declare nonnull ptr @_Znwm(i64 noundef)
 
 int *new_infallible = new int;
Index: clang/test/CodeGenCXX/new-array-init.cpp
===================================================================
--- clang/test/CodeGenCXX/new-array-init.cpp
+++ clang/test/CodeGenCXX/new-array-init.cpp
@@ -34,7 +34,7 @@
   struct S;
   new (int S::*[3][4][5]) ();
 
-  // CHECK: call noalias noundef nonnull ptr @_Zna{{.}}(i{{32 noundef 240|64 noundef 480}})
+  // CHECK: call noalias nonnull ptr @_Zna{{.}}(i{{32 noundef 240|64 noundef 480}})
   // CHECK: getelementptr inbounds i{{32|64}}, ptr {{.*}}, i{{32|64}} 60
 
   // CHECK: phi
@@ -49,7 +49,7 @@
   // CHECK: icmp slt i{{32|64}} %{{[^ ]+}}, 4
   // FIXME: Conditionally throw an exception rather than passing -1 to alloc function
   // CHECK: select
-  // CHECK: %[[PTR:.*]] = call noalias noundef nonnull ptr @_Zna{{.}}(i{{32|64}}
+  // CHECK: %[[PTR:.*]] = call noalias nonnull ptr @_Zna{{.}}(i{{32|64}}
   // CHECK: call void @llvm.memcpy{{.*}}(ptr align {{[0-9]+}} %[[PTR]], ptr align {{[0-9]+}} @[[ABC4]], i32 4,
   // CHECK: %[[REST:.*]] = getelementptr inbounds i8, ptr %[[PTR]], i32 4
   // CHECK: %[[RESTSIZE:.*]] = sub {{.*}}, 4
@@ -60,7 +60,7 @@
 // CHECK-LABEL: define{{.*}} void @_Z12string_exactv
 void string_exact() {
   // CHECK-NOT: icmp
-  // CHECK: %[[PTR:.*]] = call noalias noundef nonnull ptr @_Zna{{.}}(i{{32|64}} noundef 4)
+  // CHECK: %[[PTR:.*]] = call noalias nonnull ptr @_Zna{{.}}(i{{32|64}} noundef 4)
   // CHECK: call void @llvm.memcpy{{.*}}(ptr align {{[0-9]+}} %[[PTR]], ptr align {{[0-9]+}} @[[ABC4]], i32 4,
   // CHECK-NOT: memset
   new char[4] { "abc" };
@@ -69,7 +69,7 @@
 // CHECK-LABEL: define{{.*}} void @_Z17string_sufficientv
 void string_sufficient() {
   // CHECK-NOT: icmp
-  // CHECK: %[[PTR:.*]] = call noalias noundef nonnull ptr @_Zna{{.}}(i{{32|64}} noundef 15)
+  // CHECK: %[[PTR:.*]] = call noalias nonnull ptr @_Zna{{.}}(i{{32|64}} noundef 15)
   // FIXME: For very large arrays, it would be preferable to emit a small copy and a memset.
   // CHECK: call void @llvm.memcpy{{.*}}(ptr align {{[0-9]+}} %[[PTR]], ptr align {{[0-9]+}} @[[ABC15]], i32 15,
   // CHECK-NOT: memset
@@ -79,7 +79,7 @@
 // CHECK-LABEL: define{{.*}} void @_Z10aggr_exactv
 void aggr_exact() {
   // CHECK-NOT: icmp
-  // CHECK: %[[MEM:.*]] = call noalias noundef nonnull ptr @_Zna{{.}}(i{{32|64}} noundef 16)
+  // CHECK: %[[MEM:.*]] = call noalias nonnull ptr @_Zna{{.}}(i{{32|64}} noundef 16)
   // CHECK: %[[FIELD:.*]] = getelementptr inbounds %[[AGGR:.*]], ptr %[[MEM]], i32 0, i32 0{{$}}
   // CHECK: store i32 1, ptr %[[FIELD]]
   // CHECK: %[[FIELD:.*]] = getelementptr inbounds %[[AGGR]], ptr %[[MEM]], i32 0, i32 1{{$}}
@@ -98,7 +98,7 @@
 // CHECK-LABEL: define{{.*}} void @_Z15aggr_sufficienti
 void aggr_sufficient(int n) {
   // CHECK: icmp ult i32 %{{.*}}, 2
-  // CHECK: %[[MEM:.*]] = call noalias noundef nonnull ptr @_Zna{{.}}(
+  // CHECK: %[[MEM:.*]] = call noalias nonnull ptr @_Zna{{.}}(
   // CHECK: %[[FIELD:.*]] = getelementptr inbounds %[[AGGR:.*]], ptr %[[MEM]], i32 0, i32 0{{$}}
   // CHECK: store i32 1, ptr %[[FIELD]]
   // CHECK: %[[FIELD:.*]] = getelementptr inbounds %[[AGGR]], ptr %[[MEM]], i32 0, i32 1{{$}}
@@ -117,7 +117,7 @@
 
 // SIO-LABEL: define{{.*}} void @_Z14constexpr_testv
 void constexpr_test() {
-  // SIO: call noalias noundef nonnull ptr @_Zna{{.}}(i32 noundef 4)
+  // SIO: call noalias nonnull ptr @_Zna{{.}}(i32 noundef 4)
   new int[0+1]{0};
 }
 
Index: clang/test/CodeGenCXX/new-alias.cpp
===================================================================
--- clang/test/CodeGenCXX/new-alias.cpp
+++ clang/test/CodeGenCXX/new-alias.cpp
@@ -9,5 +9,5 @@
 void *operator new(size_t) __attribute__((alias("something")));
 
 // PR16715: don't assert here.
-// CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef 4) #3{{$}}
+// CHECK: call noalias nonnull ptr @_Znwm(i64 noundef 4) #3{{$}}
 int *pr16715 = new int;
Index: clang/test/CodeGenCXX/multi-dim-operator-new.cpp
===================================================================
--- clang/test/CodeGenCXX/multi-dim-operator-new.cpp
+++ clang/test/CodeGenCXX/multi-dim-operator-new.cpp
@@ -43,6 +43,6 @@
  return 0;
 }
 
-// CHECK: call noalias noundef nonnull ptr @_Znam
-// CHECK: call noalias noundef nonnull ptr @_Znam
-// CHECK: call noalias noundef nonnull ptr @_Znam
+// CHECK: call noalias nonnull ptr @_Znam
+// CHECK: call noalias nonnull ptr @_Znam
+// CHECK: call noalias nonnull ptr @_Znam
Index: clang/test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp
===================================================================
--- clang/test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp
+++ clang/test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp
@@ -10,13 +10,13 @@
   return rv;
 }
 // O32-LABEL: define{{.*}} ptr @_Z10alloc_longv()
-// O32: call noalias noundef nonnull ptr @_Znwj(i32 noundef signext 4)
+// O32: call noalias nonnull ptr @_Znwj(i32 noundef signext 4)
 
 // N32-LABEL: define{{.*}} ptr @_Z10alloc_longv()
-// N32: call noalias noundef nonnull ptr @_Znwj(i32 noundef signext 4)
+// N32: call noalias nonnull ptr @_Znwj(i32 noundef signext 4)
 
 // N64-LABEL: define{{.*}} ptr @_Z10alloc_longv()
-// N64: call noalias noundef nonnull ptr @_Znwm(i64 noundef zeroext 8)
+// N64: call noalias nonnull ptr @_Znwm(i64 noundef zeroext 8)
 
 long *alloc_long_array() {
   long *rv = new long[2];
@@ -24,13 +24,13 @@
 }
 
 // O32-LABEL: define{{.*}} ptr @_Z16alloc_long_arrayv()
-// O32: call noalias noundef nonnull ptr @_Znaj(i32 noundef signext 8)
+// O32: call noalias nonnull ptr @_Znaj(i32 noundef signext 8)
 
 // N32-LABEL: define{{.*}} ptr @_Z16alloc_long_arrayv()
-// N32: call noalias noundef nonnull ptr @_Znaj(i32 noundef signext 8)
+// N32: call noalias nonnull ptr @_Znaj(i32 noundef signext 8)
 
 // N64-LABEL: define{{.*}} ptr @_Z16alloc_long_arrayv()
-// N64: call noalias noundef nonnull ptr @_Znam(i64 noundef zeroext 16)
+// N64: call noalias nonnull ptr @_Znam(i64 noundef zeroext 16)
 
 #include <stddef.h>
 
Index: clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp
===================================================================
--- clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp
@@ -7,7 +7,7 @@
 void check_array_no_cookies() {
 // CHECK: define dso_local void @"?check_array_no_cookies@@YAXXZ"() [[NUW:#[0-9]+]]
 
-// CHECK: call noalias noundef nonnull ptr @"??_U@YAPAXI@Z"(i32 noundef 42)
+// CHECK: call noalias nonnull ptr @"??_U@YAPAXI@Z"(i32 noundef 42)
   ClassWithoutDtor *array = new ClassWithoutDtor[42];
 
 // CHECK: call void @"??_V@YAXPAX@Z"(
@@ -24,7 +24,7 @@
 // CHECK: define {{.*}} @"?check_array_cookies_simple@@YAXXZ"()
 
   ClassWithDtor *array = new ClassWithDtor[42];
-// CHECK: [[ALLOCATED:%.*]] = call noalias noundef nonnull ptr @"??_U@YAPAXI@Z"(i32 noundef 46)
+// CHECK: [[ALLOCATED:%.*]] = call noalias nonnull ptr @"??_U@YAPAXI@Z"(i32 noundef 46)
 // 46 = 42 + size of cookie (4)
 // CHECK: store i32 42, ptr [[ALLOCATED]]
 // CHECK: [[ARRAY:%.*]] = getelementptr inbounds i8, ptr [[ALLOCATED]], i32 4
@@ -43,7 +43,7 @@
 void check_array_cookies_aligned() {
 // CHECK: define {{.*}} @"?check_array_cookies_aligned@@YAXXZ"()
   ClassWithAlignment *array = new ClassWithAlignment[42];
-// CHECK: [[ALLOCATED:%.*]] = call noalias noundef nonnull ptr @"??_U@YAPAXI@Z"(i32 noundef 344)
+// CHECK: [[ALLOCATED:%.*]] = call noalias nonnull ptr @"??_U@YAPAXI@Z"(i32 noundef 344)
 //   344 = 42*8 + size of cookie (8, due to alignment)
 // CHECK: store i32 42, ptr [[ALLOCATED]]
 // CHECK: [[ARRAY:%.*]] = getelementptr inbounds i8, ptr [[ALLOCATED]], i32 8
Index: clang/test/CodeGenCXX/delete-two-arg.cpp
===================================================================
--- clang/test/CodeGenCXX/delete-two-arg.cpp
+++ clang/test/CodeGenCXX/delete-two-arg.cpp
@@ -27,7 +27,7 @@
 
   // CHECK: define{{.*}} ptr @_ZN5test24testEv()
   A *test() {
-    // CHECK:      [[NEW:%.*]] = call noalias noundef nonnull ptr @_Znaj(i32 noundef 44)
+    // CHECK:      [[NEW:%.*]] = call noalias nonnull ptr @_Znaj(i32 noundef 44)
     // CHECK-NEXT: store i32 10, ptr [[NEW]]
     // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8, ptr [[NEW]], i32 4
     // CHECK-NEXT: ret ptr [[T1]]
@@ -59,7 +59,7 @@
 
   // CHECK-LABEL: define{{.*}} void @_ZN5test34testEv()
   void test() {
-    // CHECK:      [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znaj(i32 noundef 24)
+    // CHECK:      [[CALL:%.*]] = call noalias nonnull ptr @_Znaj(i32 noundef 24)
     // CHECK-NEXT: store i32 5
     (void) new B[5];
   }
Index: clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
===================================================================
--- clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
+++ clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
@@ -27,10 +27,10 @@
 struct OVERALIGNED A { A(); int n[128]; };
 
 // CHECK-LABEL: define {{.*}} @_Z2a0v()
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr @_ZnwmSt11align_val_t(i64 noundef 512, i64 noundef 32)
+// CHECK: %[[ALLOC:.*]] = call noalias nonnull align 32 ptr @_ZnwmSt11align_val_t(i64 noundef 512, i64 noundef 32)
 // CHECK: call void @_ZdlPvSt11align_val_t(ptr noundef %[[ALLOC]], i64 noundef 32)
 // CHECK-MS-LABEL: define {{.*}} @"?a0@@YAPEAXXZ"()
-// CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr @"??2@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef 512, i64 noundef 32)
+// CHECK-MS: %[[ALLOC:.*]] = call noalias nonnull align 32 ptr @"??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"(ptr noundef %[[ALLOC]], i64 noundef 32)
 void *a0() { return new A; }
@@ -39,13 +39,13 @@
 // The size is known.
 //
 // CHECK-LABEL: define {{.*}} @_Z2a1l(
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr @_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 noundef 32)
+// CHECK: %[[ALLOC:.*]] = call noalias nonnull align 32 ptr @_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 noundef 32)
 // No array cookie.
 // CHECK-NOT: store
 // CHECK: invoke void @_ZN1AC1Ev(
 // CHECK: call void @_ZdaPvSt11align_val_t(ptr noundef %[[ALLOC]], i64 noundef 32)
 // CHECK-MS-LABEL: define {{.*}} @"?a1@@YAPEAXJ@Z"(
-// CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr @"??_U@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef %{{.*}}, i64 noundef 32)
+// CHECK-MS: %[[ALLOC:.*]] = call noalias nonnull align 32 ptr @"??_U@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef %{{.*}}, i64 noundef 32)
 // No array cookie.
 // CHECK-MS-NOT: store
 // CHECK-MS: invoke noundef ptr @"??0A@@QEAA@XZ"(
@@ -84,7 +84,7 @@
 void *b0() { return new B; }
 
 // CHECK-LABEL: define {{.*}} @_Z2b1l(
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr @_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 noundef 32)
+// CHECK: %[[ALLOC:.*]] = call noalias nonnull align 32 ptr @_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 noundef 32)
 // No array cookie.
 // CHECK-NOT: store
 // CHECK: invoke void @_ZN1BC1Ev(
@@ -169,7 +169,7 @@
 
 #ifndef UNALIGNED
 // CHECK-LABEL: define {{.*}} @_Z2e0v(
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 4 ptr @_ZnwmSt11align_val_t(i64 noundef 512, i64 noundef 4)
+// CHECK: %[[ALLOC:.*]] = call noalias nonnull align 4 ptr @_ZnwmSt11align_val_t(i64 noundef 512, i64 noundef 4)
 // CHECK: call void @_ZdlPvSt11align_val_t(ptr noundef %[[ALLOC]], i64 noundef 4)
 void *e0() { return new (std::align_val_t(4)) A; }
 
Index: clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp
===================================================================
--- clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp
+++ clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp
@@ -7,7 +7,7 @@
 void *p = new S[2][3]{ { 1, 2, 3 }, { 4, 5, 6 } };
 
 // CHECK-LABEL: define
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull ptr @_Znam(i64 noundef 32)
+// CHECK: %[[ALLOC:.*]] = call noalias nonnull ptr @_Znam(i64 noundef 32)
 // CHECK: store i64 6, ptr %[[ALLOC]]
 // CHECK: %[[START_AS_i8:.*]] = getelementptr inbounds i8, ptr %[[ALLOC]], i64 8
 //
@@ -47,7 +47,7 @@
 // CHECK: call {{.*}} @llvm.umul.with.overflow.i64(i64 %[[N:.*]], i64 12)
 // CHECK: %[[ELTS:.*]] = mul i64 %[[N]], 3
 // CHECK: call {{.*}} @llvm.uadd.with.overflow.i64(i64 %{{.*}}, i64 8)
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull ptr @_Znam(i64 noundef %{{.*}})
+// CHECK: %[[ALLOC:.*]] = call noalias nonnull ptr @_Znam(i64 noundef %{{.*}})
 //
 // CHECK: store i64 %[[ELTS]], ptr %[[ALLOC]]
 // CHECK: %[[START_AS_i8:.*]] = getelementptr inbounds i8, ptr %[[ALLOC]], i64 8
@@ -106,7 +106,7 @@
 // No cookie.
 // CHECK-NOT: @llvm.uadd.with.overflow
 //
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull ptr @_Znam(i64 noundef %{{.*}})
+// CHECK: %[[ALLOC:.*]] = call noalias nonnull ptr @_Znam(i64 noundef %{{.*}})
 //
 //
 // Explicit initializers:
Index: clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
===================================================================
--- clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
+++ clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
@@ -37,26 +37,26 @@
 
 // CHECK-LABEL: define{{.*}} void @test_basic(
 extern "C" void test_basic() {
-  // CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
+  // CHECK: call noalias nonnull ptr @_Znwm(i64 noundef 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
   // CHECK: call void @_ZdlPv({{.*}}) [[ATTR_BUILTIN_DELETE:#[^ ]*]]
   // CHECK: ret void
   __builtin_operator_delete(__builtin_operator_new(4));
 }
-// CHECK: declare noundef nonnull ptr @_Znwm(i64 noundef) [[ATTR_NOBUILTIN:#[^ ]*]]
+// CHECK: declare nonnull ptr @_Znwm(i64 noundef) [[ATTR_NOBUILTIN:#[^ ]*]]
 // CHECK: declare void @_ZdlPv(ptr noundef) [[ATTR_NOBUILTIN_NOUNWIND:#[^ ]*]]
 
 // CHECK-LABEL: define{{.*}} void @test_aligned_alloc(
 extern "C" void test_aligned_alloc() {
-  // CHECK: call noalias noundef nonnull align 4 ptr @_ZnwmSt11align_val_t(i64 noundef 4, i64 noundef 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
+  // CHECK: call noalias nonnull align 4 ptr @_ZnwmSt11align_val_t(i64 noundef 4, i64 noundef 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
   // CHECK: call void @_ZdlPvSt11align_val_t({{.*}}, i64 noundef 4) [[ATTR_BUILTIN_DELETE:#[^ ]*]]
   __builtin_operator_delete(__builtin_operator_new(4, std::align_val_t(4)), std::align_val_t(4));
 }
-// CHECK: declare noundef nonnull ptr @_ZnwmSt11align_val_t(i64 noundef, i64 noundef) [[ATTR_NOBUILTIN:#[^ ]*]]
+// CHECK: declare nonnull ptr @_ZnwmSt11align_val_t(i64 noundef, i64 noundef) [[ATTR_NOBUILTIN:#[^ ]*]]
 // CHECK: declare void @_ZdlPvSt11align_val_t(ptr noundef, i64 noundef) [[ATTR_NOBUILTIN_NOUNWIND:#[^ ]*]]
 
 // CHECK-LABEL: define{{.*}} void @test_sized_delete(
 extern "C" void test_sized_delete() {
-  // CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
+  // CHECK: call noalias nonnull ptr @_Znwm(i64 noundef 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
   // CHECK: call void @_ZdlPvm({{.*}}, i64 noundef 4) [[ATTR_BUILTIN_DELETE:#[^ ]*]]
   __builtin_operator_delete(__builtin_operator_new(4), 4);
 }
Index: clang/test/CodeGenCXX/builtin-is-constant-evaluated.cpp
===================================================================
--- clang/test/CodeGenCXX/builtin-is-constant-evaluated.cpp
+++ clang/test/CodeGenCXX/builtin-is-constant-evaluated.cpp
@@ -85,7 +85,7 @@
 
 // CHECK-ARR-LABEL: define{{.*}} void @_Z17test_new_arr_exprv
 void test_new_arr_expr() {
-  // CHECK-ARR: call noalias noundef nonnull ptr @_Znam(i64 noundef 17)
+  // CHECK-ARR: call noalias nonnull ptr @_Znam(i64 noundef 17)
   new char[std::is_constant_evaluated() || __builtin_is_constant_evaluated() ? 1 : 17];
 }
 
Index: clang/test/CodeGenCXX/builtin-calling-conv.cpp
===================================================================
--- clang/test/CodeGenCXX/builtin-calling-conv.cpp
+++ clang/test/CodeGenCXX/builtin-calling-conv.cpp
@@ -27,27 +27,27 @@
 }
 
 // LINUX: define{{.*}} void @_Z4userv()
-// LINUX: call noalias noundef nonnull ptr @_Znwm
+// LINUX: call noalias nonnull ptr @_Znwm
 // LINUX: call float @atan2f
 // LINUX: call void @_Z3foov
-// LINUX: declare noundef nonnull ptr @_Znwm(i64 noundef)
+// LINUX: declare nonnull ptr @_Znwm(i64 noundef)
 // LINUX: declare float @atan2f(float noundef, float noundef)
 // LINUX: declare void @_Z3foov()
 
 // SPIR: define{{.*}} spir_func void @_Z4userv()
-// SPIR: call spir_func noalias noundef nonnull ptr @_Znwj
+// SPIR: call spir_func noalias nonnull ptr @_Znwj
 // SPIR: call spir_func float @atan2f
 // SPIR: call spir_func void @_Z3foov
-// SPIR: declare spir_func noundef nonnull ptr @_Znwj(i32 noundef)
+// SPIR: declare spir_func nonnull ptr @_Znwj(i32 noundef)
 // SPIR: declare spir_func float @atan2f(float noundef, float noundef)
 // SPIR: declare spir_func void @_Z3foov()
 
 // Note: Windows /G options should not change the platform default calling
 // convention of builtins.
 // WIN32: define dso_local x86_stdcallcc void @"?user@@YGXXZ"()
-// WIN32: call noalias noundef nonnull ptr @"??2@YAPAXI@Z"
+// WIN32: call noalias nonnull ptr @"??2@YAPAXI@Z"
 // WIN32: call float @atan2f
 // WIN32: call x86_stdcallcc void @"?foo@@YGXXZ"
-// WIN32: declare dso_local noundef nonnull ptr @"??2@YAPAXI@Z"(
+// WIN32: declare dso_local nonnull ptr @"??2@YAPAXI@Z"(
 // WIN32: declare dso_local float @atan2f(float noundef, float noundef)
 // WIN32: declare dso_local x86_stdcallcc void @"?foo@@YGXXZ"()
Index: clang/test/CodeGenCXX/align-avx-complete-objects.cpp
===================================================================
--- clang/test/CodeGenCXX/align-avx-complete-objects.cpp
+++ clang/test/CodeGenCXX/align-avx-complete-objects.cpp
@@ -17,8 +17,8 @@
 }
 
 // CHECK: [[R:%.*]] = alloca <8 x float>, align 32
-// PRE17-NEXT:  [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znwm(i64 noundef 32)
-// CXX17-NEXT:  [[CALL:%.*]] = call noalias noundef nonnull align 32 ptr @_ZnwmSt11align_val_t(i64 noundef 32, i64 noundef 32)
+// PRE17-NEXT:  [[CALL:%.*]] = call noalias nonnull ptr @_Znwm(i64 noundef 32)
+// CXX17-NEXT:  [[CALL:%.*]] = call noalias nonnull align 32 ptr @_ZnwmSt11align_val_t(i64 noundef 32, i64 noundef 32)
 // CHECK-NEXT:  store ptr [[CALL]], ptr [[P:%.*]], align 8
 // CHECK-NEXT:  [[ONE:%.*]] = load ptr, ptr [[P]], align 8
 // CHECK-NEXT:  [[TWO:%.*]] = load volatile <8 x float>, ptr [[ONE]], align 16
@@ -49,8 +49,8 @@
 }
 
 // CHECK: [[R:%.*]] = alloca <8 x float>, align 32
-// PRE17-NEXT:  [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znwm(i64 noundef 32)
-// CXX17-NEXT:  [[CALL:%.*]] = call noalias noundef nonnull align 32 ptr @_ZnwmSt11align_val_t(i64 noundef 32, i64 noundef 32)
+// PRE17-NEXT:  [[CALL:%.*]] = call noalias nonnull ptr @_Znwm(i64 noundef 32)
+// CXX17-NEXT:  [[CALL:%.*]] = call noalias nonnull align 32 ptr @_ZnwmSt11align_val_t(i64 noundef 32, i64 noundef 32)
 // CHECK-NEXT:  store ptr [[CALL]], ptr [[P:%.*]], align 8
 // CHECK-NEXT:  [[ONE:%.*]] = load ptr, ptr [[P]], align 8
 // CHECK-NEXT:  [[TWO:%.*]] = load volatile <8 x float>, ptr [[ONE]], align 32
Index: clang/test/CodeGenCXX/aix-alignment.cpp
===================================================================
--- clang/test/CodeGenCXX/aix-alignment.cpp
+++ clang/test/CodeGenCXX/aix-alignment.cpp
@@ -11,8 +11,8 @@
   ~B() {}
 };
 
-// AIX32: %call = call noalias noundef nonnull ptr @_Znam(i32 noundef 8)
-// AIX64: %call = call noalias noundef nonnull ptr @_Znam(i64 noundef 8)
+// AIX32: %call = call noalias nonnull ptr @_Znam(i32 noundef 8)
+// AIX64: %call = call noalias nonnull ptr @_Znam(i64 noundef 8)
 B *allocBp() { return new B[0]; }
 
 // AIX-LABEL: delete.notnull:
Index: clang/test/CodeGen/noundef-analysis.cpp
===================================================================
--- clang/test/CodeGen/noundef-analysis.cpp
+++ clang/test/CodeGen/noundef-analysis.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple arm64-darwin -enable-noundef-analysis -emit-llvm -o - %s | FileCheck %s -check-prefix ENABLED
+// RUN: %clang_cc1 -triple arm64-darwin -fcxx-exceptions -enable-noundef-analysis -emit-llvm -o - %s | FileCheck %s -check-prefix ENABLED-EXCEPTIONS
 // RUN: %clang_cc1 -triple arm64-darwin -no-enable-noundef-analysis -emit-llvm -o - %s | FileCheck %s -check-prefix DISABLED
 
 union u1 {
@@ -21,8 +22,13 @@
 // ENABLED-LABEL: @main(
 // ENABLED:    [[CALL:%.*]] = call noundef {{.*}}i32 @_Z19indirect_callee_inti(i32 noundef {{.*}}0)
 // ENABLED:    [[CALL1:%.*]] = call i32 @_Z21indirect_callee_union2u1(i64 {{.*}})
-// ENABLED:    [[CALL2:%.*]] = call noalias noundef nonnull ptr @_Znwm(i64 noundef 4) #[[ATTR4:[0-9]+]]
+// ENABLED:    [[CALL2:%.*]] = call noalias nonnull ptr @_Znwm(i64 noundef 4) #[[ATTR4:[0-9]+]]
 // ENABLED:    call void @_ZL12examineValuei(i32 noundef {{.*}})
+// ENABLED-EXCEPTIONS-LABEL: @main(
+// ENABLED-EXCEPTIONS:    [[CALL:%.*]] = call noundef {{.*}}i32 @_Z19indirect_callee_inti(i32 noundef {{.*}}0)
+// ENABLED-EXCEPTIONS:    [[CALL1:%.*]] = call i32 @_Z21indirect_callee_union2u1(i64 {{.*}})
+// ENABLED-EXCEPTIONS:    [[CALL2:%.*]] = call noalias noundef nonnull ptr @_Znwm(i64 noundef 4) #[[ATTR4:[0-9]+]]
+// ENABLED-EXCEPTIONS:    call void @_ZL12examineValuei(i32 noundef {{.*}})
 // DISABLED-LABEL: @main(
 // DISABLED:    [[CALL:%.*]] = call {{.*}}i32 @_Z19indirect_callee_inti(i32 {{.*}}0)
 // DISABLED:    [[CALL1:%.*]] = call i32 @_Z21indirect_callee_union2u1(i64 {{.*}})
Index: clang/lib/Sema/SemaExprCXX.cpp
===================================================================
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -3161,9 +3161,13 @@
     Alloc->setVisibleDespiteOwningModule();
 
     if (HasBadAllocExceptionSpec && getLangOpts().NewInfallible &&
-        !getLangOpts().CheckNew)
+        !getLangOpts().CheckNew) {
       Alloc->addAttr(
           ReturnsNonNullAttr::CreateImplicit(Context, Alloc->getLocation()));
+      if (!getLangOpts().CXXExceptions)
+        Alloc->addAttr(ReturnsMaybeUndefAttr::CreateImplicit(
+            Context, Alloc->getLocation()));
+    }
 
     // C++ [basic.stc.dynamic.general]p2:
     //   The library provides default definitions for the global allocation
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16225,8 +16225,16 @@
   // However, -fcheck-new invalidates this possible assumption, so don't add
   // NonNull when that is enabled.
   if (!IsNothrow && !FD->hasAttr<ReturnsNonNullAttr>() &&
-      !getLangOpts().CheckNew)
+      !getLangOpts().CheckNew) {
     FD->addAttr(ReturnsNonNullAttr::CreateImplicit(Context, FD->getLocation()));
+    // FIXME: The current implementation of `operator new` under -fno-exceptions
+    // invalidates this possible assumption. Add ReturnsMaybeUndefAttr to
+    // preserve the never return null semantics of `operator new`. This ensures
+    // that when `operator new` returns null, it is poison and not UB.
+    if (!getLangOpts().CXXExceptions)
+      FD->addAttr(
+          ReturnsMaybeUndefAttr::CreateImplicit(Context, FD->getLocation()));
+  }
 
   // C++2a [basic.stc.dynamic.allocation]p2:
   //   An allocation function attempts to allocate the requested amount of
Index: clang/lib/CodeGen/CGCall.cpp
===================================================================
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2505,7 +2505,8 @@
 
   // Determine if the return type could be partially undef
   if (CodeGenOpts.EnableNoundefAttrs &&
-      HasStrictReturn(*this, RetTy, TargetDecl)) {
+      HasStrictReturn(*this, RetTy, TargetDecl) &&
+      (!TargetDecl || !TargetDecl->hasAttr<ReturnsMaybeUndefAttr>())) {
     if (!RetTy->isVoidType() && RetAI.getKind() != ABIArgInfo::Indirect &&
         DetermineNoUndef(RetTy, getTypes(), DL, RetAI))
       RetAttrs.addAttribute(llvm::Attribute::NoUndef);
Index: clang/include/clang/Basic/Attr.td
===================================================================
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -2028,6 +2028,12 @@
   let Documentation = [ReturnsNonNullDocs];
 }
 
+def ReturnsMaybeUndef : InheritableAttr {
+  let Spellings = [];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [InternalOnly];
+}
+
 def CalledOnce : Attr {
   let Spellings = [Clang<"called_once">];
   let Subjects = SubjectList<[ParmVar]>;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to