Skip to content

[FunctionAttrs] Incorrect nonnull inference for non-inbounds GEP #91177

Closed
@nikic

Description

@nikic

FunctionAttrs incorrectly infers that the following function returns nonnull (https://llvm.godbolt.org/z/49Kbq15xn):

define ptr @test(ptr nonnull %arg) {
  %res = getelementptr i8, ptr %arg, i64 -8
  ret ptr %res
}

This is because the code assumes that the result of a GEP is non-null if the source is non-null here:

case Instruction::GetElementPtr:
This is not correct for non-inbounds GEPs.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions