================ @@ -0,0 +1,28 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef SUPPORT_ESCAPE_H +#define SUPPORT_ESCAPE_H + +#include "test_macros.h" + +namespace support { +// This function can be used to hide some objects from compiler optimizations. +// +// For example, this is useful to hide the result of a call to `new` and ensure +// ensure that the compiler doesn't elide the call to new/delete. Otherwise, +// elliding calls to new/delete is allowed by the Standard and compilers actually +// do it when optimizations are enabled. +template <class T> +TEST_CONSTEXPR __attribute__((noinline)) T* escape(T* ptr) TEST_NOEXCEPT { ---------------- mordante wrote:
I'm not too fond of this name, it does not really tell me what it does. How about `do_not_optimized`, which is seen quite often in benchmark suites. https://github.com/llvm/llvm-project/pull/68753 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits