LLVM  13.0.0git
Macros | Functions | Variables
PoisonChecking.cpp File Reference
#include "llvm/Transforms/Instrumentation/PoisonChecking.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstVisitor.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
Include dependency graph for PoisonChecking.cpp:

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. More...
 
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< bool > LocalCheck ("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 75 of file PoisonChecking.cpp.

Function Documentation

◆ buildOrChain()

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

Definition at line 90 of file PoisonChecking.cpp.

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

Referenced by rewrite().

◆ CreateAssert()

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

Definition at line 242 of file PoisonChecking.cpp.

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

Referenced by CreateAssertNot().

◆ CreateAssertNot()

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

Definition at line 256 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 187 of file PoisonChecking.cpp.

References B, Check(), generateCreationChecksForBinOp(), llvm::ConstantInt::get(), llvm::Value::getType(), I, and llvm::CmpInst::ICMP_UGE.

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 83 of file PoisonChecking.cpp.

References assert(), llvm::Value::getType(), and llvm::Type::isIntegerTy().

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)"))
static

Referenced by rewrite().