llvm-project/clang/test/CodeGen/alloc-fns-alignment.c
hyeongyukim aacfbb953e [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default
Turning on `enable_noundef_analysis` flag allows better codegen by removing freeze instructions.
I modified clang by renaming `enable_noundef_analysis` flag to `disable-noundef-analysis` and turning it off by default.

Test updates are made as a separate patch: D108453

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D105169

[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default (2)

This patch updates test files after D105169.
Autogenerated test codes are changed by `utils/update_cc_test_checks.py,` and non-autogenerated test codes are changed as follows:

(1) I wrote a python script that (partially) updates the tests using regex: {F18594904} The script is not perfect, but I believe it gives hints about which patterns are updated to have `noundef` attached.

(2) The remaining tests are updated manually.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D108453

Resolve lit failures in clang after 8ca4b3e's land

Fix lit test failures in clang-ppc* and clang-x64-windows-msvc

Fix missing failures in clang-ppc64be* and retry fixing clang-x64-windows-msvc

Fix internal_clone(aarch64) inline assembly
2021-11-06 19:19:22 +09:00

82 lines
2.8 KiB
C

// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN16
// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN16
// RUN: %clang_cc1 -triple i386-apple-darwin -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN16
// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN8
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-malloc -emit-llvm < %s | FileCheck %s --check-prefix=NOBUILTIN-MALLOC
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-calloc -emit-llvm < %s | FileCheck %s --check-prefix=NOBUILTIN-CALLOC
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-realloc -emit-llvm < %s | FileCheck %s --check-prefix=NOBUILTIN-REALLOC
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-aligned_alloc -emit-llvm < %s | FileCheck %s --check-prefix=NOBUILTIN-ALIGNED_ALLOC
typedef __SIZE_TYPE__ size_t;
void *malloc(size_t);
void *calloc(size_t, size_t);
void *realloc(void *, size_t);
void *aligned_alloc(size_t, size_t);
void *malloc_test(size_t n) {
return malloc(n);
}
void *calloc_test(size_t n) {
return calloc(1, n);
}
void *realloc_test(void *p, size_t n) {
return realloc(p, n);
}
void *aligned_alloc_variable_test(size_t n, size_t a) {
return aligned_alloc(a, n);
}
void *aligned_alloc_constant_test(size_t n) {
return aligned_alloc(8, n);
}
void *aligned_alloc_large_constant_test(size_t n) {
return aligned_alloc(4096, n);
}
// CHECK-LABEL: @malloc_test
// ALIGN16: align 16 i8* @malloc
// CHECK-LABEL: @calloc_test
// ALIGN16: align 16 i8* @calloc
// CHECK-LABEL: @realloc_test
// ALIGN16: align 16 i8* @realloc
// CHECK-LABEL: @aligned_alloc_variable_test
// ALIGN16: %[[ALLOCATED:.*]] = call align 16 i8* @aligned_alloc({{i32|i64}} noundef %[[ALIGN:.*]], {{i32|i64}} noundef %[[NBYTES:.*]])
// ALIGN16-NEXT: call void @llvm.assume(i1 true) [ "align"(i8* %[[ALLOCATED]], {{i32|i64}} %[[ALIGN]]) ]
// CHECK-LABEL: @aligned_alloc_constant_test
// ALIGN16: align 16 i8* @aligned_alloc
// CHECK-LABEL: @aligned_alloc_large_constant_test
// ALIGN16: align 4096 i8* @aligned_alloc
// CHECK-LABEL: @malloc_test
// ALIGN8: align 8 i8* @malloc
// CHECK-LABEL: @calloc_test
// ALIGN8: align 8 i8* @calloc
// CHECK-LABEL: @realloc_test
// ALIGN8: align 8 i8* @realloc
// CHECK-LABEL: @aligned_alloc_variable_test
// ALIGN8: align 8 i8* @aligned_alloc
// CHECK-LABEL: @aligned_alloc_constant_test
// ALIGN8: align 8 i8* @aligned_alloc
// CHECK-LABEL: @aligned_alloc_large_constant_test
// ALIGN8: align 4096 i8* @aligned_alloc
// NOBUILTIN-MALLOC: declare i8* @malloc
// NOBUILTIN-CALLOC: declare i8* @calloc
// NOBUILTIN-REALLOC: declare i8* @realloc
// NOBUILTIN-ALIGNED_ALLOC: declare i8* @aligned_alloc