Juneyoung Lee via llvm-dev
2020-Aug-19 03:05 UTC
[llvm-dev] The value of padding when storing an aggregate into memory
Hello all, LangRef isn't clear about the value of padding when an aggregate value is stored into memory, and I'd like to suggest that storing an aggregate fills padding with undef. Here are a few clues that supports this change: - According to C17, the value of padding bytes when storing values in structures or unions is unspecified. - IPSCCP ignores padding and directly stores a constant aggregate if possible: https://godbolt.org/z/ddWq9z Memcpyopt ignores padding when copying an aggregate or storing a constant: https://godbolt.org/z/hY6ndd / https://godbolt.org/z/3WMP5a - Alive2 (with store operation updated) did not find any problematic transformation from LLVM unit tests and while running translation validation on a few C programs. The patch is here: https://reviews.llvm.org/D86189 Thanks, Juneyoung -- Juneyoung Lee Software Foundation Lab, Seoul National University -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200819/482c1806/attachment.html>
Alexander Cherepanov via llvm-dev
2020-Aug-19 11:43 UTC
[llvm-dev] The value of padding when storing an aggregate into memory
On 19/08/2020 06.05, Juneyoung Lee via llvm-dev wrote:> LangRef isn't clear about the value of padding when an aggregate value is > stored into memory, and I'd like to suggest that storing an aggregate fills > padding with undef. > > Here are a few clues that supports this change: > > - According to C17, the value of padding bytes when storing values in > structures or unions is unspecified. > > - IPSCCP ignores padding and directly stores a constant aggregate if > possible: https://godbolt.org/z/ddWq9z > Memcpyopt ignores padding when copying an aggregate or storing a constant: > https://godbolt.org/z/hY6ndd / https://godbolt.org/z/3WMP5aInteresting topic. Is any such optimization reachable from C? -- Alexander Cherepanov
Juneyoung Lee via llvm-dev
2020-Aug-19 15:55 UTC
[llvm-dev] The value of padding when storing an aggregate into memory
Hello Alexander,> Interesting topic. Is any such optimization reachable from C?Yes, I think so - both PassBuilder and PassManagerBuilder add MemCpyOpt & IPSCCP in the default pass pipeline. Juneyoung On Wed, Aug 19, 2020 at 8:43 PM Alexander Cherepanov <ch3root at openwall.com> wrote:> On 19/08/2020 06.05, Juneyoung Lee via llvm-dev wrote: > > LangRef isn't clear about the value of padding when an aggregate value is > > stored into memory, and I'd like to suggest that storing an aggregate > fills > > padding with undef. > > > > Here are a few clues that supports this change: > > > > - According to C17, the value of padding bytes when storing values in > > structures or unions is unspecified. > > > > - IPSCCP ignores padding and directly stores a constant aggregate if > > possible: https://godbolt.org/z/ddWq9z > > Memcpyopt ignores padding when copying an aggregate or storing a > constant: > > https://godbolt.org/z/hY6ndd / https://godbolt.org/z/3WMP5a > > Interesting topic. Is any such optimization reachable from C? > > -- > Alexander Cherepanov >-- Juneyoung Lee Software Foundation Lab, Seoul National University -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200820/01ce2cb3/attachment.html>