-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[ir] Let real function return nested StructType #7059
Conversation
[ghstack-poisoned]
ghstack-source-id: 9e9de3d852a8adaf4dae5810a868a31afefeae1a Pull Request resolved: #7059
@@ -2757,6 +2749,49 @@ llvm::Type *TaskCodeGenLLVM::get_real_func_ret_type(Function *real_func) { | |||
return llvm::StructType::get(*llvm_context, tps); | |||
} | |||
|
|||
void TaskCodeGenLLVM::create_return(llvm::Value *buffer, | |||
llvm::Type *buffer_type, |
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.
Can we obtain buffer_type from buffer->getType()
?
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.
No... While it works fine on linux machines, it doesn't work on Windows because the pointers are opaque pointers, and buffer->getType()
only returns ptr
in LLVM 15. I don't know why it works on linux machines... maybe the LLVM binaries are different....
issue: #6983 Before this PR, if we want to return a struct type in a real function, we flatten the struct in LLVM. For example, `struct(a: Ta, s: struct(b: Tb, c: Tc))` is flattened to `struct(a: Ta, b: Tb, c: Tc)`. After this PR, we do not flatten anymore. We directly return `struct(a: Ta, s: struct(b: Tb, c: Tc))`. Note that we still need to pass the flattened return values from Python to CHI-IR because we can't pass a Python struct into C++. We compose the target struct type from the flattened values and the return type in the codegen. [ghstack-poisoned]
ghstack-source-id: da419c9cae39d8a96490c01b5dbf0b50fd2137c3 Pull Request resolved: #7059
issue: #6983 Before this PR, if we want to return a struct type in a real function, we flatten the struct in LLVM. For example, `struct(a: Ta, s: struct(b: Tb, c: Tc))` is flattened to `struct(a: Ta, b: Tb, c: Tc)`. After this PR, we do not flatten anymore. We directly return `struct(a: Ta, s: struct(b: Tb, c: Tc))`. Note that we still need to pass the flattened return values from Python to CHI-IR because we can't pass a Python struct into C++. We compose the target struct type from the flattened values and the return type in the codegen. [ghstack-poisoned]
ghstack-source-id: dc6954a0f04f99a8edb72a6b950315ccf60a7237 Pull Request resolved: #7059
issue: #6983 Before this PR, if we want to return a struct type in a real function, we flatten the struct in LLVM. For example, `struct(a: Ta, s: struct(b: Tb, c: Tc))` is flattened to `struct(a: Ta, b: Tb, c: Tc)`. After this PR, we do not flatten anymore. We directly return `struct(a: Ta, s: struct(b: Tb, c: Tc))`. Note that we still need to pass the flattened return values from Python to CHI-IR because we can't pass a Python struct into C++. We compose the target struct type from the flattened values and the return type in the codegen. [ghstack-poisoned]
ghstack-source-id: 21a1ad6ce1912fd52267a176586bde2d56bd8148 Pull Request resolved: #7059
issue: #6983 Before this PR, if we want to return a struct type in a real function, we flatten the struct in LLVM. For example, `struct(a: Ta, s: struct(b: Tb, c: Tc))` is flattened to `struct(a: Ta, b: Tb, c: Tc)`. After this PR, we do not flatten anymore. We directly return `struct(a: Ta, s: struct(b: Tb, c: Tc))`. Note that we still need to pass the flattened return values from Python to CHI-IR because we can't pass a Python struct into C++. We compose the target struct type from the flattened values and the return type in the codegen. [ghstack-poisoned]
ghstack-source-id: 2898ad5c64bbee12090e1546c3dbf24b85603a56 Pull Request resolved: #7059
issue: #6983 Before this PR, if we want to return a struct type in a real function, we flatten the struct in LLVM. For example, `struct(a: Ta, s: struct(b: Tb, c: Tc))` is flattened to `struct(a: Ta, b: Tb, c: Tc)`. After this PR, we do not flatten anymore. We directly return `struct(a: Ta, s: struct(b: Tb, c: Tc))`. Note that we still need to pass the flattened return values from Python to CHI-IR because we can't pass a Python struct into C++. We compose the target struct type from the flattened values and the return type in the codegen. [ghstack-poisoned]
ghstack-source-id: 1384c5f237c9b2dda70d084668fe902226388bc0 Pull Request resolved: #7059
issue: #6983 Before this PR, if we want to return a struct type in a real function, we flatten the struct in LLVM. For example, `struct(a: Ta, s: struct(b: Tb, c: Tc))` is flattened to `struct(a: Ta, b: Tb, c: Tc)`. After this PR, we do not flatten anymore. We directly return `struct(a: Ta, s: struct(b: Tb, c: Tc))`. Note that we still need to pass the flattened return values from Python to CHI-IR because we can't pass a Python struct into C++. We compose the target struct type from the flattened values and the return type in the codegen. [ghstack-poisoned]
ghstack-source-id: c7345fbae605793d13fd4c358e65ab20815c9155 Pull Request resolved: #7059
ghstack-source-id: c7345fbae605793d13fd4c358e65ab20815c9155 Pull Request resolved: #7059
ghstack-source-id: c7345fbae605793d13fd4c358e65ab20815c9155 Pull Request resolved: taichi-dev#7059
Stack from ghstack (oldest at bottom):
issue: #6983
Before this PR, if we want to return a struct type in a real function, we flatten the struct in LLVM. For example,
struct(a: Ta, s: struct(b: Tb, c: Tc))
is flattened tostruct(a: Ta, b: Tb, c: Tc)
. After this PR, we do not flatten anymore. We directly returnstruct(a: Ta, s: struct(b: Tb, c: Tc))
.Note that we still need to pass the flattened return values from Python to CHI-IR because we can't pass a Python struct into C++. We compose the target struct type from the flattened values and the return type in the codegen.