[PATCH] D94142: [IR] Allow scalable vectors in structs to support intrinsics returning multiple values.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 10 23:32:40 PST 2021
craig.topper added a comment.
In D94142#2489466 <https://reviews.llvm.org/D94142#2489466>, @kito-cheng wrote:
>> This patch removes the existing restriction for this. I've modified
>> StructType::isSized to consider a struct containing scalable vectors
>> as unsized so the verifier won't allow loads/stores/allocas of these
>> structs.
>
> I worry about this will become a problem when we implement tuple type on C level,
> clang will emit alloca & load & store no matter using -O0 or -O1.
>
> For example following program:
>
> struct foo{
> int x;
> };
>
> int bar(void)
> {
> struct foo a;
> return a.x;
> }
>
> Will emit following code:
>
> define i32 @bar() #0 {
> %1 = alloca %struct.foo, align 4
> %2 = getelementptr inbounds %struct.foo, %struct.foo* %1, i32 0, i32 0
> %3 = load i32, i32* %2, align 4
> ret i32 %3
> }
It won't be a struct in clang's type system. It's it own special builtin type. I hope we can control the codegen of that type and emit it as multiple allocas/loads/stores. I haven't looked at this yet. Clang can also emit fixed size memcpys of structs which would be broken for this. So we are going to need to customize clang.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94142/new/
https://reviews.llvm.org/D94142
More information about the llvm-commits
mailing list