LLVM 17.0.0git
|
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/CFG.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/CodeGen/RuntimeLibcalls.h"
#include "llvm/CodeGen/StackProtector.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/EHPersonalities.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include <cstddef>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "dwarfehprepare" |
Functions | |
STATISTIC (NumResumesLowered, "Number of resume calls lowered") | |
STATISTIC (NumCleanupLandingPadsUnreachable, "Number of cleanup landing pads found unreachable") | |
STATISTIC (NumCleanupLandingPadsRemaining, "Number of cleanup landing pads remaining") | |
STATISTIC (NumNoUnwind, "Number of functions with nounwind") | |
STATISTIC (NumUnwind, "Number of functions with unwind") | |
static void | addCleanupResumeToLandingPad (BasicBlock &BB, DomTreeUpdater *DTU) |
If a landingpad block doesn't already have a cleanup case, add one that feeds directly into a resume instruction. | |
static BasicBlock * | createCleanupResumeBB (Function &F, Type *LandingPadTy) |
Create a basic block that has a landingpad instruction feeding directly into a resume . | |
static void | changeCallToInvokeResume (CallInst &CI, BasicBlock *CleanupResumeBB, DomTreeUpdater *DTU) |
Convert a call that might throw into an invoke that unwinds to the specified simple landingpad/resume block. | |
static void | addCleanupPathsForStackProtector (Function &F, DomTreeUpdater *DTU) |
Ensure that any call in this function that might throw has an associated cleanup/resume that the stack protector can instrument later. | |
static bool | prepareDwarfEH (CodeGenOpt::Level OptLevel, Function &F, const TargetLowering &TLI, DominatorTree *DT, const TargetTransformInfo *TTI, const Triple &TargetTriple) |
INITIALIZE_PASS_BEGIN (DwarfEHPrepareLegacyPass, DEBUG_TYPE, "Prepare DWARF exceptions", false, false) INITIALIZE_PASS_END(DwarfEHPrepareLegacyPass | |
Variables | |
DEBUG_TYPE | |
Prepare DWARF | exceptions |
Prepare DWARF | false |
#define DEBUG_TYPE "dwarfehprepare" |
Definition at line 47 of file DwarfEHPrepare.cpp.
|
static |
Ensure that any call in this function that might throw has an associated cleanup/resume that the stack protector can instrument later.
Existing invokes will get an added cleanup
clause if needed, calls will be converted to an invoke with trivial unwind followup.
Definition at line 256 of file DwarfEHPrepare.cpp.
References addCleanupResumeToLandingPad(), changeCallToInvokeResume(), createCleanupResumeBB(), llvm::CallBase::doesNotThrow(), F, llvm::BasicBlock::getLandingPadInst(), I, and llvm::CallInst::isTailCall().
|
static |
If a landingpad block doesn't already have a cleanup case, add one that feeds directly into a resume instruction.
Definition at line 174 of file DwarfEHPrepare.cpp.
References llvm::DomTreeUpdater::applyUpdates(), B, llvm::BasicBlock::Create(), llvm::ResumeInst::Create(), llvm::Instruction::eraseFromParent(), F, llvm::ConstantInt::get(), llvm::BasicBlock::getLandingPadInst(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::BasicBlock::getParent(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::LandingPadInst::isCleanup(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::LandingPadInst::setCleanup(), and llvm::SplitBlock().
Referenced by addCleanupPathsForStackProtector().
|
static |
Convert a call that might throw into an invoke that unwinds to the specified simple landingpad/resume block.
Definition at line 226 of file DwarfEHPrepare.cpp.
References llvm::DomTreeUpdater::applyUpdates(), llvm::CallBase::args(), B, llvm::Instruction::copyMetadata(), llvm::Instruction::eraseFromParent(), llvm::CallBase::getAttributes(), llvm::CallBase::getCalledOperand(), llvm::CallBase::getCallingConv(), llvm::CallBase::getFunctionType(), llvm::Value::getName(), llvm::CallBase::getOperandBundlesAsDefs(), llvm::Instruction::getParent(), llvm::BasicBlock::getTerminator(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::Value::replaceAllUsesWith(), llvm::CallBase::setAttributes(), llvm::CallBase::setCallingConv(), and llvm::SplitBlock().
Referenced by addCleanupPathsForStackProtector().
|
static |
Create a basic block that has a landingpad
instruction feeding directly into a resume
.
Will be set to the unwind destination of a new invoke.
Definition at line 207 of file DwarfEHPrepare.cpp.
References B, llvm::BasicBlock::Create(), F, llvm::IntegerType::get(), llvm::StructType::get(), llvm::Type::getInt8PtrTy(), and llvm::LandingPadInst::setCleanup().
Referenced by addCleanupPathsForStackProtector().
INITIALIZE_PASS_BEGIN | ( | DwarfEHPrepareLegacyPass | , |
DEBUG_TYPE | , | ||
"Prepare DWARF exceptions" | , | ||
false | , | ||
false | |||
) |
|
static |
Definition at line 444 of file DwarfEHPrepare.cpp.
References F.
STATISTIC | ( | NumCleanupLandingPadsRemaining | , |
"Number of cleanup landing pads remaining" | |||
) |
STATISTIC | ( | NumCleanupLandingPadsUnreachable | , |
"Number of cleanup landing pads found unreachable" | |||
) |
STATISTIC | ( | NumNoUnwind | , |
"Number of functions with nounwind" | |||
) |
STATISTIC | ( | NumResumesLowered | , |
"Number of resume calls lowered" | |||
) |
DEBUG_TYPE |
Definition at line 507 of file DwarfEHPrepare.cpp.
Prepare DWARF exceptions |
Definition at line 508 of file DwarfEHPrepare.cpp.
Prepare DWARF false |
Definition at line 508 of file DwarfEHPrepare.cpp.