[PATCH] D157227: [Clang] Don't add `undef` for `operator new` under -fno-exceptions.

2023-08-09 Thread DianQK via Phabricator via cfe-commits
DianQK abandoned this revision.
DianQK added a comment.

Track this issue at https://github.com/llvm/llvm-project/issues/60717.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157227

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157227: [Clang] Don't add `undef` for `operator new` under -fno-exceptions.

2023-08-07 Thread DianQK via Phabricator via cfe-commits
DianQK added a comment.

In D157227#4564817 , @nikic wrote:

> Removing noundef makes no sense to me, because the return value is noundef 
> even under fno-exceptions. If we remove something, it should be the nonnull 
> attribute, because that's what's actually being violated.

Return null on nonnull is poison. So I can also think that the noundef 
attribute is violated. I think the reason for keeping nonnull is to match the 
semantics of `operator new`. But that probably doesn't make sense either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157227

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157227: [Clang] Don't add `undef` for `operator new` under -fno-exceptions.

2023-08-06 Thread DianQK via Phabricator via cfe-commits
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  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 @@
 
 //