[all-commits] [llvm/llvm-project] bf1b59: [InferAlignment] Do not use intrinsic align attrib...

Stanislav Bardyuk via All-commits all-commits at lists.llvm.org
Fri Sep 11 06:23:27 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bf1b598fff82413353b3ad45c4df06b243c1e6a1
      https://github.com/llvm/llvm-project/commit/bf1b598fff82413353b3ad45c4df06b243c1e6a1
  Author: Stanislav Bardyuk <6258615+kodlan at users.noreply.github.com>
  Date:   2026-09-11 (Fri, 11 Sep 2026)

  Changed paths:
    M llvm/lib/Transforms/Scalar/InferAlignment.cpp
    M llvm/test/Transforms/InferAlignment/masked.ll
    M llvm/test/Transforms/InferAlignment/memintrinsics.ll

  Log Message:
  -----------
  [InferAlignment] Do not use intrinsic align attributes as base pointer alignment (#221018)

InferAlignment propagates alignment between accesses of the same base
pointer: each load/store records how aligned the base must be, and later
accesses of that base are upgraded. Since #156057 (masked.load/store)
and
#217172 (memcpy/memmove/memset), the align parameter attribute of these
intrinsics is fed into the same table.

That is not sound. A memset with a zero length (or a masked store with
an
all-false mask) does not access memory, and its pointer argument is
allowed
to be poison, so an align attribute on it proves nothing about the
pointer.
For

```llvm
define void @test(ptr %p, i64 %n) {
  call void @llvm.memset(ptr align 16 %p, i8 0, i64 %n, i1 false)
  store i32 0, ptr %p
  ret void
}
```

the store was upgraded to align 16, which is UB when %p is only 4-byte
aligned and %n is 0.

Stop presenting the attribute alignment to the base pointer logic: the
intrinsic branch now passes align 1, the same convention the
and(ptrtoint)/trunc(ptrtoint) patterns use for "this instruction proves
nothing". The attribute can still be improved from a dominating real
access or from known bits. A constant non-zero length would be a
provable access, but it is deliberately not special-cased, as suggested
in the issue.

Fixes #220520



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