-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[CIR] Upstream a batch of passing tests from CIR-Incubator #157333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // TODO: fix crash in emitTaskWaitCall | ||
| // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fopenmp-enable-irbuilder -fopenmp -fclangir -emit-cir %s -o %t.cir | ||
| // RUN: FileCheck --input-file=%t.cir %s | ||
|
|
||
| // CHECK: cir.func | ||
| void omp_taskwait_1(){ | ||
| // CHECK-DISABLE: omp.taskwait | ||
| // #pragma omp taskwait | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // RUN: true | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| int strlen(char const *); | ||
| void puts(char const *); | ||
|
|
||
| struct String { | ||
| long size; | ||
| long capacity; | ||
| char *storage; | ||
|
|
||
| String() : size{0}, capacity{0}, storage{nullptr} {} | ||
| String(char const *s) : size{strlen(s)}, capacity{size}, | ||
| storage{new char[capacity]} {} | ||
| }; | ||
|
|
||
| struct StringView { | ||
| long size; | ||
| char *storage; | ||
|
|
||
| StringView(const String &s) : size{s.size}, storage{s.storage} {} | ||
| StringView() : size{0}, storage{nullptr} {} | ||
| }; | ||
|
|
||
| int main() { | ||
| StringView sv; | ||
| { | ||
| String s = "Hi"; | ||
| sv = s; | ||
|
|
||
| puts(sv.storage); | ||
| } | ||
|
|
||
| puts(sv.storage); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir | ||
|
||
| // RUN: FileCheck --input-file=%t.cir %s | ||
|
|
||
| int foo(int a, int b) { | ||
| int x = a * b; | ||
| x *= b; | ||
| x /= b; | ||
| x %= b; | ||
| x += b; | ||
| x -= b; | ||
| x >>= b; | ||
| x <<= b; | ||
| x &= b; | ||
| x ^= b; | ||
| x |= b; | ||
| return x; | ||
| } | ||
|
|
||
| // CHECK: [[Value:%[0-9]+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {alignment = 4 : i64} | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // CHECK: = cir.binop(mul, | ||
| // CHECK: = cir.load {{.*}}[[Value]] | ||
| // CHECK: = cir.binop(mul, | ||
| // CHECK: cir.store{{.*}} {{.*}}[[Value]] | ||
| // CHECK: = cir.load {{.*}}[[Value]] | ||
| // CHECK: cir.binop(div, | ||
| // CHECK: cir.store{{.*}} {{.*}}[[Value]] | ||
| // CHECK: = cir.load {{.*}}[[Value]] | ||
| // CHECK: = cir.binop(rem, {{.*}} loc([[SourceLocation:#loc[0-9]+]]) | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // CHECK: cir.store{{.*}} {{.*}}[[Value]] | ||
| // CHECK: = cir.load {{.*}}[[Value]] | ||
| // CHECK: = cir.binop(add, | ||
| // CHECK: cir.store{{.*}} {{.*}}[[Value]] | ||
| // CHECK: = cir.load {{.*}}[[Value]] | ||
| // CHECK: = cir.binop(sub, | ||
| // CHECK: cir.store{{.*}} {{.*}}[[Value]] | ||
| // CHECK: = cir.load {{.*}}[[Value]] | ||
| // CHECK: = cir.shift(right | ||
| // CHECK: cir.store{{.*}} {{.*}}[[Value]] | ||
| // CHECK: = cir.load {{.*}}[[Value]] | ||
| // CHECK: = cir.shift(left | ||
| // CHECK: cir.store{{.*}} {{.*}}[[Value]] | ||
| // CHECK: = cir.load {{.*}}[[Value]] | ||
| // CHECK: = cir.binop(and, | ||
| // CHECK: cir.store{{.*}} {{.*}}[[Value]] | ||
| // CHECK: = cir.load {{.*}}[[Value]] | ||
| // CHECK: = cir.binop(xor, | ||
| // CHECK: cir.store{{.*}} {{.*}}[[Value]] | ||
| // CHECK: = cir.load {{.*}}[[Value]] | ||
| // CHECK: = cir.binop(or, | ||
| // CHECK: cir.store{{.*}} {{.*}}[[Value]] | ||
|
|
||
| typedef enum { | ||
| A = 3, | ||
| } enumy; | ||
|
|
||
| enumy getty(); | ||
|
|
||
| void exec() { | ||
| enumy r; | ||
| if ((r = getty()) < 0) {} | ||
| } | ||
|
|
||
| // CHECK: cir.func dso_local @_Z4execv() | ||
| // CHECK: %0 = cir.alloca !u32i, !cir.ptr<!u32i>, ["r"] {alignment = 4 : i64} | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // CHECK: cir.scope { | ||
| // CHECK: %1 = cir.call @_Z5gettyv() : () -> !u32i | ||
| // CHECK: cir.store{{.*}} %1, %0 : !u32i, !cir.ptr<!u32i> | ||
| // CHECK: %2 = cir.cast(integral, %1 : !u32i), !s32i | ||
| // CHECK: %3 = cir.const #cir.int<0> : !s32i | ||
| // CHECK: %4 = cir.cmp(lt, %2, %3) : !s32i, !cir.bool | ||
| // CHECK: cir.if %4 { | ||
|
|
||
| // CHECK: [[SourceLocationB:#loc[0-9]+]] = loc("{{.*}}binassign.cpp":8:8) | ||
| // CHECK: [[SourceLocationA:#loc[0-9]+]] = loc("{{.*}}binassign.cpp":8:3) | ||
| // CHECK: [[SourceLocation]] = loc(fused[[[SourceLocationA]], [[SourceLocationB]]]) | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -fclangir -emit-cir %s -o %t.cir | ||
| // RUN: FileCheck --input-file=%t.cir %s | ||
|
|
||
| using u16 = unsigned short; | ||
| using u32 = unsigned int; | ||
| using u64 = unsigned long long; | ||
|
|
||
| u16 bswap_u16(u16 x) { | ||
| return __builtin_bswap16(x); | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| // CHECK: cir.func dso_local @_Z9bswap_u16t | ||
| // CHECK: %{{.+}} = cir.byte_swap %{{.+}} : !u16i | ||
| // CHECK: } | ||
|
|
||
| u32 bswap_u32(u32 x) { | ||
| return __builtin_bswap32(x); | ||
| } | ||
|
|
||
| // CHECK: cir.func dso_local @_Z9bswap_u32j | ||
| // CHECK: %{{.+}} = cir.byte_swap %{{.+}} : !u32i | ||
| // CHECK: } | ||
|
|
||
| u64 bswap_u64(u64 x) { | ||
| return __builtin_bswap64(x); | ||
| } | ||
|
|
||
| // CHECK: cir.func dso_local @_Z9bswap_u64y | ||
| // CHECK: %{{.+}} = cir.byte_swap %{{.+}} : !u64i | ||
| // CHECK: } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c89 -emit-cir %s -o %t.cir | ||
| // RUN: FileCheck --input-file=%t.cir %s | ||
|
|
||
| // Implicit int return type. | ||
| test = 0; | ||
| // CHECK: cir.global external @test = #cir.int<0> : !s32i | ||
| func (void) { | ||
| // CHECK: cir.func dso_local @func() -> !s32i | ||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -Wno-unused-value -emit-cir %s -o %t.cir | ||
|
||
| // RUN: FileCheck --input-file=%t.cir %s | ||
|
|
||
| int c0() { | ||
| int a = 1; | ||
| int b = 2; | ||
| return b + 1, a; | ||
| } | ||
|
|
||
| // CHECK: cir.func dso_local @_Z2c0v() -> !s32i | ||
| // CHECK: %[[#RET:]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"] | ||
| // CHECK: %[[#A:]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["a", init] | ||
| // CHECK: %[[#B:]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["b", init] | ||
| // CHECK: %[[#LOADED_B:]] = cir.load{{.*}} %[[#B]] : !cir.ptr<!s32i>, !s32i | ||
| // CHECK: %[[#]] = cir.binop(add, %[[#LOADED_B]], %[[#]]) nsw : !s32i | ||
| // CHECK: %[[#LOADED_A:]] = cir.load{{.*}} %[[#A]] : !cir.ptr<!s32i>, !s32i | ||
| // CHECK: cir.store{{.*}} %[[#LOADED_A]], %[[#RET]] : !s32i, !cir.ptr<!s32i> | ||
|
|
||
| int &foo1(); | ||
| int &foo2(); | ||
|
|
||
| void c1() { | ||
| int &x = (foo1(), foo2()); | ||
| } | ||
|
|
||
| // CHECK: cir.func dso_local @_Z2c1v() | ||
| // CHECK: %0 = cir.alloca !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>> | ||
| // CHECK: %1 = cir.call @_Z4foo1v() : () -> !cir.ptr<!s32i> | ||
| // CHECK: %2 = cir.call @_Z4foo2v() : () -> !cir.ptr<!s32i> | ||
| // CHECK: cir.store{{.*}} %2, %0 : !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.