[all-commits] [llvm/llvm-project] 419a2c: [Inliner] Preserve alignment of byval arguments (#...

sallto via All-commits all-commits at lists.llvm.org
Sat Apr 26 12:39:19 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 419a2cb218245b90ace9e0a460d94057e7091002
      https://github.com/llvm/llvm-project/commit/419a2cb218245b90ace9e0a460d94057e7091002
  Author: sallto <68823230+sallto at users.noreply.github.com>
  Date:   2025-04-26 (Sat, 26 Apr 2025)

  Changed paths:
    M llvm/lib/Transforms/Utils/InlineFunction.cpp
    M llvm/test/Transforms/Inline/byval-align.ll
    M llvm/test/Transforms/Inline/byval-with-non-alloca-addrspace.ll
    M llvm/test/Transforms/Inline/byval.ll
    M llvm/test/Transforms/Inline/inline-deferred-instsimplify.ll
    M llvm/test/Transforms/Inline/inline-tail.ll

  Log Message:
  -----------
  [Inliner] Preserve alignment of byval arguments (#137455)

Previously the inliner always produced a memcpy with alignment 1 for src
and destination, leading to potentially suboptimal Codegen.

Since the Src ptr alignment is only available through the CallBase it
has to be passed to HandleByValArgumentInit. Dst Alignment is already
known so it doesn't have to be passed along.

If there is no specified Src Alignment my changes cause the ptr to have
no align data attached instead of align 1 as before (see
inline-tail.ll), I believe this is fine but since I'm a first time
contributor, please confirm.

My changes are already covered by 4 existing regression tests, so I did
not add any additional ones.

The example from #45778 now results in:
```C
opt -S -passes=inline,instcombine,sroa,instcombine test.ll

define dso_local i32 @test(ptr %t) {
entry:
  %.sroa.0.0.copyload = load ptr, ptr %t, align 8       # this used to be align 1 in the original issue
  %arrayidx.i = getelementptr inbounds nuw i8, ptr %.sroa.0.0.copyload, i64 24
  %0 = load i32, ptr %arrayidx.i, align 4
  ret i32 %0
}
```

Fixes #45778.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list