Skip to content

[DSE] dereferenceable attribute should be updated after shortening memset at the beginning #115976

Closed
@dtcxzyw

Description

@dtcxzyw
; bin/opt -passes=dse test.ll -S
define void @test(ptr %p) {
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(100) %p, i8 0, i64 100, i1 false)
  store i32 5, ptr %p, align 4
  %4 = getelementptr inbounds i8, ptr %p, i64 4
  store i32 8, ptr %4, align 4
  %5 = getelementptr inbounds i8, ptr %p, i64 8
  store i32 5, ptr %5, align 4
  %6 = getelementptr inbounds i8, ptr %p, i64 12
  store i32 8, ptr %6, align 4
  ret void
}
define void @test(ptr %p) {
  %1 = getelementptr inbounds i8, ptr %p, i64 16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(100) %1, i8 0, i64 84, i1 false)
  store i32 5, ptr %p, align 4
  %2 = getelementptr inbounds i8, ptr %p, i64 4
  store i32 8, ptr %2, align 4
  %3 = getelementptr inbounds i8, ptr %p, i64 8
  store i32 5, ptr %3, align 4
  %4 = getelementptr inbounds i8, ptr %p, i64 12
  store i32 8, ptr %4, align 4
  ret void
}

Found with https://github.com/dtcxzyw/llvm-ub-aware-interpreter.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions