-
Notifications
You must be signed in to change notification settings - Fork 100
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
[CIR][CodeGen] Fix array initialization in CIRGenExprAgg #852
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6a11031
[CIR][Lowering] Fix lowering for multi dimensional array
bruteforceboy 2694e25
update array-init.c and extra test
bruteforceboy 0bfd66d
undo forced push
bruteforceboy 211aa85
Merge branch 'agg-init' of https://github.com/bruteforceboy/clangir i…
bruteforceboy 5d1234c
update test
bruteforceboy 3846579
undo commits
bruteforceboy 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 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
This file contains 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,38 @@ | ||
// 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 | ||
|
||
typedef struct { | ||
int a; | ||
int b[2]; | ||
} A; | ||
|
||
int bar() { | ||
return 42; | ||
} | ||
|
||
void foo() { | ||
A a = {bar(), {}}; | ||
} | ||
// CHECK: %0 = cir.alloca !ty_A, !cir.ptr<!ty_A>, ["a", init] | ||
// CHECK: %1 = cir.alloca !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>, ["arrayinit.temp", init] | ||
// CHECK: %2 = cir.get_member %0[0] {name = "a"} : !cir.ptr<!ty_A> -> !cir.ptr<!s32i> | ||
// CHECK: %3 = cir.call @_Z3barv() : () -> !s32i | ||
// CHECK: cir.store %3, %2 : !s32i, !cir.ptr<!s32i> | ||
// CHECK: %4 = cir.get_member %0[1] {name = "b"} : !cir.ptr<!ty_A> -> !cir.ptr<!cir.array<!s32i x 2>> | ||
// CHECK: %5 = cir.cast(array_to_ptrdecay, %4 : !cir.ptr<!cir.array<!s32i x 2>>), !cir.ptr<!s32i> | ||
// CHECK: cir.store %5, %1 : !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>> | ||
// CHECK: %6 = cir.const #cir.int<2> : !s64i | ||
// CHECK: %7 = cir.ptr_stride(%5 : !cir.ptr<!s32i>, %6 : !s64i), !cir.ptr<!s32i> | ||
// CHECK: cir.do { | ||
// CHECK: %8 = cir.load %1 : !cir.ptr<!cir.ptr<!s32i>>, !cir.ptr<!s32i> | ||
// CHECK: %9 = cir.const #cir.int<0> : !s32i | ||
// CHECK: cir.store %9, %8 : !s32i, !cir.ptr<!s32i> | ||
// CHECK: %10 = cir.const #cir.int<1> : !s64i | ||
// CHECK: %11 = cir.ptr_stride(%8 : !cir.ptr<!s32i>, %10 : !s64i), !cir.ptr<!s32i> | ||
// CHECK: cir.store %11, %1 : !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>> | ||
// CHECK: cir.yield | ||
// CHECK: } while { | ||
// CHECK: %8 = cir.load %1 : !cir.ptr<!cir.ptr<!s32i>>, !cir.ptr<!s32i> | ||
// CHECK: %9 = cir.cmp(ne, %8, %7) : !cir.ptr<!s32i>, !cir.bool | ||
// CHECK: cir.condition(%9) | ||
// CHECK: } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to use regexes for SSA values and struct definitions, see examples in
clang/test/CIR/CodeGen/abstract-cond.c
and eslewhere.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated