100 changes: 100 additions & 0 deletions clang/test/CodeGenHLSL/builtins/normalize.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
// RUN: --check-prefixes=CHECK,DXIL_CHECK,DXIL_NATIVE_HALF,NATIVE_HALF
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,DXIL_CHECK,NO_HALF,DXIL_NO_HALF
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
// RUN: spirv-unknown-vulkan-compute %s -fnative-half-type \
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
// RUN: --check-prefixes=CHECK,NATIVE_HALF,SPIR_NATIVE_HALF,SPIR_CHECK
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF,SPIR_NO_HALF,SPIR_CHECK

// DXIL_NATIVE_HALF: define noundef half @
// SPIR_NATIVE_HALF: define spir_func noundef half @
// DXIL_NATIVE_HALF: call half @llvm.dx.normalize.f16(half
// SPIR_NATIVE_HALF: call half @llvm.spv.normalize.f16(half
// DXIL_NO_HALF: call float @llvm.dx.normalize.f32(float
// SPIR_NO_HALF: call float @llvm.spv.normalize.f32(float
// NATIVE_HALF: ret half
// NO_HALF: ret float
half test_normalize_half(half p0)
{
return normalize(p0);
}
// DXIL_NATIVE_HALF: define noundef <2 x half> @
// SPIR_NATIVE_HALF: define spir_func noundef <2 x half> @
// DXIL_NATIVE_HALF: call <2 x half> @llvm.dx.normalize.v2f16(<2 x half>
// SPIR_NATIVE_HALF: call <2 x half> @llvm.spv.normalize.v2f16(<2 x half>
// DXIL_NO_HALF: call <2 x float> @llvm.dx.normalize.v2f32(<2 x float>
// SPIR_NO_HALF: call <2 x float> @llvm.spv.normalize.v2f32(<2 x float>
// NATIVE_HALF: ret <2 x half> %hlsl.normalize
// NO_HALF: ret <2 x float> %hlsl.normalize
half2 test_normalize_half2(half2 p0)
{
return normalize(p0);
}
// DXIL_NATIVE_HALF: define noundef <3 x half> @
// SPIR_NATIVE_HALF: define spir_func noundef <3 x half> @
// DXIL_NATIVE_HALF: call <3 x half> @llvm.dx.normalize.v3f16(<3 x half>
// SPIR_NATIVE_HALF: call <3 x half> @llvm.spv.normalize.v3f16(<3 x half>
// DXIL_NO_HALF: call <3 x float> @llvm.dx.normalize.v3f32(<3 x float>
// SPIR_NO_HALF: call <3 x float> @llvm.spv.normalize.v3f32(<3 x float>
// NATIVE_HALF: ret <3 x half> %hlsl.normalize
// NO_HALF: ret <3 x float> %hlsl.normalize
half3 test_normalize_half3(half3 p0)
{
return normalize(p0);
}
// DXIL_NATIVE_HALF: define noundef <4 x half> @
// SPIR_NATIVE_HALF: define spir_func noundef <4 x half> @
// DXIL_NATIVE_HALF: call <4 x half> @llvm.dx.normalize.v4f16(<4 x half>
// SPIR_NATIVE_HALF: call <4 x half> @llvm.spv.normalize.v4f16(<4 x half>
// DXIL_NO_HALF: call <4 x float> @llvm.dx.normalize.v4f32(<4 x float>
// SPIR_NO_HALF: call <4 x float> @llvm.spv.normalize.v4f32(<4 x float>
// NATIVE_HALF: ret <4 x half> %hlsl.normalize
// NO_HALF: ret <4 x float> %hlsl.normalize
half4 test_normalize_half4(half4 p0)
{
return normalize(p0);
}

// DXIL_CHECK: define noundef float @
// SPIR_CHECK: define spir_func noundef float @
// DXIL_CHECK: call float @llvm.dx.normalize.f32(float
// SPIR_CHECK: call float @llvm.spv.normalize.f32(float
// CHECK: ret float
float test_normalize_float(float p0)
{
return normalize(p0);
}
// DXIL_CHECK: define noundef <2 x float> @
// SPIR_CHECK: define spir_func noundef <2 x float> @
// DXIL_CHECK: %hlsl.normalize = call <2 x float> @llvm.dx.normalize.v2f32(
// SPIR_CHECK: %hlsl.normalize = call <2 x float> @llvm.spv.normalize.v2f32(<2 x float>
// CHECK: ret <2 x float> %hlsl.normalize
float2 test_normalize_float2(float2 p0)
{
return normalize(p0);
}
// DXIL_CHECK: define noundef <3 x float> @
// SPIR_CHECK: define spir_func noundef <3 x float> @
// DXIL_CHECK: %hlsl.normalize = call <3 x float> @llvm.dx.normalize.v3f32(
// SPIR_CHECK: %hlsl.normalize = call <3 x float> @llvm.spv.normalize.v3f32(<3 x float>
// CHECK: ret <3 x float> %hlsl.normalize
float3 test_normalize_float3(float3 p0)
{
return normalize(p0);
}
// DXIL_CHECK: define noundef <4 x float> @
// SPIR_CHECK: define spir_func noundef <4 x float> @
// DXIL_CHECK: %hlsl.normalize = call <4 x float> @llvm.dx.normalize.v4f32(
// SPIR_CHECK: %hlsl.normalize = call <4 x float> @llvm.spv.normalize.v4f32(
// CHECK: ret <4 x float> %hlsl.normalize
float4 test_length_float4(float4 p0)
{
return normalize(p0);
}
10 changes: 6 additions & 4 deletions clang/test/CodeGenHLSL/export.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@
// RUN: dxil-pc-shadermodel6.3-library %s \
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s

// CHECK: define void @"?f1@@YAXXZ"()
// CHECK: define void @"?f1@@YAXXZ"() [[Attr:\#[0-9]+]]
export void f1() {
}

// CHECK: define void @"?f2@MyNamespace@@YAXXZ"()
// CHECK: define void @"?f2@MyNamespace@@YAXXZ"() [[Attr]]
namespace MyNamespace {
export void f2() {
}
}

export {
// CHECK: define void @"?f3@@YAXXZ"()
// CHECK: define void @"?f4@@YAXXZ"()
// CHECK: define void @"?f3@@YAXXZ"() [[Attr]]
// CHECK: define void @"?f4@@YAXXZ"() [[Attr]]
void f3() {}
void f4() {}
}

// CHECK: attributes [[Attr]] = { {{.*}} "hlsl.export" {{.*}} }
20 changes: 10 additions & 10 deletions clang/test/Driver/linker-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ __attribute__((visibility("protected"), used)) int x;
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=NVPTX-LINK

// NVPTX-LINK: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70 -O2 {{.*}}.o {{.*}}.o
// NVPTX-LINK: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70 -O2 -flto {{.*}}.o {{.*}}.o

// RUN: clang-offload-packager -o %t.out \
// RUN: --image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
Expand All @@ -30,7 +30,7 @@ __attribute__((visibility("protected"), used)) int x;
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run --device-debug -O0 \
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=NVPTX-LINK-DEBUG

// NVPTX-LINK-DEBUG: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70 -O2 {{.*}}.o {{.*}}.o -g
// NVPTX-LINK-DEBUG: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70 -O2 -flto {{.*}}.o {{.*}}.o -g

// RUN: clang-offload-packager -o %t.out \
// RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
Expand All @@ -39,7 +39,7 @@ __attribute__((visibility("protected"), used)) int x;
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=AMDGPU-LINK

// AMDGPU-LINK: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx908 -O2 -Wl,--no-undefined {{.*}}.o {{.*}}.o
// AMDGPU-LINK: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx908 -O2 -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o

// RUN: clang-offload-packager -o %t.out \
// RUN: --image=file=%t.amdgpu.bc,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx1030 \
Expand All @@ -48,7 +48,7 @@ __attribute__((visibility("protected"), used)) int x;
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run --save-temps -O2 \
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=AMDGPU-LTO-TEMPS

// AMDGPU-LTO-TEMPS: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -O2 -Wl,--no-undefined {{.*}}.o -save-temps
// AMDGPU-LTO-TEMPS: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -O2 -flto -Wl,--no-undefined {{.*}}.o -save-temps

// RUN: clang-offload-packager -o %t.out \
// RUN: --image=file=%t.elf.o,kind=openmp,triple=x86_64-unknown-linux-gnu \
Expand All @@ -59,7 +59,7 @@ __attribute__((visibility("protected"), used)) int x;
// RUN: --linker-path=/usr/bin/ld.lld --whole-archive %t.a --no-whole-archive \
// RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CPU-LINK

// CPU-LINK: clang{{.*}} -o {{.*}}.img --target=x86_64-unknown-linux-gnu -march=native -O2 -Wl,--no-undefined {{.*}}.o {{.*}}.o -Wl,-Bsymbolic -shared -Wl,--whole-archive {{.*}}.a -Wl,--no-whole-archive
// CPU-LINK: clang{{.*}} -o {{.*}}.img --target=x86_64-unknown-linux-gnu -march=native -O2 -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o -Wl,-Bsymbolic -shared -Wl,--whole-archive {{.*}}.a -Wl,--no-whole-archive

// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o
// RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu -mllvm -openmp-opt-disable \
Expand Down Expand Up @@ -148,7 +148,7 @@ __attribute__((visibility("protected"), used)) int x;
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run --clang-backend \
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CLANG-BACKEND

// CLANG-BACKEND: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx908 -O2 -Wl,--no-undefined {{.*}}.o
// CLANG-BACKEND: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx908 -O2 -flto -Wl,--no-undefined {{.*}}.o

// RUN: clang-offload-packager -o %t.out \
// RUN: --image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
Expand All @@ -171,8 +171,8 @@ __attribute__((visibility("protected"), used)) int x;
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
// RUN: --linker-path=/usr/bin/ld %t-on.o %t-off.o %t.a -o a.out 2>&1 | FileCheck %s --check-prefix=AMD-TARGET-ID

// AMD-TARGET-ID: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack+ -O2 -Wl,--no-undefined {{.*}}.o {{.*}}.o
// AMD-TARGET-ID: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack- -O2 -Wl,--no-undefined {{.*}}.o {{.*}}.o
// AMD-TARGET-ID: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack+ -O2 -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
// AMD-TARGET-ID: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack- -O2 -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o

// RUN: clang-offload-packager -o %t-lib.out \
// RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=generic
Expand All @@ -187,8 +187,8 @@ __attribute__((visibility("protected"), used)) int x;
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
// RUN: --linker-path=/usr/bin/ld %t1.o %t2.o %t.a -o a.out 2>&1 | FileCheck %s --check-prefix=ARCH-ALL

// ARCH-ALL: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx90a -O2 -Wl,--no-undefined {{.*}}.o {{.*}}.o
// ARCH-ALL: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx908 -O2 -Wl,--no-undefined {{.*}}.o {{.*}}.o
// ARCH-ALL: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx90a -O2 -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
// ARCH-ALL: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx908 -O2 -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o

// RUN: clang-offload-packager -o %t.out \
// RUN: --image=file=%t.elf.o,kind=openmp,triple=x86_64-unknown-linux-gnu \
Expand Down
3 changes: 3 additions & 0 deletions clang/test/Interpreter/const.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// see https://github.com/llvm/llvm-project/issues/68092
// XFAIL: host={{.*}}-windows-msvc

// The test is flaky with asan https://github.com/llvm/llvm-project/issues/102858.
// UNSUPPORTED: asan

// RUN: cat %s | clang-repl | FileCheck %s
// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s

Expand Down
31 changes: 31 additions & 0 deletions clang/test/SemaHLSL/BuiltIns/normalize-errors.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -verify-ignore-unexpected

void test_too_few_arg()
{
return __builtin_hlsl_normalize();
// expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
}

void test_too_many_arg(float2 p0)
{
return __builtin_hlsl_normalize(p0, p0);
// expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
}

bool builtin_bool_to_float_type_promotion(bool p1)
{
return __builtin_hlsl_normalize(p1);
// expected-error@-1 {passing 'bool' to parameter of incompatible type 'float'}}
}

bool builtin_normalize_int_to_float_promotion(int p1)
{
return __builtin_hlsl_normalize(p1);
// expected-error@-1 {{passing 'int' to parameter of incompatible type 'float'}}
}

bool2 builtin_normalize_int2_to_float2_promotion(int2 p1)
{
return __builtin_hlsl_normalize(p1);
// expected-error@-1 {{passing 'int2' (aka 'vector<int, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}}
}
1 change: 1 addition & 0 deletions clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args) {

// Forward all of the `--offload-opt` and similar options to the device.
if (linkerSupportsLTO(Args)) {
CmdArgs.push_back("-flto");
for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm))
CmdArgs.append(
{"-Xlinker",
Expand Down
11 changes: 11 additions & 0 deletions clang/unittests/Format/TokenAnnotatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3216,6 +3216,17 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
EXPECT_BRACE_KIND(Tokens[17], BK_Block);
EXPECT_BRACE_KIND(Tokens[22], BK_Block);
EXPECT_BRACE_KIND(Tokens[26], BK_Block);

Tokens = annotate("{\n"
"#define M(x) \\\n"
" return {#x};\n"
"}");
ASSERT_EQ(Tokens.size(), 15u) << Tokens;
EXPECT_TOKEN(Tokens[0], tok::l_brace, TT_BlockLBrace);
EXPECT_BRACE_KIND(Tokens[0], BK_Block);
EXPECT_BRACE_KIND(Tokens[8], BK_BracedInit);
EXPECT_BRACE_KIND(Tokens[11], BK_BracedInit);
EXPECT_BRACE_KIND(Tokens[13], BK_Block);
}

TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,35 @@ TEST(DependencyScanningFilesystem, CacheStatOnExists) {
EXPECT_EQ(InstrumentingFS->NumStatusCalls, 2u);
EXPECT_EQ(InstrumentingFS->NumExistsCalls, 0u);
}

TEST(DependencyScanningFilesystem, CacheStatFailures) {
auto InMemoryFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
InMemoryFS->setCurrentWorkingDirectory("/");
InMemoryFS->addFile("/dir/vector", 0, llvm::MemoryBuffer::getMemBuffer(""));
InMemoryFS->addFile("/cache/a.pcm", 0, llvm::MemoryBuffer::getMemBuffer(""));

auto InstrumentingFS =
llvm::makeIntrusiveRefCnt<InstrumentingFilesystem>(InMemoryFS);

DependencyScanningFilesystemSharedCache SharedCache;
DependencyScanningWorkerFilesystem DepFS(SharedCache, InstrumentingFS);

DepFS.status("/dir");
DepFS.status("/dir");
EXPECT_EQ(InstrumentingFS->NumStatusCalls, 1u);

DepFS.status("/dir/vector");
DepFS.status("/dir/vector");
EXPECT_EQ(InstrumentingFS->NumStatusCalls, 2u);

DepFS.setBypassedPathPrefix("/cache");
DepFS.exists("/cache/a.pcm");
EXPECT_EQ(InstrumentingFS->NumStatusCalls, 3u);
DepFS.exists("/cache/a.pcm");
EXPECT_EQ(InstrumentingFS->NumStatusCalls, 4u);

DepFS.resetBypassedPathPrefix();
DepFS.exists("/cache/a.pcm");
DepFS.exists("/cache/a.pcm");
EXPECT_EQ(InstrumentingFS->NumStatusCalls, 5u);
}
4 changes: 3 additions & 1 deletion compiler-rt/lib/fuzzer/FuzzerDictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ template <size_t kMaxSizeT> class FixedWord {
static_assert(kMaxSizeT <= std::numeric_limits<uint8_t>::max(),
"FixedWord::kMaxSizeT cannot fit in a uint8_t.");
assert(S <= kMaxSize);
memcpy(Data, B, S);
// memcpy cannot take null pointer arguments even if Size is 0.
if (S)
memcpy(Data, B, S);
Size = static_cast<uint8_t>(S);
}

Expand Down
7 changes: 6 additions & 1 deletion compiler-rt/lib/fuzzer/FuzzerLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,9 @@ void Fuzzer::CrashOnOverwrittenData() {
// Compare two arrays, but not all bytes if the arrays are large.
static bool LooseMemeq(const uint8_t *A, const uint8_t *B, size_t Size) {
const size_t Limit = 64;
// memcmp cannot take null pointer arguments even if Size is 0.
if (!Size)
return true;
if (Size <= 64)
return !memcmp(A, B, Size);
// Compare first and last Limit/2 bytes.
Expand All @@ -596,7 +599,9 @@ ATTRIBUTE_NOINLINE bool Fuzzer::ExecuteCallback(const uint8_t *Data,
// We copy the contents of Unit into a separate heap buffer
// so that we reliably find buffer overflows in it.
uint8_t *DataCopy = new uint8_t[Size];
memcpy(DataCopy, Data, Size);
// memcpy cannot take null pointer arguments even if Size is 0.
if (Size)
memcpy(DataCopy, Data, Size);
if (EF->__msan_unpoison)
EF->__msan_unpoison(DataCopy, Size);
if (EF->__msan_unpoison_param)
Expand Down
8 changes: 8 additions & 0 deletions compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,11 @@ void WriteOneLineToSyslog(const char *s) {
if (GetMacosAlignedVersion() >= MacosVersion(10, 12)) {
os_log_error(OS_LOG_DEFAULT, "%{public}s", s);
} else {
#pragma clang diagnostic push
// as_log is deprecated.
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
asl_log(nullptr, nullptr, ASL_LEVEL_ERR, "%s", s);
#pragma clang diagnostic pop
}
#endif
}
Expand Down Expand Up @@ -843,6 +847,9 @@ void LogFullErrorReport(const char *buffer) {
#if !SANITIZER_GO
// Log with os_trace. This will make it into the crash log.
#if SANITIZER_OS_TRACE
#pragma clang diagnostic push
// os_trace is deprecated.
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (GetMacosAlignedVersion() >= MacosVersion(10, 10)) {
// os_trace requires the message (format parameter) to be a string literal.
if (internal_strncmp(SanitizerToolName, "AddressSanitizer",
Expand All @@ -860,6 +867,7 @@ void LogFullErrorReport(const char *buffer) {
if (common_flags()->log_to_syslog)
os_trace("Consult syslog for more information.");
}
#pragma clang diagnostic pop
#endif

// Log to syslog.
Expand Down
4 changes: 4 additions & 0 deletions compiler-rt/lib/scudo/standalone/timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#include "string_utils.h"
#include "thread_annotations.h"

#ifndef __STDC_FORMAT_MACROS
// Ensure PRId64 macro is available
#define __STDC_FORMAT_MACROS 1
#endif
#include <inttypes.h>
#include <string.h>

Expand Down
8 changes: 8 additions & 0 deletions compiler-rt/lib/tsan/rtl/tsan_interceptors_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ static constexpr morder kMacFailureOrder = mo_relaxed;
m_orig(int32_t, uint32_t, a32, f##32##OrigBarrier, \
__tsan_atomic32_##tsan_atomic_f, kMacOrderBarrier)


#pragma clang diagnostic push
// OSAtomic* functions are deprecated.
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
OSATOMIC_INTERCEPTORS_ARITHMETIC(OSAtomicAdd, fetch_add,
OSATOMIC_INTERCEPTOR_PLUS_X)
OSATOMIC_INTERCEPTORS_ARITHMETIC(OSAtomicIncrement, fetch_add,
Expand Down Expand Up @@ -123,6 +127,9 @@ OSATOMIC_INTERCEPTORS_BITWISE(OSAtomicXor, fetch_xor,
kMacOrderBarrier, kMacFailureOrder); \
}

#pragma clang diagnostic push
// OSAtomicCompareAndSwap* functions are deprecated.
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
OSATOMIC_INTERCEPTORS_CAS(OSAtomicCompareAndSwapInt, __tsan_atomic32, a32, int)
OSATOMIC_INTERCEPTORS_CAS(OSAtomicCompareAndSwapLong, __tsan_atomic64, a64,
long_t)
Expand All @@ -132,6 +139,7 @@ OSATOMIC_INTERCEPTORS_CAS(OSAtomicCompareAndSwap32, __tsan_atomic32, a32,
int32_t)
OSATOMIC_INTERCEPTORS_CAS(OSAtomicCompareAndSwap64, __tsan_atomic64, a64,
int64_t)
#pragma clang diagnostic pop

#define OSATOMIC_INTERCEPTOR_BITOP(f, op, clear, mo) \
TSAN_INTERCEPTOR(bool, f, uint32_t n, volatile void *ptr) { \
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/dfsan/custom.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clang_dfsan %s -o %t && DFSAN_OPTIONS="strict_data_dependencies=0" %run %t
// RUN: %clang_dfsan %s -o %t && env DFSAN_OPTIONS="strict_data_dependencies=0" %run %t
// RUN: %clang_dfsan -DSTRICT_DATA_DEPENDENCIES %s -o %t && %run %t
// RUN: %clang_dfsan -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 -mllvm -dfsan-combine-pointer-labels-on-load=false -DSTRICT_DATA_DEPENDENCIES %s -o %t && %run %t
// RUN: %clang_dfsan -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 -mllvm -dfsan-combine-pointer-labels-on-load=false -no-pie %s -o %t && DFSAN_OPTIONS="strict_data_dependencies=0" %run %t
// RUN: %clang_dfsan -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 -mllvm -dfsan-combine-pointer-labels-on-load=false -no-pie %s -o %t && env DFSAN_OPTIONS="strict_data_dependencies=0" %run %t
//
// Tests custom implementations of various glibc functions.

Expand Down
6 changes: 3 additions & 3 deletions compiler-rt/test/dfsan/flags.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %clang_dfsan %s -fsanitize-ignorelist=%S/Inputs/flags_abilist.txt -mllvm -dfsan-debug-nonzero-labels -o %t && DFSAN_OPTIONS=warn_unimplemented=1 %run %t 2>&1 | FileCheck %s
// RUN: %clang_dfsan %s -fsanitize-ignorelist=%S/Inputs/flags_abilist.txt -mllvm -dfsan-debug-nonzero-labels -o %t && DFSAN_OPTIONS=warn_unimplemented=0 %run %t 2>&1 | count 0
// RUN: %clang_dfsan %s -fsanitize-ignorelist=%S/Inputs/flags_abilist.txt -mllvm -dfsan-debug-nonzero-labels -o %t && DFSAN_OPTIONS=warn_nonzero_labels=1 %run %t 2>&1 | FileCheck --check-prefix=CHECK-NONZERO %s
// RUN: %clang_dfsan %s -fsanitize-ignorelist=%S/Inputs/flags_abilist.txt -mllvm -dfsan-debug-nonzero-labels -o %t && env DFSAN_OPTIONS=warn_unimplemented=1 %run %t 2>&1 | FileCheck %s
// RUN: %clang_dfsan %s -fsanitize-ignorelist=%S/Inputs/flags_abilist.txt -mllvm -dfsan-debug-nonzero-labels -o %t && env DFSAN_OPTIONS=warn_unimplemented=0 %run %t 2>&1 | count 0
// RUN: %clang_dfsan %s -fsanitize-ignorelist=%S/Inputs/flags_abilist.txt -mllvm -dfsan-debug-nonzero-labels -o %t && env DFSAN_OPTIONS=warn_nonzero_labels=1 %run %t 2>&1 | FileCheck --check-prefix=CHECK-NONZERO %s

// Tests that flags work correctly.

Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/dfsan/fork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// RUN: %run %t 2>&1 | FileCheck %s
//
// RUN: %clangxx_dfsan -mllvm -dfsan-track-origins=1 %s -o %t
// RUN: DFSAN_OPTIONS=store_context_size=1000,origin_history_size=0,origin_history_per_stack_limit=0 %run %t 2>&1 | FileCheck %s
// RUN: env DFSAN_OPTIONS=store_context_size=1000,origin_history_size=0,origin_history_per_stack_limit=0 %run %t 2>&1 | FileCheck %s

#include <assert.h>
#include <errno.h>
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/dfsan/origin_limit.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// RUN: %run %t >%t.out 2>&1
// RUN: FileCheck %s < %t.out
//
// RUN: DFSAN_OPTIONS=origin_history_size=2 %run %t >%t.out 2>&1
// RUN: env DFSAN_OPTIONS=origin_history_size=2 %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK2 < %t.out
//
// RUN: DFSAN_OPTIONS=origin_history_size=0 %run %t >%t.out 2>&1
// RUN: env DFSAN_OPTIONS=origin_history_size=0 %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK0 < %t.out

#include <sanitizer/dfsan_interface.h>
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/test/fuzzer/fork-sigusr.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Check that libFuzzer honors SIGUSR1/SIGUSR2
# Disabled on Windows which does not have SIGUSR1/SIGUSR2.
REQUIRES: shell
UNSUPPORTED: darwin, target={{.*windows.*}}, target=aarch64{{.*}}
RUN: rm -rf %t
RUN: mkdir -p %t
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/test/fuzzer/merge-sigusr.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Check that libFuzzer honors SIGUSR1/SIGUSR2
# FIXME: Disabled on Windows for now because of reliance on posix only features
# (eg: export, "&", pkill).
REQUIRES: shell
UNSUPPORTED: darwin, target={{.*windows.*}}
RUN: rm -rf %t
RUN: mkdir -p %t
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/fuzzer/sigint.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REQUIRES: msan
REQUIRES: shell, msan
UNSUPPORTED: target=arm{{.*}}

# Check that libFuzzer exits gracefully under SIGINT with MSan.
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/test/fuzzer/sigusr.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# FIXME: Disabled on Windows for now because of reliance on posix only features
# (eg: export, "&", pkill).
REQUIRES: shell
UNSUPPORTED: darwin, target={{.*windows.*}}
# Check that libFuzzer honors SIGUSR1/SIGUSR2
RUN: rm -rf %t
Expand Down
8 changes: 4 additions & 4 deletions compiler-rt/test/msan/Linux/sendmsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
// RUN: %clangxx_msan %s -DSENDMMSG -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE

// RUN: %clangxx_msan %s -DSEND -DPOISON -o %t && \
// RUN: MSAN_OPTIONS=intercept_send=0 %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE
// RUN: env MSAN_OPTIONS=intercept_send=0 %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE
// RUN: %clangxx_msan %s -DSENDTO -DPOISON -o %t && \
// RUN: MSAN_OPTIONS=intercept_send=0 %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE
// RUN: env MSAN_OPTIONS=intercept_send=0 %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE
// RUN: %clangxx_msan %s -DSENDMSG -DPOISON -o %t && \
// RUN: MSAN_OPTIONS=intercept_send=0 %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE
// RUN: env MSAN_OPTIONS=intercept_send=0 %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE
// RUN: %clangxx_msan %s -DSENDMMSG -DPOISON -o %t && \
// RUN: MSAN_OPTIONS=intercept_send=0 %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE
// RUN: env MSAN_OPTIONS=intercept_send=0 %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE

// UNSUPPORTED: android

Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/chained_origin_empty_stack.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -O3 %s -o %t && \
// RUN: MSAN_OPTIONS=store_context_size=1 not %run %t 2>&1 | FileCheck %s
// RUN: env MSAN_OPTIONS=store_context_size=1 not %run %t 2>&1 | FileCheck %s

// Test that stack trace for the intermediate store is not empty.

Expand Down
34 changes: 16 additions & 18 deletions compiler-rt/test/msan/chained_origin_limits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,61 @@
// Heap origin.
// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O3 %s -o %t

// RUN: MSAN_OPTIONS=origin_history_size=7 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_size=7 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK7 < %t.out

// RUN: MSAN_OPTIONS=origin_history_size=2 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_size=2 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK2 < %t.out

// RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK --check-prefix=CHECK-%short-stack < %t.out

// RUN: MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK7 < %t.out

// Stack origin.
// RUN: %clangxx_msan -DSTACK -fsanitize-memory-track-origins=2 -O3 %s -o %t

// RUN: MSAN_OPTIONS=origin_history_size=7 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_size=7 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK7 < %t.out

// RUN: MSAN_OPTIONS=origin_history_size=2 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_size=2 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK2 < %t.out

// RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK --check-prefix=CHECK-%short-stack < %t.out

// RUN: MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK7 < %t.out


// Heap origin, with calls.
// RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -O3 %s -o %t

// RUN: MSAN_OPTIONS=origin_history_size=7 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_size=7 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK7 < %t.out

// RUN: MSAN_OPTIONS=origin_history_size=2 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_size=2 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK2 < %t.out

// RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK --check-prefix=CHECK-%short-stack < %t.out

// RUN: MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK7 < %t.out


// Stack origin, with calls.
// RUN: %clangxx_msan -DSTACK -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -O3 %s -o %t

// RUN: MSAN_OPTIONS=origin_history_size=7 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_size=7 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK7 < %t.out

// RUN: MSAN_OPTIONS=origin_history_size=2 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_size=2 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK2 < %t.out

// RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK --check-prefix=CHECK-%short-stack < %t.out

// RUN: MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
// RUN: env MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK7 < %t.out

#include <stdio.h>
Expand Down
8 changes: 4 additions & 4 deletions compiler-rt/test/msan/coverage-levels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
//
// RUN: %clangxx_msan -DINIT_VAR=1 -O1 -fsanitize-coverage=func,trace-pc-guard %s -o %t
// RUN: mkdir -p %t-dir
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN
// RUN: env MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN
// RUN: %clangxx_msan -O1 -fsanitize-coverage=func,trace-pc-guard %s -o %t
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_WARN
// RUN: env MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_WARN
// RUN: %clangxx_msan -O1 -fsanitize-coverage=bb,trace-pc-guard %s -o %t
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2 --check-prefix=CHECK_WARN
// RUN: env MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2 --check-prefix=CHECK_WARN
// RUN: %clangxx_msan -O1 -fsanitize-coverage=edge,trace-pc-guard %s -o %t
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN
// RUN: env MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN

volatile int sink;
int main(int argc, char **argv) {
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/dtor-member.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// RUN: %clangxx_msan %s -fsanitize=memory -fno-sanitize-memory-use-after-dtor -o %t && %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK-NO-FLAG < %t.out

// RUN: %clangxx_msan -fsanitize=memory -fsanitize-memory-use-after-dtor %s -o %t && MSAN_OPTIONS=poison_in_dtor=0 %run %t >%t.out 2>&1
// RUN: %clangxx_msan -fsanitize=memory -fsanitize-memory-use-after-dtor %s -o %t && env MSAN_OPTIONS=poison_in_dtor=0 %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK-NO-FLAG < %t.out

#include <sanitizer/msan_interface.h>
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/fork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// and verify that origin reads do not deadlock in the child process.

// RUN: %clangxx_msan -std=c++11 -fsanitize-memory-track-origins=2 -g -O3 %s -o %t
// RUN: MSAN_OPTIONS=store_context_size=1000,origin_history_size=0,origin_history_per_stack_limit=0 %run %t 2>&1 | FileCheck %s
// RUN: env MSAN_OPTIONS=store_context_size=1000,origin_history_size=0,origin_history_per_stack_limit=0 %run %t 2>&1 | FileCheck %s

// Fun fact: if test output is redirected to a file (as opposed to
// being piped directly to FileCheck), we may lose some "done"s due to
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/interception_sigaction_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clangxx_msan -O0 -g %s -o %t
// RUN: MSAN_OPTIONS=handle_segv=2 %t 2>&1 | FileCheck %s
// RUN: env MSAN_OPTIONS=handle_segv=2 %t 2>&1 | FileCheck %s
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/memcmp_test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %clangxx_msan -O0 -g %s -o %t
// RUN: not %run %t 2>&1 | FileCheck %s
// RUN: MSAN_OPTIONS=intercept_memcmp=0 %run %t
// RUN: env MSAN_OPTIONS=intercept_memcmp=0 %run %t

#include <string.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/msan_check_mem_is_initialized.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %clangxx_msan -O0 -g -DPOSITIVE %s -o %t
// RUN: not %run %t 2>&1 | FileCheck %s
// RUN: MSAN_OPTIONS=verbosity=1 not %run %t 2>&1 | \
// RUN: env MSAN_OPTIONS=verbosity=1 not %run %t 2>&1 | \
// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-VERBOSE

// RUN: %clangxx_msan -O0 -g %s -o %t && %run %t
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/poison_in_free.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&1
// FileCheck %s <%t.out
// RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=poison_in_free=0 %run %t >%t.out 2>&1
// RUN: %clangxx_msan -O0 %s -o %t && env MSAN_OPTIONS=poison_in_free=0 %run %t >%t.out 2>&1

#include <stdio.h>
#include <stdlib.h>
Expand Down
12 changes: 6 additions & 6 deletions compiler-rt/test/msan/print_stats.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -g %s -o %t
// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -g %s -o %t
// RUN: %run %t 2>&1 | \
// RUN: FileCheck --check-prefixes=CHECK,CHECK-NOSTATS %s
// RUN: MSAN_OPTIONS=print_stats=1 %run %t 2>&1 | \
// RUN: env MSAN_OPTIONS=print_stats=1 %run %t 2>&1 | \
// RUN: FileCheck --check-prefixes=CHECK,CHECK-NOSTATS %s
// RUN: MSAN_OPTIONS=print_stats=1,atexit=1 %run %t 2>&1 | \
// RUN: env MSAN_OPTIONS=print_stats=1,atexit=1 %run %t 2>&1 | \
// RUN: FileCheck --check-prefixes=CHECK,CHECK-STATS %s

// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -g -DPOSITIVE=1 %s -o %t
// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -g -DPOSITIVE=1 %s -o %t
// RUN: not %run %t 2>&1 | \
// RUN: FileCheck --check-prefixes=CHECK,CHECK-NOSTATS %s
// RUN: MSAN_OPTIONS=print_stats=1 not %run %t 2>&1 | \
// RUN: env MSAN_OPTIONS=print_stats=1 not %run %t 2>&1 | \
// RUN: FileCheck --check-prefixes=CHECK,CHECK-STATS %s

// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -fsanitize-recover=memory -g -DPOSITIVE=1 %s -o %t
// RUN: not %run %t 2>&1 | \
// RUN: FileCheck --check-prefixes=CHECK,CHECK-NOSTATS,CHECK-RECOVER %s
// RUN: MSAN_OPTIONS=print_stats=1 not %run %t 2>&1 | \
// RUN: env MSAN_OPTIONS=print_stats=1 not %run %t 2>&1 | \
// RUN: FileCheck --check-prefixes=CHECK,CHECK-STATS,CHECK-RECOVER %s

#include <stdio.h>
Expand Down
8 changes: 4 additions & 4 deletions compiler-rt/test/msan/recover-dso.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&1
// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out
// RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
// RUN: %clangxx_msan -O0 %s -o %t && env MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
// FileCheck %s <%t.out
// RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1
// RUN: %clangxx_msan -O0 %s -o %t && env MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1
// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out

// Test how -fsanitize-recover=memory and MSAN_OPTIONS=keep_going affect reports
Expand All @@ -12,9 +12,9 @@

// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && not %run %t >%t.out 2>&1
// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out
// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && env MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
// FileCheck %s <%t.out
// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1
// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && env MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1
// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out

// Test how legacy -mllvm -msan-keep-going and MSAN_OPTIONS=keep_going affect
Expand Down
14 changes: 7 additions & 7 deletions compiler-rt/test/msan/recover.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&1
// FileCheck %s <%t.out
// RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
// RUN: %clangxx_msan -O0 %s -o %t && env MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
// FileCheck %s <%t.out
// RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1
// RUN: %clangxx_msan -O0 %s -o %t && env MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1
// FileCheck %s <%t.out

// Test behavior of -fsanitize-recover=memory and MSAN_OPTIONS=keep_going.
Expand All @@ -11,20 +11,20 @@

// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && not %run %t >%t.out 2>&1
// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out
// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && env MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
// FileCheck %s <%t.out
// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1
// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && env MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1
// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out
// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=halt_on_error=1 not %run %t >%t.out 2>&1
// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && env MSAN_OPTIONS=halt_on_error=1 not %run %t >%t.out 2>&1
// FileCheck %s <%t.out
// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=halt_on_error=0 not %run %t >%t.out 2>&1
// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && env MSAN_OPTIONS=halt_on_error=0 not %run %t >%t.out 2>&1
// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out

// Basic test of legacy -mllvm -msan-keep-going and MSAN_OPTIONS=keep_going.

// RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && not %run %t >%t.out 2>&1
// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out
// RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
// RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && env MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
// FileCheck %s <%t.out

#include <stdio.h>
Expand Down
6 changes: 3 additions & 3 deletions compiler-rt/test/msan/release_origin.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clang_msan -fsanitize-memory-track-origins=0 -O0 %s -o %t && MSAN_OPTIONS=soft_rss_limit_mb=18:verbosity=1:allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s -implicit-check-not="soft rss limit" -check-prefixes=CHECK,NOORIG
// RUN: %clang_msan -fsanitize-memory-track-origins=2 -O0 %s -o %t && MSAN_OPTIONS=soft_rss_limit_mb=36:verbosity=1:allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s -implicit-check-not="soft rss limit" -check-prefixes=CHECK,ORIGIN
// RUN: %clang_msan -fsanitize-memory-track-origins=0 -O0 %s -o %t && env MSAN_OPTIONS=soft_rss_limit_mb=18:verbosity=1:allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s -implicit-check-not="soft rss limit" -check-prefixes=CHECK,NOORIG
// RUN: %clang_msan -fsanitize-memory-track-origins=2 -O0 %s -o %t && env MSAN_OPTIONS=soft_rss_limit_mb=36:verbosity=1:allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s -implicit-check-not="soft rss limit" -check-prefixes=CHECK,ORIGIN

#include <assert.h>
#include <sanitizer/allocator_interface.h>
Expand Down Expand Up @@ -39,4 +39,4 @@ int main(int argc, char **argv) {
// CHECK-LABEL: free

// Now non-origin release all everything.
// NOORIG: soft rss limit unexhausted
// NOORIG: soft rss limit unexhausted
4 changes: 2 additions & 2 deletions compiler-rt/test/msan/strcmp.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %clang_msan %s -o %t
// RUN: MSAN_OPTIONS=intercept_strcmp=false %run %t 2>&1
// RUN: MSAN_OPTIONS=intercept_strcmp=true not %run %t 2>&1 | FileCheck %s
// RUN: env MSAN_OPTIONS=intercept_strcmp=false %run %t 2>&1
// RUN: env MSAN_OPTIONS=intercept_strcmp=true not %run %t 2>&1 | FileCheck %s
// RUN: not %run %t 2>&1 | FileCheck %s

#include <assert.h>
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/strndup.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clangxx_msan %s -o %t && not %run %t 2>&1 | FileCheck --check-prefix=ON %s
// RUN: %clangxx_msan %s -o %t && MSAN_OPTIONS=intercept_strndup=0 %run %t 2>&1 | FileCheck --check-prefix=OFF --allow-empty %s
// RUN: %clangxx_msan %s -o %t && env MSAN_OPTIONS=intercept_strndup=0 %run %t 2>&1 | FileCheck --check-prefix=OFF --allow-empty %s

// When built as C on Linux, strndup is transformed to __strndup.
// RUN: %clangxx_msan -O3 -xc %s -o %t && not %run %t 2>&1 | FileCheck --check-prefix=ON %s
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/profile/Linux/instrprof-comdat.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RUN: mkdir -p %t.d
RUN: %clangxx_profgen -o %t.d/comdat -fcoverage-mapping -fuse-ld=gold %S/../Inputs/instrprof-comdat-1.cpp %S/../Inputs/instrprof-comdat-2.cpp
RUN: LLVM_PROFILE_FILE=%t-comdat.profraw %run %t.d/comdat
RUN: env LLVM_PROFILE_FILE=%t-comdat.profraw %run %t.d/comdat
RUN: llvm-profdata merge -o %t.d/comdat.prof %t-comdat.profraw
RUN: llvm-cov show --instr-profile=%t.d/comdat.prof %t.d/comdat | FileCheck --check-prefix=HEADER %S/../Inputs/instrprof-comdat.h

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -O1 %s -o %t && TSAN_OPTIONS="flush_memory_ms=1 memory_limit_mb=1" %run %t 2>&1 | FileCheck %s
// RUN: %clangxx -O1 %s -o %t && env TSAN_OPTIONS="flush_memory_ms=1 memory_limit_mb=1" %run %t 2>&1 | FileCheck %s

// JVM uses SEGV to preempt threads. All threads do a load from a known address
// periodically. When runtime needs to preempt threads, it unmaps the page.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// REQUIRES: ubsan-standalone
// REQUIRES: target={{x86_64.*}}
// UNSUPPORTED: i386-target-arch, internal_symbolizer
// RUN: %clangxx -fsanitize=bool -static %s -o %t && UBSAN_OPTIONS=handle_segv=0:handle_sigbus=0:handle_sigfpe=0 %run %t 2>&1 | FileCheck %s
// RUN: %clangxx -fsanitize=bool -static %s -o %t && env UBSAN_OPTIONS=handle_segv=0:handle_sigbus=0:handle_sigfpe=0 %run %t 2>&1 | FileCheck %s
// RUN: %run %t 2>&1 | FileCheck %s
#include <signal.h>
#include <stdio.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// RUN: rm -f arg0-arg1-logging-*
// RUN: %clangxx_xray -std=c++11 %s -o %t
// RUN: XRAY_OPTIONS="patch_premain=true verbosity=1 xray_logfile_base=arg0-arg1-logging-" %run %t
// RUN: env XRAY_OPTIONS="patch_premain=true verbosity=1 xray_logfile_base=arg0-arg1-logging-" %run %t

// REQUIRES: target={{(aarch64|x86_64)-.*}}

Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/xray/TestCases/Posix/arg1-logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// RUN: %clangxx_xray -std=c++11 %s -o %t
// RUN: rm -f arg1-logger-*
// RUN: XRAY_OPTIONS="patch_premain=true verbosity=1 xray_mode=xray-basic \
// RUN: env XRAY_OPTIONS="patch_premain=true verbosity=1 xray_mode=xray-basic \
// RUN: xray_logfile_base=arg1-logger-" %run %t 2>&1 | FileCheck %s
//
// After all that, clean up the XRay log file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// RUN: %clangxx_xray -g -std=c++11 %s -o %t
// RUN: rm -f log-args-this-*
// RUN: XRAY_OPTIONS="patch_premain=true verbosity=1 xray_logfile_base=log-args-this-" %run %t
// RUN: env XRAY_OPTIONS="patch_premain=true verbosity=1 xray_logfile_base=log-args-this-" %run %t

// REQUIRES: target={{(aarch64|x86_64)-.*}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// name.

// RUN: %clangxx_xray -std=c++11 %s -o %t
// RUN: XRAY_OPTIONS="patch_premain=true xray_mode=xray-basic" %run %t > xray.log.file.name 2>&1
// RUN: env XRAY_OPTIONS="patch_premain=true xray_mode=xray-basic" %run %t > xray.log.file.name 2>&1
// RUN: ls | FileCheck xray.log.file.name
// RUN: rm xray-log.argv0-log-file-name.* xray.log.file.name

Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/xray/TestCases/Posix/coverage-sample.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Check that we can patch and unpatch specific function ids.
//
// RUN: %clangxx_xray -std=c++11 %s -o %t
// RUN: XRAY_OPTIONS="patch_premain=false" %run %t | FileCheck %s
// RUN: env XRAY_OPTIONS="patch_premain=false" %run %t | FileCheck %s
// RUN: %clangxx_xray -fno-xray-function-index -std=c++11 %s -o %t
// RUN: XRAY_OPTIONS="patch_premain=false" %run %t | FileCheck %s
// RUN: env XRAY_OPTIONS="patch_premain=false" %run %t | FileCheck %s

// UNSUPPORTED: target-is-mips64,target-is-mips64el

Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/xray/TestCases/Posix/fdr-reinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// UNSUPPORTED: target={{(aarch64|arm).*}}
// RUN: %clangxx_xray -g -std=c++11 %s -o %t
// RUN: rm xray-log.fdr-reinit* || true
// RUN: XRAY_OPTIONS="verbosity=1" %run %t
// RUN: env XRAY_OPTIONS="verbosity=1" %run %t
// RUN: rm xray-log.fdr-reinit* || true
#include "xray/xray_log_interface.h"
#include <atomic>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Check to make sure that we have a log file with a fixed-size.

// RUN: %clangxx_xray -std=c++11 %s -o %t
// RUN: XRAY_OPTIONS="patch_premain=true xray_mode=xray-basic verbosity=1 xray_logfile_base=fixedsize-logging-" %run %t 2>&1 | FileCheck %s
// RUN: env XRAY_OPTIONS="patch_premain=true xray_mode=xray-basic verbosity=1 xray_logfile_base=fixedsize-logging-" %run %t 2>&1 | FileCheck %s
//
// After all that, clean up the output xray log.
//
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/xray/TestCases/Posix/func-id-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// maximum function id for the current binary.
//
// RUN: %clangxx_xray -std=c++11 %s -o %t
// RUN: XRAY_OPTIONS="patch_premain=false" %run %t
// RUN: env XRAY_OPTIONS="patch_premain=false" %run %t
// RUN: %clangxx_xray -fno-xray-function-index -std=c++11 %s -o %t
// RUN: XRAY_OPTIONS="patch_premain=false" %run %t
// RUN: env XRAY_OPTIONS="patch_premain=false" %run %t

// UNSUPPORTED: target-is-mips64,target-is-mips64el

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// we turn it off via options.

// RUN: %clangxx_xray -std=c++11 %s -o %t
// RUN: XRAY_OPTIONS="patch_premain=true verbosity=1 xray_logfile_base=optional-inmemory-log.xray-" %run %t 2>&1 | FileCheck %s
// RUN: env XRAY_OPTIONS="patch_premain=true verbosity=1 xray_logfile_base=optional-inmemory-log.xray-" %run %t 2>&1 | FileCheck %s
//
// Make sure we clean out the logs in case there was a bug.
//
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/xray/TestCases/Posix/patching-unpatching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// appropriately.
//
// RUN: %clangxx_xray -fxray-instrument -std=c++11 %s -o %t
// RUN: XRAY_OPTIONS="patch_premain=false" %run %t 2>&1 | FileCheck %s
// RUN: env XRAY_OPTIONS="patch_premain=false" %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_xray -fxray-instrument -fno-xray-function-index -std=c++11 %s -o %t
// RUN: XRAY_OPTIONS="patch_premain=false" %run %t 2>&1 | FileCheck %s
// RUN: env XRAY_OPTIONS="patch_premain=false" %run %t 2>&1 | FileCheck %s

// UNSUPPORTED: target-is-mips64,target-is-mips64el

Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/xray/TestCases/Posix/pic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// RUN: %clangxx_xray -fxray-instrument -std=c++11 -ffunction-sections \
// RUN: -fdata-sections -fpic -fpie -Wl,--gc-sections %s -o %t
// RUN: rm -f pic-test-logging-*
// RUN: XRAY_OPTIONS="patch_premain=true verbosity=1 xray_mode=xray-basic \
// RUN: env XRAY_OPTIONS="patch_premain=true verbosity=1 xray_mode=xray-basic \
// RUN: xray_logfile_base=pic-test-logging-" %run %t 2>&1 | FileCheck %s
// After all that, clean up the output xray log.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clangxx_xray %s -o %t
// RUN: XRAY_OPTIONS=patch_premain=false:verbosity=1 %run %t 2>&1 | FileCheck %s
// RUN: env XRAY_OPTIONS=patch_premain=false:verbosity=1 %run %t 2>&1 | FileCheck %s

// REQUIRES: target={{(aarch64|x86_64)-.*linux.*}}

Expand Down
20 changes: 10 additions & 10 deletions flang/include/flang/Optimizer/Builder/FIRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,20 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
/// Create a temporary using `fir.alloca`. This function does not hoist.
/// It is the callers responsibility to set the insertion point if
/// hoisting is required.
mlir::Value
createTemporaryAlloc(mlir::Location loc, mlir::Type type,
llvm::StringRef name, mlir::ValueRange lenParams = {},
mlir::ValueRange shape = {},
llvm::ArrayRef<mlir::NamedAttribute> attrs = {});
mlir::Value createTemporaryAlloc(
mlir::Location loc, mlir::Type type, llvm::StringRef name,
mlir::ValueRange lenParams = {}, mlir::ValueRange shape = {},
llvm::ArrayRef<mlir::NamedAttribute> attrs = {},
std::optional<Fortran::common::CUDADataAttr> cudaAttr = std::nullopt);

/// Create a temporary. A temp is allocated using `fir.alloca` and can be read
/// and written using `fir.load` and `fir.store`, resp. The temporary can be
/// given a name via a front-end `Symbol` or a `StringRef`.
mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
llvm::StringRef name = {},
mlir::ValueRange shape = {},
mlir::ValueRange lenParams = {},
llvm::ArrayRef<mlir::NamedAttribute> attrs = {});
mlir::Value createTemporary(
mlir::Location loc, mlir::Type type, llvm::StringRef name = {},
mlir::ValueRange shape = {}, mlir::ValueRange lenParams = {},
llvm::ArrayRef<mlir::NamedAttribute> attrs = {},
std::optional<Fortran::common::CUDADataAttr> cudaAttr = std::nullopt);

/// Create an unnamed and untracked temporary on the stack.
mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
Expand Down
5 changes: 4 additions & 1 deletion flang/lib/Lower/ConvertVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,10 @@ static void genDeclareSymbol(Fortran::lower::AbstractConverter &converter,
if (sym.test(Fortran::semantics::Symbol::Flag::CrayPointee)) {
mlir::Type ptrBoxType =
Fortran::lower::getCrayPointeeBoxType(base.getType());
mlir::Value boxAlloc = builder.createTemporary(loc, ptrBoxType);
mlir::Value boxAlloc = builder.createTemporary(
loc, ptrBoxType,
/*name=*/{}, /*shape=*/{}, /*lenParams=*/{}, /*attrs=*/{},
Fortran::semantics::GetCUDADataAttr(&sym.GetUltimate()));

// Declare a local pointer variable.
auto newBase = builder.create<hlfir::DeclareOp>(
Expand Down
4 changes: 4 additions & 0 deletions flang/lib/Optimizer/Builder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ add_flang_library(FIRBuilder
TemporaryStorage.cpp

DEPENDS
CUFAttrs
CUFDialect
FIRDialect
HLFIRDialect
${dialect_libs}
${extension_libs}

LINK_LIBS
CUFAttrs
CUFDialect
FIRDialect
FIRDialectSupport
FIRSupport
Expand Down
30 changes: 18 additions & 12 deletions flang/lib/Optimizer/Builder/FIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "flang/Optimizer/Builder/Runtime/Assign.h"
#include "flang/Optimizer/Builder/Runtime/Derived.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/Dialect/CUF/CUFOps.h"
#include "flang/Optimizer/Dialect/FIRAttr.h"
#include "flang/Optimizer/Dialect/FIROpsSupport.h"
#include "flang/Optimizer/Dialect/FIRType.h"
Expand Down Expand Up @@ -270,25 +271,30 @@ mlir::Block *fir::FirOpBuilder::getAllocaBlock() {
mlir::Value fir::FirOpBuilder::createTemporaryAlloc(
mlir::Location loc, mlir::Type type, llvm::StringRef name,
mlir::ValueRange lenParams, mlir::ValueRange shape,
llvm::ArrayRef<mlir::NamedAttribute> attrs) {
llvm::ArrayRef<mlir::NamedAttribute> attrs,
std::optional<Fortran::common::CUDADataAttr> cudaAttr) {
assert(!mlir::isa<fir::ReferenceType>(type) && "cannot be a reference");
// If the alloca is inside an OpenMP Op which will be outlined then pin
// the alloca here.
const bool pinned =
getRegion().getParentOfType<mlir::omp::OutlineableOpenMPOpInterface>();
mlir::Value temp =
create<fir::AllocaOp>(loc, type, /*unique_name=*/llvm::StringRef{}, name,
pinned, lenParams, shape, attrs);
return temp;
if (cudaAttr) {
cuf::DataAttributeAttr attr = cuf::getDataAttribute(getContext(), cudaAttr);
return create<cuf::AllocOp>(loc, type, /*unique_name=*/llvm::StringRef{},
name, attr, lenParams, shape, attrs);
} else {
return create<fir::AllocaOp>(loc, type, /*unique_name=*/llvm::StringRef{},
name, pinned, lenParams, shape, attrs);
}
}

/// Create a temporary variable on the stack. Anonymous temporaries have no
/// `name` value. Temporaries do not require a uniqued name.
mlir::Value
fir::FirOpBuilder::createTemporary(mlir::Location loc, mlir::Type type,
llvm::StringRef name, mlir::ValueRange shape,
mlir::ValueRange lenParams,
llvm::ArrayRef<mlir::NamedAttribute> attrs) {
mlir::Value fir::FirOpBuilder::createTemporary(
mlir::Location loc, mlir::Type type, llvm::StringRef name,
mlir::ValueRange shape, mlir::ValueRange lenParams,
llvm::ArrayRef<mlir::NamedAttribute> attrs,
std::optional<Fortran::common::CUDADataAttr> cudaAttr) {
llvm::SmallVector<mlir::Value> dynamicShape =
fir::factory::elideExtentsAlreadyInType(type, shape);
llvm::SmallVector<mlir::Value> dynamicLength =
Expand All @@ -300,8 +306,8 @@ fir::FirOpBuilder::createTemporary(mlir::Location loc, mlir::Type type,
setInsertionPointToStart(getAllocaBlock());
}

mlir::Value ae =
createTemporaryAlloc(loc, type, name, dynamicLength, dynamicShape, attrs);
mlir::Value ae = createTemporaryAlloc(loc, type, name, dynamicLength,
dynamicShape, attrs, cudaAttr);

if (hoistAlloc)
restoreInsertionPoint(insPt);
Expand Down
5 changes: 5 additions & 0 deletions flang/test/Lower/CUDA/cuda-data-attribute.cuf
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,9 @@ end subroutine

end module

subroutine craypointer()
real, device :: x(*); pointer(px, x)
end

! CHECK-LABEL: func.func @_QPcraypointer()
! CHECK: %{{.*}} = cuf.alloc !fir.box<!fir.ptr<!fir.array<?xf32>>> {data_attr = #cuf.cuda<device>} -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
2 changes: 2 additions & 0 deletions libc/config/linux/aarch64/headers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ set(TARGET_PUBLIC_HEADERS
libc.include.assert
libc.include.ctype
libc.include.dlfcn
libc.include.elf
libc.include.errno
libc.include.features
libc.include.fenv
libc.include.float
libc.include.stdint
libc.include.inttypes
libc.include.limits
libc.include.link
libc.include.math
libc.include.pthread
libc.include.signal
Expand Down
2 changes: 2 additions & 0 deletions libc/config/linux/x86_64/headers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(TARGET_PUBLIC_HEADERS
libc.include.ctype
libc.include.dirent
libc.include.dlfcn
libc.include.elf
libc.include.errno
libc.include.fcntl
libc.include.features
Expand All @@ -11,6 +12,7 @@ set(TARGET_PUBLIC_HEADERS
libc.include.stdint
libc.include.inttypes
libc.include.limits
libc.include.link
libc.include.math
libc.include.pthread
libc.include.sched
Expand Down
17 changes: 17 additions & 0 deletions libc/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,23 @@ add_header_macro(
.llvm-libc-types.posix_spawn_file_actions_t
)

add_gen_header(
link
DEF_FILE link.h.def
GEN_HDR link.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.link_macros
)

add_gen_header(
elf
DEF_FILE elf.h.def
GEN_HDR elf.h
DEPENDS
.llvm-libc-macros.elf_macros
)

# TODO: Not all platforms will have a include/sys directory. Add the sys
# directory and the targets for sys/*.h files conditional to the OS requiring
# them.
Expand Down
17 changes: 17 additions & 0 deletions libc/include/elf.h.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//===-- System V header elf.h ---------------------------------------------===//
//
// 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 LLVM_LIBC_ELF_H
#define LLVM_LIBC_ELF_H

#include "__llvm-libc-common.h"
#include "llvm-libc-macros/elf-macros.h"

%%public_api()

#endif // LLVM_LIBC_ELF_H
17 changes: 17 additions & 0 deletions libc/include/link.h.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//===-- GNU header link.h -------------------------------------------------===//
//
// 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 LLVM_LIBC_LINK_H
#define LLVM_LIBC_LINK_H

#include "__llvm-libc-common.h"
#include "llvm-libc-macros/link-macros.h"

%%public_api()

#endif // LLVM_LIBC_LINK_H
6 changes: 6 additions & 0 deletions libc/include/llvm-libc-macros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,9 @@ add_macro_header(
HDR
dlfcn-macros.h
)

add_macro_header(
elf_macros
HDR
elf-macros.h
)
18 changes: 18 additions & 0 deletions libc/include/llvm-libc-macros/elf-macros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Definition of macros from elf.h -----------------------------------===//
//
// 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 LLVM_LIBC_MACROS_ELF_MACROS_H
#define LLVM_LIBC_MACROS_ELF_MACROS_H

#if __has_include(<linux/elf.h>)
#include <linux/elf.h>
#else
#error "cannot use <sys/elf.h> without proper system headers."
#endif

#endif // LLVM_LIBC_MACROS_ELF_MACROS_H
11 changes: 9 additions & 2 deletions libc/include/llvm-libc-macros/link-macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_MACROS_LINK_MACROS_H
#define LLVM_LIBC_MACROS_LINK_MACROS_H

#include "elf-macros.h"

#ifdef __LP64__
#define ElfW(type) Elf64_ ## type
#define ElfW(type) Elf64_##type
#else
#define ElfW(type) Elf32_ ## type
#define ElfW(type) Elf32_##type
#endif

#endif
2 changes: 1 addition & 1 deletion libc/include/llvm-libc-macros/math-macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#define HUGE_VAL __builtin_huge_val()
#define HUGE_VALF __builtin_huge_valf()
#define INFINITY __builtin_inf()
#define INFINITY __builtin_inff()
#define NAN __builtin_nanf("")

#define FP_ILOGB0 (-INT_MAX - 1)
Expand Down
2 changes: 0 additions & 2 deletions libc/include/time.h.def
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

#include "__llvm-libc-common.h"
#include "llvm-libc-macros/time-macros.h"
#include "llvm-libc-types/clock_t.h"
#include "llvm-libc-types/clockid_t.h"

%%public_api()

Expand Down
1 change: 0 additions & 1 deletion libc/include/uchar.h.def
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#define LLVM_LIBC_UCHAR_H

#include "__llvm-libc-common.h"
#include "llvm-libc-types/mbstate_t.h"

%%public_api()

Expand Down
8 changes: 8 additions & 0 deletions libc/newhdrgen/yaml/elf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
header: elf.h
standards:
- Linux
macros: []
types: []
enums: []
objects: []
functions: []
8 changes: 8 additions & 0 deletions libc/newhdrgen/yaml/link.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
header: link.h
standards:
- Linux
macros: []
types: []
enums: []
objects: []
functions: []
1 change: 1 addition & 0 deletions libc/newhdrgen/yaml/time.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ types:
- type_name: struct_tm
- type_name: time_t
- type_name: clock_t
- type_name: size_t
enums: []
objects: []
functions:
Expand Down
1 change: 1 addition & 0 deletions libc/newhdrgen/yaml/uchar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ types:
- type_name: char16_t
- type_name: char8_t
- type_name: mbstate_t
- type_name: size_t
enums: []
objects: []
functions: []
2 changes: 2 additions & 0 deletions libc/spec/stdc.td
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,7 @@ def StdC : StandardSpec<"stdc"> {
StructTmType,
StructTimeSpec,
TimeTType,
SizeTType,
],
[], // Enumerations
[
Expand Down Expand Up @@ -1562,6 +1563,7 @@ def StdC : StandardSpec<"stdc"> {
Char8TType,
Char16TType,
Char32TType,
SizeTType,
],
[], // Enumerations
[]
Expand Down
1 change: 1 addition & 0 deletions libc/src/math/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,7 @@ add_entrypoint_object(
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.polyeval
libc.src.__support.FPUtil.rounding_mode
libc.src.__support.macros.attributes
libc.src.__support.macros.optimization
COMPILE_OPTIONS
-O3
Expand Down
3 changes: 2 additions & 1 deletion libc/src/math/generic/expxf16.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "src/__support/FPUtil/PolyEval.h"
#include "src/__support/FPUtil/multiply_add.h"
#include "src/__support/FPUtil/nearest_integer.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include <stdint.h>

Expand Down Expand Up @@ -45,7 +46,7 @@ struct ExpRangeReduction {
float exp_lo;
};

ExpRangeReduction exp_range_reduction(float16 x) {
LIBC_INLINE ExpRangeReduction exp_range_reduction(float16 x) {
// For -18 < x < 12, to compute exp(x), we perform the following range
// reduction: find hi, mid, lo, such that:
// x = hi + mid + lo, in which
Expand Down
304 changes: 152 additions & 152 deletions libcxx/docs/Status/Cxx14Issues.csv

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions libcxx/docs/Status/Cxx14Papers.csv
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
"Paper #","Group","Paper Name","Meeting","Status","First released version"
"`N3346 <https://wg21.link/N3346>`__","LWG","Terminology for Container Element Requirements - Rev 1","Kona","|Complete|","3.4"
"`N3346 <https://wg21.link/N3346>`__","LWG","Terminology for Container Element Requirements - Rev 1","2012-02 (Kona)","|Complete|","3.4"
"","","","","",""
"`N3421 <https://wg21.link/N3421>`__","LWG","Making Operator Functors greater<>","Portland","|Complete|","3.4"
"`N3462 <https://wg21.link/N3462>`__","LWG","std::result_of and SFINAE","Portland","|Complete|","3.4"
"`N3469 <https://wg21.link/N3469>`__","LWG","Constexpr Library Additions: chrono, v3","Portland","|Complete|","3.4"
"`N3470 <https://wg21.link/N3470>`__","LWG","Constexpr Library Additions: containers, v2","Portland","|Complete|","3.4"
"`N3471 <https://wg21.link/N3471>`__","LWG","Constexpr Library Additions: utilities, v3","Portland","|Complete|","3.4"
"`N3302 <https://wg21.link/N3302>`__","LWG","Constexpr Library Additions: complex, v2","Portland","|Complete|","3.4"
"`N3421 <https://wg21.link/N3421>`__","LWG","Making Operator Functors greater<>","2012-10 (Portland)","|Complete|","3.4"
"`N3462 <https://wg21.link/N3462>`__","LWG","std::result_of and SFINAE","2012-10 (Portland)","|Complete|","3.4"
"`N3469 <https://wg21.link/N3469>`__","LWG","Constexpr Library Additions: chrono, v3","2012-10 (Portland)","|Complete|","3.4"
"`N3470 <https://wg21.link/N3470>`__","LWG","Constexpr Library Additions: containers, v2","2012-10 (Portland)","|Complete|","3.4"
"`N3471 <https://wg21.link/N3471>`__","LWG","Constexpr Library Additions: utilities, v3","2012-10 (Portland)","|Complete|","3.4"
"`N3302 <https://wg21.link/N3302>`__","LWG","Constexpr Library Additions: complex, v2","2012-10 (Portland)","|Complete|","3.4"
"","","","","",""
"`N3545 <https://wg21.link/N3545>`__","LWG","An Incremental Improvement to integral_constant","Bristol","|Complete|","3.4"
"`N3644 <https://wg21.link/N3644>`__","LWG","Null Forward Iterators","Bristol","|Complete|","3.4"
"`N3668 <https://wg21.link/N3668>`__","LWG","std::exchange()","Bristol","|Complete|","3.4"
"`N3658 <https://wg21.link/N3658>`__","LWG","Compile-time integer sequences","Bristol","|Complete|","3.4"
"`N3670 <https://wg21.link/N3670>`__","LWG","Addressing Tuples by Type","Bristol","|Complete|","3.4"
"`N3671 <https://wg21.link/N3671>`__","LWG","Making non-modifying sequence operations more robust","Bristol","|Complete|","3.4"
"`N3656 <https://wg21.link/N3656>`__","LWG","make_unique","Bristol","|Complete|","3.4"
"`N3654 <https://wg21.link/N3654>`__","LWG","Quoted Strings","Bristol","|Complete|","3.4"
"`N3642 <https://wg21.link/N3642>`__","LWG","User-defined Literals","Bristol","|Complete|","3.4"
"`N3655 <https://wg21.link/N3655>`__","LWG","TransformationTraits Redux (excluding part 4)","Bristol","|Complete|","3.4"
"`N3657 <https://wg21.link/N3657>`__","LWG","Adding heterogeneous comparison lookup to associative containers","Bristol","|Complete|","3.4"
"`N3672 <https://wg21.link/N3672>`__","LWG","A proposal to add a utility class to represent optional objects","Bristol","*Removed from Draft Standard*","n/a"
"`N3669 <https://wg21.link/N3669>`__","LWG","Fixing constexpr member functions without const","Bristol","|Complete|","3.4"
"`N3662 <https://wg21.link/N3662>`__","LWG","C++ Dynamic Arrays (dynarray)","Bristol","*Removed from Draft Standard*","n/a"
"`N3659 <https://wg21.link/N3659>`__","SG1","Shared Locking in C++","Bristol","|Complete|","3.4"
"`N3545 <https://wg21.link/N3545>`__","LWG","An Incremental Improvement to integral_constant","2013-04 (Bristol)","|Complete|","3.4"
"`N3644 <https://wg21.link/N3644>`__","LWG","Null Forward Iterators","2013-04 (Bristol)","|Complete|","3.4"
"`N3668 <https://wg21.link/N3668>`__","LWG","std::exchange()","2013-04 (Bristol)","|Complete|","3.4"
"`N3658 <https://wg21.link/N3658>`__","LWG","Compile-time integer sequences","2013-04 (Bristol)","|Complete|","3.4"
"`N3670 <https://wg21.link/N3670>`__","LWG","Addressing Tuples by Type","2013-04 (Bristol)","|Complete|","3.4"
"`N3671 <https://wg21.link/N3671>`__","LWG","Making non-modifying sequence operations more robust","2013-04 (Bristol)","|Complete|","3.4"
"`N3656 <https://wg21.link/N3656>`__","LWG","make_unique","2013-04 (Bristol)","|Complete|","3.4"
"`N3654 <https://wg21.link/N3654>`__","LWG","Quoted Strings","2013-04 (Bristol)","|Complete|","3.4"
"`N3642 <https://wg21.link/N3642>`__","LWG","User-defined Literals","2013-04 (Bristol)","|Complete|","3.4"
"`N3655 <https://wg21.link/N3655>`__","LWG","TransformationTraits Redux (excluding part 4)","2013-04 (Bristol)","|Complete|","3.4"
"`N3657 <https://wg21.link/N3657>`__","LWG","Adding heterogeneous comparison lookup to associative containers","2013-04 (Bristol)","|Complete|","3.4"
"`N3672 <https://wg21.link/N3672>`__","LWG","A proposal to add a utility class to represent optional objects","2013-04 (Bristol)","*Removed from Draft Standard*","n/a"
"`N3669 <https://wg21.link/N3669>`__","LWG","Fixing constexpr member functions without const","2013-04 (Bristol)","|Complete|","3.4"
"`N3662 <https://wg21.link/N3662>`__","LWG","C++ Dynamic Arrays (dynarray)","2013-04 (Bristol)","*Removed from Draft Standard*","n/a"
"`N3659 <https://wg21.link/N3659>`__","SG1","Shared Locking in C++","2013-04 (Bristol)","|Complete|","3.4"
"","","","","",""
"`N3779 <https://wg21.link/N3779>`__","LWG","User-defined Literals for std::complex","Chicago","|Complete|","3.4"
"`N3789 <https://wg21.link/N3789>`__","LWG","Constexpr Library Additions: functional","Chicago","|Complete|","3.4"
"`N3779 <https://wg21.link/N3779>`__","LWG","User-defined Literals for std::complex","2013-09 (Chicago)","|Complete|","3.4"
"`N3789 <https://wg21.link/N3789>`__","LWG","Constexpr Library Additions: functional","2013-09 (Chicago)","|Complete|","3.4"
"","","","","",""
"`N3924 <https://wg21.link/N3924>`__","LWG","Discouraging rand() in C++14","Issaquah","|Complete|","3.5"
"`N3887 <https://wg21.link/N3887>`__","LWG","Consistent Metafunction Aliases","Issaquah","|Complete|","3.5"
"`N3891 <https://wg21.link/N3891>`__","SG1","A proposal to rename shared_mutex to shared_timed_mutex","Issaquah","|Complete|","3.5"
"`N3924 <https://wg21.link/N3924>`__","LWG","Discouraging rand() in C++14","2014-02 (Issaquah)","|Complete|","3.5"
"`N3887 <https://wg21.link/N3887>`__","LWG","Consistent Metafunction Aliases","2014-02 (Issaquah)","|Complete|","3.5"
"`N3891 <https://wg21.link/N3891>`__","SG1","A proposal to rename shared_mutex to shared_timed_mutex","2014-02 (Issaquah)","|Complete|","3.5"
619 changes: 309 additions & 310 deletions libcxx/docs/Status/Cxx17Issues.csv

Large diffs are not rendered by default.

210 changes: 105 additions & 105 deletions libcxx/docs/Status/Cxx17Papers.csv

Large diffs are not rendered by default.

585 changes: 293 additions & 292 deletions libcxx/docs/Status/Cxx20Issues.csv

Large diffs are not rendered by default.

391 changes: 196 additions & 195 deletions libcxx/docs/Status/Cxx20Papers.csv

Large diffs are not rendered by default.

600 changes: 300 additions & 300 deletions libcxx/docs/Status/Cxx23Issues.csv

Large diffs are not rendered by default.

230 changes: 115 additions & 115 deletions libcxx/docs/Status/Cxx23Papers.csv

Large diffs are not rendered by default.

146 changes: 73 additions & 73 deletions libcxx/docs/Status/Cxx2cIssues.csv

Large diffs are not rendered by default.

146 changes: 73 additions & 73 deletions libcxx/docs/Status/Cxx2cPapers.csv

Large diffs are not rendered by default.

14 changes: 1 addition & 13 deletions libcxx/include/__memory/unique_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include <__type_traits/is_trivially_relocatable.h>
#include <__type_traits/is_void.h>
#include <__type_traits/remove_extent.h>
#include <__type_traits/remove_pointer.h>
#include <__type_traits/type_identity.h>
#include <__utility/declval.h>
#include <__utility/forward.h>
Expand All @@ -52,17 +51,6 @@ _LIBCPP_PUSH_MACROS

_LIBCPP_BEGIN_NAMESPACE_STD

#ifndef _LIBCPP_CXX03_LANG

template <class _Ptr>
struct __is_noexcept_deref_or_void {
static constexpr bool value = noexcept(*std::declval<_Ptr>());
};

template <>
struct __is_noexcept_deref_or_void<void*> : true_type {};
#endif

template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS default_delete {
static_assert(!is_function<_Tp>::value, "default_delete cannot be instantiated for function types");
Expand Down Expand Up @@ -266,7 +254,7 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {
}

_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const
_NOEXCEPT_(__is_noexcept_deref_or_void<pointer>::value) {
_NOEXCEPT_(_NOEXCEPT_(*std::declval<pointer>())) {
return *__ptr_.first();
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_.first(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,3 @@ static_assert(std::indirectly_movable_storable<std::unique_ptr<int>, std::unique
static_assert(std::indirectly_copyable<std::unique_ptr<int>, std::unique_ptr<int>>);
static_assert(std::indirectly_copyable_storable<std::unique_ptr<int>, std::unique_ptr<int>>);
static_assert(std::indirectly_swappable<std::unique_ptr<int>, std::unique_ptr<int> >);

static_assert(!std::indirectly_readable<std::unique_ptr<void> >);
static_assert(!std::indirectly_writable<std::unique_ptr<void>, void>);
static_assert(!std::weakly_incrementable<std::unique_ptr<void> >);
static_assert(!std::indirectly_movable<std::unique_ptr<void>, std::unique_ptr<void>>);
static_assert(!std::indirectly_movable_storable<std::unique_ptr<void>, std::unique_ptr<void>>);
static_assert(!std::indirectly_copyable<std::unique_ptr<void>, std::unique_ptr<void>>);
static_assert(!std::indirectly_copyable_storable<std::unique_ptr<void>, std::unique_ptr<void>>);

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ struct Deleter {
#endif

TEST_CONSTEXPR_CXX23 bool test() {
ASSERT_NOEXCEPT(*(std::unique_ptr<void>{}));
#if TEST_STD_VER >= 11
static_assert(noexcept(*std::declval<std::unique_ptr<void>>()), "");
#endif
{
std::unique_ptr<int> p(new int(3));
assert(*p == 3);
Expand Down
8 changes: 4 additions & 4 deletions lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1077,10 +1077,10 @@ ArchSpec ProcessElfCore::GetArchitecture() {
}

DataExtractor ProcessElfCore::GetAuxvData() {
const uint8_t *start = m_auxv.GetDataStart();
size_t len = m_auxv.GetByteSize();
lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(start, len));
return DataExtractor(buffer, GetByteOrder(), GetAddressByteSize());
assert(m_auxv.GetByteSize() == 0 ||
(m_auxv.GetByteOrder() == GetByteOrder() &&
m_auxv.GetAddressByteSize() == GetAddressByteSize()));
return DataExtractor(m_auxv);
}

bool ProcessElfCore::GetProcessInfo(ProcessInstanceInfo &info) {
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class DWARFASTParser {
const AddressRange &range) = 0;

virtual bool CompleteTypeFromDWARF(const DWARFDIE &die, Type *type,
CompilerType &compiler_type) = 0;
const CompilerType &compiler_type) = 0;

virtual CompilerDecl GetDeclForUIDFromDWARF(const DWARFDIE &die) = 0;

Expand Down
17 changes: 9 additions & 8 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,7 @@ bool DWARFASTParserClang::ParseTemplateParameterInfos(

bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
lldb_private::Type *type,
CompilerType &clang_type) {
const CompilerType &clang_type) {
const dw_tag_t tag = die.Tag();
SymbolFileDWARF *dwarf = die.GetDWARF();

Expand Down Expand Up @@ -2152,7 +2152,7 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,

bool DWARFASTParserClang::CompleteEnumType(const DWARFDIE &die,
lldb_private::Type *type,
CompilerType &clang_type) {
const CompilerType &clang_type) {
if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
if (die.HasChildren()) {
bool is_signed = false;
Expand All @@ -2165,9 +2165,9 @@ bool DWARFASTParserClang::CompleteEnumType(const DWARFDIE &die,
return (bool)clang_type;
}

bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die,
lldb_private::Type *type,
CompilerType &clang_type) {
bool DWARFASTParserClang::CompleteTypeFromDWARF(
const DWARFDIE &die, lldb_private::Type *type,
const CompilerType &clang_type) {
SymbolFileDWARF *dwarf = die.GetDWARF();

std::lock_guard<std::recursive_mutex> guard(
Expand Down Expand Up @@ -2244,7 +2244,7 @@ DWARFASTParserClang::GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) {
}

size_t DWARFASTParserClang::ParseChildEnumerators(
lldb_private::CompilerType &clang_type, bool is_signed,
const lldb_private::CompilerType &clang_type, bool is_signed,
uint32_t enumerator_byte_size, const DWARFDIE &parent_die) {
if (!parent_die)
return 0;
Expand Down Expand Up @@ -3032,7 +3032,7 @@ void DWARFASTParserClang::ParseSingleMember(
}

bool DWARFASTParserClang::ParseChildMembers(
const DWARFDIE &parent_die, CompilerType &class_clang_type,
const DWARFDIE &parent_die, const CompilerType &class_clang_type,
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
std::vector<DWARFDIE> &member_function_dies,
std::vector<DWARFDIE> &contained_type_dies,
Expand Down Expand Up @@ -3763,7 +3763,8 @@ bool DWARFASTParserClang::ShouldCreateUnnamedBitfield(
}

void DWARFASTParserClang::ParseRustVariantPart(
DWARFDIE &die, const DWARFDIE &parent_die, CompilerType &class_clang_type,
DWARFDIE &die, const DWARFDIE &parent_die,
const CompilerType &class_clang_type,
const lldb::AccessType default_accesibility,
ClangASTImporter::LayoutInfo &layout_info) {
assert(die.Tag() == llvm::dwarf::DW_TAG_variant_part);
Expand Down
18 changes: 9 additions & 9 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
const lldb_private::plugin::dwarf::DWARFDIE &die,
const lldb_private::AddressRange &func_range) override;

bool
CompleteTypeFromDWARF(const lldb_private::plugin::dwarf::DWARFDIE &die,
lldb_private::Type *type,
lldb_private::CompilerType &compiler_type) override;
bool CompleteTypeFromDWARF(
const lldb_private::plugin::dwarf::DWARFDIE &die,
lldb_private::Type *type,
const lldb_private::CompilerType &compiler_type) override;

lldb_private::CompilerDecl GetDeclForUIDFromDWARF(
const lldb_private::plugin::dwarf::DWARFDIE &die) override;
Expand Down Expand Up @@ -178,7 +178,7 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {

bool ParseChildMembers(
const lldb_private::plugin::dwarf::DWARFDIE &die,
lldb_private::CompilerType &class_compiler_type,
const lldb_private::CompilerType &class_compiler_type,
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
std::vector<lldb_private::plugin::dwarf::DWARFDIE> &member_function_dies,
std::vector<lldb_private::plugin::dwarf::DWARFDIE> &contained_type_dies,
Expand All @@ -196,7 +196,7 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
unsigned &type_quals);

size_t ParseChildEnumerators(
lldb_private::CompilerType &compiler_type, bool is_signed,
const lldb_private::CompilerType &compiler_type, bool is_signed,
uint32_t enumerator_byte_size,
const lldb_private::plugin::dwarf::DWARFDIE &parent_die);

Expand Down Expand Up @@ -362,10 +362,10 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {

bool CompleteRecordType(const lldb_private::plugin::dwarf::DWARFDIE &die,
lldb_private::Type *type,
lldb_private::CompilerType &clang_type);
const lldb_private::CompilerType &clang_type);
bool CompleteEnumType(const lldb_private::plugin::dwarf::DWARFDIE &die,
lldb_private::Type *type,
lldb_private::CompilerType &clang_type);
const lldb_private::CompilerType &clang_type);

lldb::TypeSP
ParseTypeModifier(const lldb_private::SymbolContext &sc,
Expand Down Expand Up @@ -467,7 +467,7 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
void
ParseRustVariantPart(lldb_private::plugin::dwarf::DWARFDIE &die,
const lldb_private::plugin::dwarf::DWARFDIE &parent_die,
lldb_private::CompilerType &class_clang_type,
const lldb_private::CompilerType &class_clang_type,
const lldb::AccessType default_accesibility,
lldb_private::ClangASTImporter::LayoutInfo &layout_info);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class TestSharedPtr(TestBase):
@add_test_categories(["libc++"])
@skipIf(compiler=no_match("clang"))
@skipIf(compiler="clang", compiler_version=['<', '17.0'])
def test(self):
self.build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class TestDbgInfoContentWeakPtr(TestBase):
@add_test_categories(["libc++"])
@skipIf(compiler=no_match("clang"))
@skipIf(compiler="clang", compiler_version=['<', '17.0'])
def test(self):
self.build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class TestSharedPtr(TestBase):
@add_test_categories(["libc++"])
@skipIf(compiler=no_match("clang"))
@skipIf(compiler="clang", compiler_version=['<', '17.0'])
def test(self):
self.build()

Expand Down
2 changes: 1 addition & 1 deletion llvm/cmake/modules/AddLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ macro(add_llvm_executable name)

if (DEFINED LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND
NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND
NOT ARG_EXPORT_SYMBOLS AND NOT ARG_EXPORT_SYMBOLS_FOR_PLUGINS)
NOT ARG_EXPORT_SYMBOLS)
if(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
set_property(TARGET ${name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-no_exported_symbols")
Expand Down
8 changes: 4 additions & 4 deletions llvm/include/llvm/Analysis/TargetLibraryInfo.def
Original file line number Diff line number Diff line change
Expand Up @@ -365,22 +365,22 @@ TLI_DEFINE_SIG_INTERNAL(Ptr, Long, Long, Ptr, Bool)
/// __sized_ptr_t __size_returning_new(size_t size)
TLI_DEFINE_ENUM_INTERNAL(size_returning_new)
TLI_DEFINE_STRING_INTERNAL("__size_returning_new")
TLI_DEFINE_SIG_INTERNAL(Struct, Long)
TLI_DEFINE_SIG_INTERNAL(/* Checked manually. */)

/// __sized_ptr_t __size_returning_new_hot_cold(size_t, __hot_cold_t)
TLI_DEFINE_ENUM_INTERNAL(size_returning_new_hot_cold)
TLI_DEFINE_STRING_INTERNAL("__size_returning_new_hot_cold")
TLI_DEFINE_SIG_INTERNAL(Struct, Long, Bool)
TLI_DEFINE_SIG_INTERNAL(/* Checked manually. */)

/// __sized_ptr_t __size_returning_new_aligned(size_t, std::align_val_t)
TLI_DEFINE_ENUM_INTERNAL(size_returning_new_aligned)
TLI_DEFINE_STRING_INTERNAL("__size_returning_new_aligned")
TLI_DEFINE_SIG_INTERNAL(Struct, Long, Long)
TLI_DEFINE_SIG_INTERNAL(/* Checked manually. */)

/// __sized_ptr_t __size_returning_new_aligned(size_t, std::align_val_t, __hot_cold_t)
TLI_DEFINE_ENUM_INTERNAL(size_returning_new_aligned_hot_cold)
TLI_DEFINE_STRING_INTERNAL("__size_returning_new_aligned_hot_cold")
TLI_DEFINE_SIG_INTERNAL(Struct, Long, Long, Bool)
TLI_DEFINE_SIG_INTERNAL(/* Checked manually. */)

/// double __acos_finite(double x);
TLI_DEFINE_ENUM_INTERNAL(acos_finite)
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/CodeGen/GlobalMerge.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ struct GlobalMergeOptions {
bool MergeConst = false;
/// Whether we should merge global variables that have external linkage.
bool MergeExternal = true;
/// Whether we should merge constant global variables.
bool MergeConstantGlobals = false;
/// Whether we should try to optimize for size only.
/// Currently, this applies a dead simple heuristic: only consider globals
/// used in minsize functions for merging.
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/CodeGen/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,8 @@ namespace llvm {
///
Pass *createGlobalMergePass(const TargetMachine *TM, unsigned MaximalOffset,
bool OnlyOptimizeForSize = false,
bool MergeExternalByDefault = false);
bool MergeExternalByDefault = false,
bool MergeConstantByDefault = false);

/// This pass splits the stack into a safe stack and an unsafe stack to
/// protect against stack-based overflow vulnerabilities.
Expand Down
24 changes: 2 additions & 22 deletions llvm/include/llvm/CodeGen/SelectionDAG.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#ifndef LLVM_CODEGEN_SELECTIONDAG_H
#define LLVM_CODEGEN_SELECTIONDAG_H

#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
Expand Down Expand Up @@ -675,10 +673,7 @@ class SelectionDAG {
bool isTarget = false, bool isOpaque = false);

SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget = false,
bool IsOpaque = false) {
return getConstant(APInt::getAllOnes(VT.getScalarSizeInBits()), DL, VT,
IsTarget, IsOpaque);
}
bool IsOpaque = false);

SDValue getConstant(const ConstantInt &Val, const SDLoc &DL, EVT VT,
bool isTarget = false, bool isOpaque = false);
Expand Down Expand Up @@ -1824,21 +1819,6 @@ class SelectionDAG {
AllNodes.insert(Position, AllNodes.remove(N));
}

/// Returns an APFloat semantics tag appropriate for the given type. If VT is
/// a vector type, the element semantics are returned.
static const fltSemantics &EVTToAPFloatSemantics(EVT VT) {
switch (VT.getScalarType().getSimpleVT().SimpleTy) {
default: llvm_unreachable("Unknown FP format");
case MVT::f16: return APFloat::IEEEhalf();
case MVT::bf16: return APFloat::BFloat();
case MVT::f32: return APFloat::IEEEsingle();
case MVT::f64: return APFloat::IEEEdouble();
case MVT::f80: return APFloat::x87DoubleExtended();
case MVT::f128: return APFloat::IEEEquad();
case MVT::ppcf128: return APFloat::PPCDoubleDouble();
}
}

/// Add a dbg_value SDNode. If SD is non-null that means the
/// value is produced by SD.
void AddDbgValue(SDDbgValue *DB, bool isParameter);
Expand Down Expand Up @@ -2379,7 +2359,7 @@ class SelectionDAG {
/// Return the current function's default denormal handling kind for the given
/// floating point type.
DenormalMode getDenormalMode(EVT VT) const {
return MF->getDenormalMode(EVTToAPFloatSemantics(VT));
return MF->getDenormalMode(VT.getFltSemantics());
}

bool shouldOptForSize() const;
Expand Down
5 changes: 5 additions & 0 deletions llvm/include/llvm/CodeGen/ValueTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace llvm {

class LLVMContext;
class Type;
struct fltSemantics;

/// Extended Value Type. Capable of holding value types which are not native
/// for any processor (such as the i12345 type), as well as the types an MVT
Expand Down Expand Up @@ -512,6 +513,10 @@ namespace llvm {
}
};

/// Returns an APFloat semantics tag appropriate for the value type. If this
/// is a vector type, the element semantics are returned.
const fltSemantics &getFltSemantics() const;

private:
// Methods for handling the Extended-type case in functions above.
// These are all out-of-line to prevent users of this header file
Expand Down
5 changes: 5 additions & 0 deletions llvm/include/llvm/CodeGenTypes/MachineValueType.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace llvm {

class Type;
struct fltSemantics;
class raw_ostream;

/// Machine Value Type. Every type that is supported natively by some
Expand Down Expand Up @@ -476,6 +477,10 @@ namespace llvm {
/// to a concrete value type.
static MVT getVT(Type *Ty, bool HandleUnknown = false);

/// Returns an APFloat semantics tag appropriate for the value type. If this
/// is a vector type, the element semantics are returned.
const fltSemantics &getFltSemantics() const;

public:
/// SimpleValueType Iteration
/// @{
Expand Down
13 changes: 3 additions & 10 deletions llvm/include/llvm/IR/DataLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,10 @@ class DataLayout {
/// if the string is malformed.
Error parseSpecifier(StringRef Desc);

// Free all internal data structures.
void clear();

public:
/// Constructs a DataLayout from a specification string. See reset().
explicit DataLayout(StringRef LayoutDescription) {
reset(LayoutDescription);
}
/// Constructs a DataLayout from a specification string.
/// WARNING: Aborts execution if the string is malformed. Use parse() instead.
explicit DataLayout(StringRef LayoutString);

DataLayout(const DataLayout &DL) { *this = DL; }

Expand All @@ -203,9 +199,6 @@ class DataLayout {
bool operator==(const DataLayout &Other) const;
bool operator!=(const DataLayout &Other) const { return !(*this == Other); }

/// Parse a data layout string (with fallback to default values).
void reset(StringRef LayoutDescription);

/// Parse a data layout string and return the layout. Return an error
/// description on failure.
static Expected<DataLayout> parse(StringRef LayoutDescription);
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/IR/IntrinsicsDirectX.td
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def int_dx_lerp : Intrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty, LLVMMatchType
def int_dx_length : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], [llvm_anyfloat_ty]>;
def int_dx_imad : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
def int_dx_umad : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
def int_dx_normalize : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty]>;
def int_dx_rcp : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
def int_dx_rsqrt : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
}
1 change: 1 addition & 0 deletions llvm/include/llvm/IR/IntrinsicsSPIRV.td
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@ let TargetPrefix = "spv" in {
def int_spv_lerp : Intrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty, LLVMMatchType<0>,LLVMMatchType<0>],
[IntrNoMem, IntrWillReturn] >;
def int_spv_length : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], [llvm_anyfloat_ty]>;
def int_spv_normalize : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty]>;
def int_spv_rsqrt : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty]>;
}
90 changes: 90 additions & 0 deletions llvm/include/llvm/SandboxIR/SandboxIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class CastInst;
class PtrToIntInst;
class BitCastInst;
class AllocaInst;
class AtomicCmpXchgInst;

/// Iterator for the `Use` edges of a User's operands.
/// \Returns the operand `Use` when dereferenced.
Expand Down Expand Up @@ -248,6 +249,7 @@ class Value {
friend class InvokeInst; // For getting `Val`.
friend class CallBrInst; // For getting `Val`.
friend class GetElementPtrInst; // For getting `Val`.
friend class AtomicCmpXchgInst; // For getting `Val`.
friend class AllocaInst; // For getting `Val`.
friend class CastInst; // For getting `Val`.
friend class PHINode; // For getting `Val`.
Expand Down Expand Up @@ -628,6 +630,7 @@ class Instruction : public sandboxir::User {
friend class InvokeInst; // For getTopmostLLVMInstruction().
friend class CallBrInst; // For getTopmostLLVMInstruction().
friend class GetElementPtrInst; // For getTopmostLLVMInstruction().
friend class AtomicCmpXchgInst; // For getTopmostLLVMInstruction().
friend class AllocaInst; // For getTopmostLLVMInstruction().
friend class CastInst; // For getTopmostLLVMInstruction().
friend class PHINode; // For getTopmostLLVMInstruction().
Expand Down Expand Up @@ -1337,6 +1340,91 @@ class GetElementPtrInst final
// TODO: Add missing member functions.
};

class AtomicCmpXchgInst
: public SingleLLVMInstructionImpl<llvm::AtomicCmpXchgInst> {
AtomicCmpXchgInst(llvm::AtomicCmpXchgInst *Atomic, Context &Ctx)
: SingleLLVMInstructionImpl(ClassID::AtomicCmpXchg,
Instruction::Opcode::AtomicCmpXchg, Atomic,
Ctx) {}
friend class Context; // For constructor.

public:
/// Return the alignment of the memory that is being allocated by the
/// instruction.
Align getAlign() const {
return cast<llvm::AtomicCmpXchgInst>(Val)->getAlign();
}

void setAlignment(Align Align);
/// Return true if this is a cmpxchg from a volatile memory
/// location.
bool isVolatile() const {
return cast<llvm::AtomicCmpXchgInst>(Val)->isVolatile();
}
/// Specify whether this is a volatile cmpxchg.
void setVolatile(bool V);
/// Return true if this cmpxchg may spuriously fail.
bool isWeak() const { return cast<llvm::AtomicCmpXchgInst>(Val)->isWeak(); }
void setWeak(bool IsWeak);
static bool isValidSuccessOrdering(AtomicOrdering Ordering) {
return llvm::AtomicCmpXchgInst::isValidSuccessOrdering(Ordering);
}
static bool isValidFailureOrdering(AtomicOrdering Ordering) {
return llvm::AtomicCmpXchgInst::isValidFailureOrdering(Ordering);
}
AtomicOrdering getSuccessOrdering() const {
return cast<llvm::AtomicCmpXchgInst>(Val)->getSuccessOrdering();
}
void setSuccessOrdering(AtomicOrdering Ordering);

AtomicOrdering getFailureOrdering() const {
return cast<llvm::AtomicCmpXchgInst>(Val)->getFailureOrdering();
}
void setFailureOrdering(AtomicOrdering Ordering);
AtomicOrdering getMergedOrdering() const {
return cast<llvm::AtomicCmpXchgInst>(Val)->getMergedOrdering();
}
SyncScope::ID getSyncScopeID() const {
return cast<llvm::AtomicCmpXchgInst>(Val)->getSyncScopeID();
}
void setSyncScopeID(SyncScope::ID SSID);
Value *getPointerOperand();
const Value *getPointerOperand() const {
return const_cast<AtomicCmpXchgInst *>(this)->getPointerOperand();
}

Value *getCompareOperand();
const Value *getCompareOperand() const {
return const_cast<AtomicCmpXchgInst *>(this)->getCompareOperand();
}

Value *getNewValOperand();
const Value *getNewValOperand() const {
return const_cast<AtomicCmpXchgInst *>(this)->getNewValOperand();
}

/// Returns the address space of the pointer operand.
unsigned getPointerAddressSpace() const {
return cast<llvm::AtomicCmpXchgInst>(Val)->getPointerAddressSpace();
}

static AtomicCmpXchgInst *
create(Value *Ptr, Value *Cmp, Value *New, MaybeAlign Align,
AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering,
BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx,
SyncScope::ID SSID = SyncScope::System, const Twine &Name = "");
static AtomicCmpXchgInst *
create(Value *Ptr, Value *Cmp, Value *New, MaybeAlign Align,
AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering,
Instruction *InsertBefore, Context &Ctx,
SyncScope::ID SSID = SyncScope::System, const Twine &Name = "");
static AtomicCmpXchgInst *
create(Value *Ptr, Value *Cmp, Value *New, MaybeAlign Align,
AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering,
BasicBlock *InsertAtEnd, Context &Ctx,
SyncScope::ID SSID = SyncScope::System, const Twine &Name = "");
};

class AllocaInst final : public UnaryInstruction {
AllocaInst(llvm::AllocaInst *AI, Context &Ctx)
: UnaryInstruction(ClassID::Alloca, Instruction::Opcode::Alloca, AI,
Expand Down Expand Up @@ -1696,6 +1784,8 @@ class Context {
friend CallBrInst; // For createCallBrInst()
GetElementPtrInst *createGetElementPtrInst(llvm::GetElementPtrInst *I);
friend GetElementPtrInst; // For createGetElementPtrInst()
AtomicCmpXchgInst *createAtomicCmpXchgInst(llvm::AtomicCmpXchgInst *I);
friend AtomicCmpXchgInst; // For createAtomicCmpXchgInst()
AllocaInst *createAllocaInst(llvm::AllocaInst *I);
friend AllocaInst; // For createAllocaInst()
CastInst *createCastInst(llvm::CastInst *I);
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/SandboxIR/SandboxIRValues.def
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ DEF_INSTR(Call, OP(Call), CallInst)
DEF_INSTR(Invoke, OP(Invoke), InvokeInst)
DEF_INSTR(CallBr, OP(CallBr), CallBrInst)
DEF_INSTR(GetElementPtr, OP(GetElementPtr), GetElementPtrInst)
DEF_INSTR(AtomicCmpXchg, OP(AtomicCmpXchg), AtomicCmpXchgInst)
DEF_INSTR(Alloca, OP(Alloca), AllocaInst)
DEF_INSTR(Cast, OPCODES(\
OP(ZExt) \
Expand Down
21 changes: 7 additions & 14 deletions llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,6 @@ SampleProfileLoaderBaseImpl<BT>::getInstWeightImpl(const InstructionT &Inst) {
return R;
}

// Here use error_code to represent: 1) The dangling probe. 2) Ignore the weight
// of non-probe instruction. So if all instructions of the BB give error_code,
// tell the inference algorithm to infer the BB weight.
template <typename BT>
ErrorOr<uint64_t>
SampleProfileLoaderBaseImpl<BT>::getProbeWeight(const InstructionT &Inst) {
Expand All @@ -464,17 +461,13 @@ SampleProfileLoaderBaseImpl<BT>::getProbeWeight(const InstructionT &Inst) {
return std::error_code();

const FunctionSamples *FS = findFunctionSamples(Inst);
// If none of the instruction has FunctionSample, we choose to return zero
// value sample to indicate the BB is cold. This could happen when the
// instruction is from inlinee and no profile data is found.
// FIXME: This should not be affected by the source drift issue as 1) if the
// newly added function is top-level inliner, it won't match the CFG checksum
// in the function profile or 2) if it's the inlinee, the inlinee should have
// a profile, otherwise it wouldn't be inlined. For non-probe based profile,
// we can improve it by adding a switch for profile-sample-block-accurate for
// block level counts in the future.
if (!FS)
return 0;
if (!FS) {
// If we can't find the function samples for a probe, it could be due to the
// probe is later optimized away or the inlining context is mismatced. We
// treat it as unknown, leaving it to profile inference instead of forcing a
// zero count.
return std::error_code();
}

auto R = FS->findSamplesAt(Probe->Id, Probe->Discriminator);
if (R) {
Expand Down
51 changes: 50 additions & 1 deletion llvm/lib/Analysis/TargetLibraryInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,49 @@ static bool matchType(FuncArgTypeID ArgTy, const Type *Ty, unsigned IntBits,
llvm_unreachable("Invalid type");
}

static bool isValidProtoForSizeReturningNew(const FunctionType &FTy, LibFunc F,
const Module &M,
int SizeTSizeBits) {
switch (F) {
case LibFunc_size_returning_new: {
if (FTy.getNumParams() != 1 ||
!FTy.getParamType(0)->isIntegerTy(SizeTSizeBits)) {
return false;
}
} break;
case LibFunc_size_returning_new_hot_cold: {
if (FTy.getNumParams() != 2 ||
!FTy.getParamType(0)->isIntegerTy(SizeTSizeBits) ||
!FTy.getParamType(1)->isIntegerTy(8)) {
return false;
}
} break;
case LibFunc_size_returning_new_aligned: {
if (FTy.getNumParams() != 2 ||
!FTy.getParamType(0)->isIntegerTy(SizeTSizeBits) ||
!FTy.getParamType(1)->isIntegerTy(SizeTSizeBits)) {
return false;
}
} break;
case LibFunc_size_returning_new_aligned_hot_cold:
if (FTy.getNumParams() != 3 ||
!FTy.getParamType(0)->isIntegerTy(SizeTSizeBits) ||
!FTy.getParamType(1)->isIntegerTy(SizeTSizeBits) ||
!FTy.getParamType(2)->isIntegerTy(8)) {
return false;
}
break;
default:
return false;
}

auto &Context = M.getContext();
PointerType *PtrTy = PointerType::get(Context, 0);
StructType *SizedPtrTy = StructType::get(
Context, {PtrTy, Type::getIntNTy(Context, SizeTSizeBits)});
return FTy.getReturnType() == SizedPtrTy;
}

bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy,
LibFunc F,
const Module &M) const {
Expand Down Expand Up @@ -1099,7 +1142,13 @@ bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy,

return false;
}

// Special handling of __size_returning_new functions that return a struct
// of type {void*, size_t}.
case LibFunc_size_returning_new:
case LibFunc_size_returning_new_hot_cold:
case LibFunc_size_returning_new_aligned:
case LibFunc_size_returning_new_aligned_hot_cold:
return isValidProtoForSizeReturningNew(FTy, F, M, getSizeTSize(M));
default:
break;
}
Expand Down
Loading