Lin-Ya Yu via llvm-dev
2019-Feb-21 19:35 UTC
[llvm-dev] If there are some passes in LLVM do the opposite of the SROA(Scalar Replacement of Aggregates) pass
Hi LLVM developers, We tried to find if there are some passes in LLVM do the opposite of the SROA(Scalar Replacement of Aggregates) pass, but did not find one. Do we have this kind of pass to bring back the structure type? Or this is done separately in any transformation passes? Thanks, Lin-Ya -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190221/8c992d42/attachment.html>
Victor Campos via llvm-dev
2019-Feb-27 20:35 UTC
[llvm-dev] If there are some passes in LLVM do the opposite of the SROA(Scalar Replacement of Aggregates) pass
Hi Lin-Ya, maybe reg2mem is what you're looking for? Regards, Victor. On Thu, Feb 21, 2019 at 4:35 PM Lin-Ya Yu via llvm-dev < llvm-dev at lists.llvm.org> wrote:> > Hi LLVM developers, > > We tried to find if there are some passes in LLVM do the opposite of the > SROA(Scalar Replacement of Aggregates) pass, but did not find one. Do we > have this kind of pass to bring back the structure type? Or this is done > separately in any transformation passes? > > Thanks, > Lin-Ya > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190227/f0bd45a3/attachment.html>
Lin-Ya Yu via llvm-dev
2019-Mar-06 12:06 UTC
[llvm-dev] If there are some passes in LLVM do the opposite of the SROA(Scalar Replacement of Aggregates) pass
Hi Victor and LLVM developers, Thanks for your reply!:) reg2mem transforms values back to pointers. But I would like to look for the pass or any functions provided in LLVM to get the disaggregate structs back to aggregate struct. My goal is to do the transformation to coalesce the accesses from the same struct together. Below is an example to explain clearer what I am looking for. In the IR, I would like to have 2 load instructions that each loads a variable in the struct transform to one single load instruction that directly loads the struct. If this makes sense and anyone knows whether there is related passes or functions exists. Thanks for helping! -Lin-Ya Exported from Notepad++ %struct.mystruct = type <{ i8, i16, i8 }> @llvm.global_ctors = appending global [0 x { i32, void ()*, i8* }] zeroinitializer define i32 @_Z3accP8mystructPcPs(%struct.mystruct* noalias nonnull %input, i8* noalias nonnull %a, i16* noalias nonnull %b) { entry: br label %for.inc for.inc: ; preds = %for.inc, %entry %i.03 = phi i32 [ 0, %entry ], [ %inc, %for.inc ] %idxprom = sext i32 %i.03 to i64 %a11 = getelementptr inbounds %struct. mystruct, %struct.mystruct* %input, i64 %idxprom, i32 0 %0 = load i8, i8* %a11, align 4 %arrayidx3 = getelementptr inbounds i8, i8* %a, i64 %idxprom store i8 %0, i8* %arrayidx3, align 1 %b62 = getelementptr inbounds %struct. mystruct, %struct.mystruct* %input, i64 %idxprom, i32 1 %1 = load i16, i16* %b62, align 1 %arrayidx8 = getelementptr inbounds i16, i16* %b, i64 %idxprom store i16 %1, i16* %arrayidx8, align 2 %inc = add nsw i32 %i.03, 1 %cmp icmp slt i32 %inc, 10 br i1 %cmp, label %for.inc, label %for.end for.end: ; preds = %for.inc ret i32 0 } -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190306/8195c8c7/attachment.html>