Issue 64613
Summary Miscompile with attributor-light and dse
Labels miscompilation, llvm:optimizations
Assignees
Reporter bevin-hansson
    In the following case, running `attributor-light` followed by `dse` results in a miscompilation:
```
define dso_local ptr @fun(ptr noundef %p) {
entry:
  %p.addr = alloca ptr, align 1
  store ptr %p, ptr %p.addr, align 1
  %0 = load ptr, ptr %p.addr, align 1
  ret ptr %0
}

define dso_local i16 @test_it() {
entry:
  %x = alloca i16, align 1
  %p = alloca ptr, align 1
  call void @llvm.lifetime.start.p0(i64 2, ptr %x)
  store i16 42, ptr %x, align 1
 call void @llvm.lifetime.start.p0(i64 2, ptr %p)
  %call = call ptr @fun(ptr noundef %x)
  store ptr %call, ptr %p, align 1
  %0 = load ptr, ptr %p, align 1
  %1 = load i16, ptr %0, align 1
  %cmp = icmp eq i16 %1, 42
  %conv = zext i1 %cmp to i16
  call void @llvm.lifetime.end.p0(i64 2, ptr %p)
  call void @llvm.lifetime.end.p0(i64 2, ptr %x)
  ret i16 %conv
}

declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)

declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
```
Executing `opt -passes='attributor-light,function(dse)' repr.ll` produces an IR where the `store i16 42` is eliminated, but the store is not dead.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to