LLVM 19.0.0git
Macros | Functions | Variables
PoisonChecking.cpp File Reference
#include "llvm/Transforms/Instrumentation/PoisonChecking.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/Support/CommandLine.h"

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "poison-checking"
 

Functions

static bool isConstantFalse (Value *V)
 
static ValuebuildOrChain (IRBuilder<> &B, ArrayRef< Value * > Ops)
 
static void generateCreationChecksForBinOp (Instruction &I, SmallVectorImpl< Value * > &Checks)
 
static void generateCreationChecks (Instruction &I, SmallVectorImpl< Value * > &Checks)
 Given an instruction which can produce poison on non-poison inputs (i.e.
 
static ValuegetPoisonFor (DenseMap< Value *, Value * > &ValToPoison, Value *V)
 
static void CreateAssert (IRBuilder<> &B, Value *Cond)
 
static void CreateAssertNot (IRBuilder<> &B, Value *Cond)
 
static bool rewrite (Function &F)
 

Variables

static cl::opt< boolLocalCheck ("poison-checking-function-local", cl::init(false), cl::desc("Check that returns are non-poison (for testing)"))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "poison-checking"

Definition at line 69 of file PoisonChecking.cpp.

Function Documentation

◆ buildOrChain()

static Value * buildOrChain ( IRBuilder<> &  B,
ArrayRef< Value * >  Ops 
)
static

Definition at line 84 of file PoisonChecking.cpp.

References B, llvm::drop_begin(), isConstantFalse(), and llvm::ArrayRef< T >::size().

Referenced by rewrite().

◆ CreateAssert()

static void CreateAssert ( IRBuilder<> &  B,
Value Cond 
)
static

Definition at line 236 of file PoisonChecking.cpp.

References assert(), B, Cond, llvm::Type::getInt1Ty(), and llvm::Type::getVoidTy().

Referenced by CreateAssertNot().

◆ CreateAssertNot()

static void CreateAssertNot ( IRBuilder<> &  B,
Value Cond 
)
static

Definition at line 250 of file PoisonChecking.cpp.

References assert(), B, Cond, and CreateAssert().

Referenced by rewrite().

◆ generateCreationChecks()

static void generateCreationChecks ( Instruction I,
SmallVectorImpl< Value * > &  Checks 
)
static

Given an instruction which can produce poison on non-poison inputs (i.e.

canCreatePoison returns true), generate runtime checks to produce boolean indicators of when poison would result.

Definition at line 181 of file PoisonChecking.cpp.

References B, Check, generateCreationChecksForBinOp(), llvm::Value::getType(), I, Idx, and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by rewrite().

◆ generateCreationChecksForBinOp()

static void generateCreationChecksForBinOp ( Instruction I,
SmallVectorImpl< Value * > &  Checks 
)
static

◆ getPoisonFor()

static Value * getPoisonFor ( DenseMap< Value *, Value * > &  ValToPoison,
Value V 
)
static

◆ isConstantFalse()

static bool isConstantFalse ( Value V)
static

Definition at line 77 of file PoisonChecking.cpp.

References assert().

Referenced by buildOrChain().

◆ rewrite()

static bool rewrite ( Function F)
static

Variable Documentation

◆ LocalCheck

cl::opt< bool > LocalCheck("poison-checking-function-local", cl::init(false), cl::desc("Check that returns are non-poison (for testing)")) ( "poison-checking-function-local"  ,
cl::init(false)  ,
cl::desc("Check that returns are non-poison (for testing)")   
)
static

Referenced by rewrite().