[PATCH] D124514: [ArgPromotion] Make a non-byval promotion attempt first

Pavel Samolysov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 4 04:31:21 PDT 2022


psamolysov added a comment.

Colleagues, if the changes look good for you, could you help me with landing? Thank you.

If you have no objections, I would like to use the comments under this review to ask a question about changing the byval promotion scheme with the "usual" one. The following code:

  define internal void @f(%struct.ss* byval(%struct.ss) align 4 %b, %struct.ss** align 8 %acc) nounwind  {
  entry:
    store %struct.ss* %b, %struct.ss** %acc, align 8
    ret void
  }

Currently is optimized to the following one:

  define internal void @f(i32 %b.0, i64 %b.1, %struct.ss** align 8 %acc) #0 {
  entry:
    %b = alloca %struct.ss, align 4
    %.0 = getelementptr %struct.ss, %struct.ss* %b, i32 0, i32 0
    store i32 %b.0, i32* %.0, align 4
    %.1 = getelementptr %struct.ss, %struct.ss* %b, i32 0, i32 1
    store i64 %b.1, i64* %.1, align 4
   
    store %struct.ss* %b, %struct.ss** %acc, align 8
    ret void
  }

So, actually we store not the original pointer of `%struct.ss` but a pointer to a temporary allocated on the function `f`'s stack frame. This definitely changes the semantic of the code. Should we save this behavior?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124514/new/

https://reviews.llvm.org/D124514



More information about the llvm-commits mailing list