LLVM 22.0.0git
SafeStack.cpp File Reference
#include "llvm/CodeGen/SafeStack.h"
#include "SafeStackLayout.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/InlineCost.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/Analysis/StackLifetime.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
#include "llvm/IR/Value.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Local.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <optional>
#include <string>
#include <utility>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "safe-stack"

Functions

 STATISTIC (NumFunctions, "Total number of functions")
 STATISTIC (NumUnsafeStackFunctions, "Number of functions with unsafe stack")
 STATISTIC (NumUnsafeStackRestorePointsFunctions, "Number of functions that use setjmp or exceptions")
 STATISTIC (NumAllocas, "Total number of allocas")
 STATISTIC (NumUnsafeStaticAllocas, "Number of unsafe static allocas")
 STATISTIC (NumUnsafeDynamicAllocas, "Number of unsafe dynamic allocas")
 STATISTIC (NumUnsafeByValArguments, "Number of unsafe byval arguments")
 STATISTIC (NumUnsafeStackRestorePoints, "Number of setjmps and landingpads")
 INITIALIZE_PASS_BEGIN (SafeStackLegacyPass, DEBUG_TYPE, "Safe Stack instrumentation pass", false, false) INITIALIZE_PASS_END(SafeStackLegacyPass

Variables

static cl::opt< boolSafeStackUsePointerAddress ("safestack-use-pointer-address", cl::init(false), cl::Hidden)
 Use __safestack_pointer_address even if the platform has a faster way of access safe stack pointer.
static cl::opt< boolClColoring ("safe-stack-coloring", cl::desc("enable safe stack coloring"), cl::Hidden, cl::init(true))
 DEBUG_TYPE
Safe Stack instrumentation pass
Safe Stack instrumentation false

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "safe-stack"

Definition at line 77 of file SafeStack.cpp.

Function Documentation

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( SafeStackLegacyPass ,
DEBUG_TYPE ,
"Safe Stack instrumentation pass" ,
false ,
false  )

◆ STATISTIC() [1/8]

STATISTIC ( NumAllocas ,
"Total number of allocas"  )

◆ STATISTIC() [2/8]

STATISTIC ( NumFunctions ,
"Total number of functions"  )

◆ STATISTIC() [3/8]

STATISTIC ( NumUnsafeByValArguments ,
"Number of unsafe byval arguments"  )

◆ STATISTIC() [4/8]

STATISTIC ( NumUnsafeDynamicAllocas ,
"Number of unsafe dynamic allocas"  )

◆ STATISTIC() [5/8]

STATISTIC ( NumUnsafeStackFunctions ,
"Number of functions with unsafe stack"  )

◆ STATISTIC() [6/8]

STATISTIC ( NumUnsafeStackRestorePoints ,
"Number of setjmps and landingpads"  )

◆ STATISTIC() [7/8]

STATISTIC ( NumUnsafeStackRestorePointsFunctions ,
"Number of functions that use setjmp or exceptions"  )

◆ STATISTIC() [8/8]

STATISTIC ( NumUnsafeStaticAllocas ,
"Number of unsafe static allocas"  )

Variable Documentation

◆ ClColoring

cl::opt< bool > ClColoring("safe-stack-coloring", cl::desc("enable safe stack coloring"), cl::Hidden, cl::init(true)) ( "safe-stack-coloring" ,
cl::desc("enable safe stack coloring") ,
cl::Hidden ,
cl::init(true)  )
static

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 990 of file SafeStack.cpp.

◆ false

Safe Stack instrumentation false

Definition at line 991 of file SafeStack.cpp.

◆ pass

Safe Stack instrumentation pass

Definition at line 991 of file SafeStack.cpp.

◆ SafeStackUsePointerAddress

cl::opt< bool > SafeStackUsePointerAddress("safestack-use-pointer-address", cl::init(false), cl::Hidden) ( "safestack-use-pointer-address" ,
cl::init(false) ,
cl::Hidden  )
static

Use __safestack_pointer_address even if the platform has a faster way of access safe stack pointer.