Files
clang-p2996/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
Henrik G. Olsson e6eda66cbc Recommit changes to global checks (#71171)
Recommits the changes from https://reviews.llvm.org/D148216.
Explicitly named globals are now matched literally, instead of emitting
a capture group for the name. This resolves #70047.
Metadata and annotations, on the other hand, are captured and matched
against by default, since their identifiers are not stable.

The reasons for revert (#63746) have been fixed:
The first issue, that of duplicated checkers, has already been resolved
in #70050.
This PR resolves the second issue listed in #63746, regarding the order
of named and unnamed globals. This is fixed by recording the index of
substrings containing global values, and sorting the checks according to
that index before emitting them. This results in global value checks
being emitted in the order they were seen instead of being grouped
separately.
2023-11-13 14:45:27 +01:00

106 lines
4.0 KiB
Plaintext

// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals smart
// Check that the CHECK lines are generated for clang-generated functions
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s -emit-llvm -o - | FileCheck --check-prefix=OMP %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | FileCheck --check-prefix=NOOMP %s
const int size = 1024 * 1024 * 32;
double A[size];
void foo(void);
// OMP-LABEL: @main(
// OMP-NEXT: entry:
// OMP-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
// OMP-NEXT: [[I:%.*]] = alloca i32, align 4
// OMP-NEXT: store i32 0, ptr [[RETVAL]], align 4
// OMP-NEXT: store i32 0, ptr [[I]], align 4
// OMP-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB2:[0-9]+]], i32 0, ptr @main.omp_outlined)
// OMP-NEXT: call void @foo()
// OMP-NEXT: ret i32 0
//
// NOOMP-LABEL: @main(
// NOOMP-NEXT: entry:
// NOOMP-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
// NOOMP-NEXT: [[I:%.*]] = alloca i32, align 4
// NOOMP-NEXT: store i32 0, ptr [[RETVAL]], align 4
// NOOMP-NEXT: store i32 0, ptr [[I]], align 4
// NOOMP-NEXT: store i32 0, ptr [[I]], align 4
// NOOMP-NEXT: br label [[FOR_COND:%.*]]
// NOOMP: for.cond:
// NOOMP-NEXT: [[TMP0:%.*]] = load i32, ptr [[I]], align 4
// NOOMP-NEXT: [[CMP:%.*]] = icmp slt i32 [[TMP0]], 33554432
// NOOMP-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]]
// NOOMP: for.body:
// NOOMP-NEXT: [[TMP1:%.*]] = load i32, ptr [[I]], align 4
// NOOMP-NEXT: [[IDXPROM:%.*]] = sext i32 [[TMP1]] to i64
// NOOMP-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [33554432 x double], ptr @A, i64 0, i64 [[IDXPROM]]
// NOOMP-NEXT: store double 0.000000e+00, ptr [[ARRAYIDX]], align 8
// NOOMP-NEXT: br label [[FOR_INC:%.*]]
// NOOMP: for.inc:
// NOOMP-NEXT: [[TMP2:%.*]] = load i32, ptr [[I]], align 4
// NOOMP-NEXT: [[INC:%.*]] = add nsw i32 [[TMP2]], 1
// NOOMP-NEXT: store i32 [[INC]], ptr [[I]], align 4
// NOOMP-NEXT: br label [[FOR_COND]], !llvm.loop [[LOOP2:![0-9]+]]
// NOOMP: for.end:
// NOOMP-NEXT: call void @foo()
// NOOMP-NEXT: ret i32 0
//
int main(void) {
int i = 0;
#pragma omp parallel for
for (i = 0; i < size; ++i) {
A[i] = 0.0;
}
foo();
return 0;
}
// OMP-LABEL: @foo(
// OMP-NEXT: entry:
// OMP-NEXT: [[I:%.*]] = alloca i32, align 4
// OMP-NEXT: store i32 0, ptr [[I]], align 4
// OMP-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB2]], i32 0, ptr @foo.omp_outlined)
// OMP-NEXT: ret void
//
// NOOMP-LABEL: @foo(
// NOOMP-NEXT: entry:
// NOOMP-NEXT: [[I:%.*]] = alloca i32, align 4
// NOOMP-NEXT: store i32 0, ptr [[I]], align 4
// NOOMP-NEXT: store i32 0, ptr [[I]], align 4
// NOOMP-NEXT: br label [[FOR_COND:%.*]]
// NOOMP: for.cond:
// NOOMP-NEXT: [[TMP0:%.*]] = load i32, ptr [[I]], align 4
// NOOMP-NEXT: [[CMP:%.*]] = icmp slt i32 [[TMP0]], 33554432
// NOOMP-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]]
// NOOMP: for.body:
// NOOMP-NEXT: [[TMP1:%.*]] = load i32, ptr [[I]], align 4
// NOOMP-NEXT: [[IDXPROM:%.*]] = sext i32 [[TMP1]] to i64
// NOOMP-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [33554432 x double], ptr @A, i64 0, i64 [[IDXPROM]]
// NOOMP-NEXT: store double 1.000000e+00, ptr [[ARRAYIDX]], align 8
// NOOMP-NEXT: br label [[FOR_INC:%.*]]
// NOOMP: for.inc:
// NOOMP-NEXT: [[TMP2:%.*]] = load i32, ptr [[I]], align 4
// NOOMP-NEXT: [[INC:%.*]] = add nsw i32 [[TMP2]], 1
// NOOMP-NEXT: store i32 [[INC]], ptr [[I]], align 4
// NOOMP-NEXT: br label [[FOR_COND]], !llvm.loop [[LOOP4:![0-9]+]]
// NOOMP: for.end:
// NOOMP-NEXT: ret void
//
void foo(void) {
int i = 0;
#pragma omp parallel for
for (i = 0; i < size; ++i) {
A[i] = 1.0;
}
}
//.
// NOOMP: [[LOOP2]] = distinct !{[[LOOP2]], [[META3:![0-9]+]]}
// NOOMP: [[META3]] = !{!"llvm.loop.mustprogress"}
// NOOMP: [[LOOP4]] = distinct !{[[LOOP4]], [[META3]]}
//.