Skip to content

Lint pass should warn when fast math flags are used with noundef call return attribute #174375

@arsenm

Description

@arsenm

This IR exhibits undefined behavior:

; RUN: opt -passes=lint %s

define float @noundef_with_fastmath_flags(float %x) {
  %result = call nnan noundef float @llvm.sqrt.f32(float %x)
  ret float %result
}

The sqrt will introduce poison if the input is negative or a nan due to the nnan flag. The lint utility pass should detect this anomaly and print a warning.

Probably need to introduce a cast to FPMathOperator, and check for poison generating flags around here

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issuehttps://github.com/llvm/llvm-project/contributellvm:analysisIncludes value tracking, cost tables and constant foldingquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions