Skip to content

[SCCP] Pointer equality propagated without regard to provenance #159565

@nikic

Description

@nikic

https://llvm.godbolt.org/z/jPns55Tjn

; RUN: opt -S -passes=sccp < %s
define ptr @src(ptr %x) {
  %cmp = icmp eq ptr %x, inttoptr (i64 12345678 to ptr)
  call void @llvm.assume(i1 %cmp)
  ret ptr %x
}

define ptr @tgt(ptr %x) {
  %cmp = icmp eq ptr %x, inttoptr (i64 12345678 to ptr)
  call void @llvm.assume(i1 %cmp)
  ret ptr inttoptr (i64 12345678 to ptr)
}

This does not take into account that the two pointers may have different provenance. We've fixed this in other places like GVN, but not in SCCP apparently.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions