llvm::canCreateUndefOrPoison

Return true if Op can create undef or poison from clean operands.

Synopsis

Declared in <llvm/Analysis/ValueTracking.h>

bool
canCreateUndefOrPoison(
    Operator const* Op,
    bool ConsiderFlagsAndMetadata = true);

Description

For vectors, canCreateUndefOrPoison returns true if there is potential poison or undef in any element of the result when vectors without undef/poison poison are given as operands. For example, given Op = shl <2 x i32> %x, <0, 32>, this function returns true. If Op raises immediate UB but never creates poison or undef (e.g. sdiv I, 0), canCreatePoison returns false.

ConsiderFlagsAndMetadata controls whether poison producing flags and metadata on the instruction are considered. This can be used to see if the instruction could still introduce undef or poison even without poison generating flags and metadata which might be on the instruction. (i.e. could the result of Op->dropPoisonGeneratingFlags() still create poison or undef)

canCreatePoison returns true if Op can create poison from non-poison operands.

Return Value

True if Op can create undef or poison.

Parameters

NameDescription
OpOperator that may introduce undef or poison.
ConsiderFlagsAndMetadataWhether poison-generating flags/metadata count.