[PATCH] D152850: OpenMP: Add missing test coverage for nothrow new/delete

Matt Arsenault via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 13 12:44:35 PDT 2023


arsenm created this revision.
arsenm added reviewers: jdoerfert, ABataev, JonChesterfield, saiislam.
Herald added subscribers: sunshaoce, guansong, yaxunl.
Herald added a project: All.
arsenm requested review of this revision.
Herald added subscribers: jplehr, sstefan1, wdng.

Missing test from fd3437a4f791cb0520e19b87953141fc68543377 <https://reviews.llvm.org/rGfd3437a4f791cb0520e19b87953141fc68543377>


https://reviews.llvm.org/D152850

Files:
  clang/test/Headers/openmp_new_nothrow.cpp


Index: clang/test/Headers/openmp_new_nothrow.cpp
===================================================================
--- /dev/null
+++ clang/test/Headers/openmp_new_nothrow.cpp
@@ -0,0 +1,82 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -std=c++03 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm -fopenmp-is-device -o - %s | FileCheck -check-prefixes=CHECK,CXX03 %s
+// RUN: %clang_cc1 -std=c++11 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -verify -fopenmp -x c++ -triple nvptx64-nvida-cuda -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm -fopenmp-is-device -o - %s | FileCheck -check-prefixes=CHECK,CXX11 %s
+
+// expected-no-diagnostics
+
+#include <new>
+
+#pragma omp begin declare target
+extern const std::nothrow_t nothrow;
+
+// CHECK-LABEL: define hidden noundef ptr @_Z17new_stuff_nothrowv
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[CALL:%.*]] = call noalias noundef ptr @_ZnwmRKSt9nothrow_t(i64 noundef 4, ptr noundef nonnull align 1 dereferenceable(1) @nothrow) #[[ATTR4:[0-9]+]]
+// CHECK-NEXT:    ret ptr [[CALL]]
+//
+int* new_stuff_nothrow() {
+  return new (nothrow) int;
+}
+
+// CXX03-LABEL: define hidden noundef ptr @_Z23new_array_stuff_nothrowv
+// CXX03-SAME: () #[[ATTR0]] {
+// CXX03-NEXT:  entry:
+// CXX03-NEXT:    [[CALL:%.*]] = call noalias noundef ptr @_ZnamRKSt9nothrow_t(i64 noundef 136, ptr noundef nonnull align 1 dereferenceable(1) @nothrow) #[[ATTR4]]
+// CXX03-NEXT:    ret ptr [[CALL]]
+//
+// CXX11-LABEL: define hidden noundef ptr @_Z23new_array_stuff_nothrowv
+// CXX11-SAME: () #[[ATTR0]] {
+// CXX11-NEXT:  entry:
+// CXX11-NEXT:    [[CALL:%.*]] = call noalias noundef ptr @_ZnamRKSt9nothrow_t(i64 noundef 136, ptr noundef nonnull align 1 dereferenceable(1) @nothrow) #[[ATTR7:[0-9]+]]
+// CXX11-NEXT:    ret ptr [[CALL]]
+//
+int* new_array_stuff_nothrow() {
+  return new (nothrow) int[34];
+}
+
+// CXX03-LABEL: define hidden void @_Z20delete_stuff_nothrowPi
+// CXX03-SAME: (ptr noundef [[PTR:%.*]]) #[[ATTR0]] {
+// CXX03-NEXT:  entry:
+// CXX03-NEXT:    [[PTR_ADDR:%.*]] = alloca ptr, align 8
+// CXX03-NEXT:    store ptr [[PTR]], ptr [[PTR_ADDR]], align 8
+// CXX03-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[PTR_ADDR]], align 8
+// CXX03-NEXT:    call void @_ZdlPvRKSt9nothrow_t(ptr noundef [[TMP0]], ptr noundef nonnull align 1 dereferenceable(1) @nothrow) #[[ATTR6:[0-9]+]]
+// CXX03-NEXT:    ret void
+//
+// CXX11-LABEL: define hidden void @_Z20delete_stuff_nothrowPi
+// CXX11-SAME: (ptr noundef [[PTR:%.*]]) #[[ATTR0]] {
+// CXX11-NEXT:  entry:
+// CXX11-NEXT:    [[PTR_ADDR:%.*]] = alloca ptr, align 8
+// CXX11-NEXT:    store ptr [[PTR]], ptr [[PTR_ADDR]], align 8
+// CXX11-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[PTR_ADDR]], align 8
+// CXX11-NEXT:    call void @_ZdlPvRKSt9nothrow_t(ptr noundef [[TMP0]], ptr noundef nonnull align 1 dereferenceable(1) @nothrow) #[[ATTR8:[0-9]+]]
+// CXX11-NEXT:    ret void
+//
+void delete_stuff_nothrow(int* ptr) {
+  operator delete(ptr, nothrow);
+}
+
+// CXX03-LABEL: define hidden void @_Z26delete_array_stuff_nothrowPi
+// CXX03-SAME: (ptr noundef [[PTR:%.*]]) #[[ATTR0]] {
+// CXX03-NEXT:  entry:
+// CXX03-NEXT:    [[PTR_ADDR:%.*]] = alloca ptr, align 8
+// CXX03-NEXT:    store ptr [[PTR]], ptr [[PTR_ADDR]], align 8
+// CXX03-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[PTR_ADDR]], align 8
+// CXX03-NEXT:    call void @_ZdaPvRKSt9nothrow_t(ptr noundef [[TMP0]], ptr noundef nonnull align 1 dereferenceable(1) @nothrow) #[[ATTR6]]
+// CXX03-NEXT:    ret void
+//
+// CXX11-LABEL: define hidden void @_Z26delete_array_stuff_nothrowPi
+// CXX11-SAME: (ptr noundef [[PTR:%.*]]) #[[ATTR0]] {
+// CXX11-NEXT:  entry:
+// CXX11-NEXT:    [[PTR_ADDR:%.*]] = alloca ptr, align 8
+// CXX11-NEXT:    store ptr [[PTR]], ptr [[PTR_ADDR]], align 8
+// CXX11-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[PTR_ADDR]], align 8
+// CXX11-NEXT:    call void @_ZdaPvRKSt9nothrow_t(ptr noundef [[TMP0]], ptr noundef nonnull align 1 dereferenceable(1) @nothrow) #[[ATTR8]]
+// CXX11-NEXT:    ret void
+//
+void delete_array_stuff_nothrow(int* ptr) {
+  operator delete[](ptr, nothrow);
+}
+
+#pragma omp end declare target


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152850.531034.patch
Type: text/x-patch
Size: 4491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230613/4d7963a9/attachment.bin>


More information about the cfe-commits mailing list