89 NVPTXLowerUnreachable(
bool TrapUnreachable,
bool NoTrapAfterNoreturn)
91 NoTrapAfterNoreturn(NoTrapAfterNoreturn) {}
95 bool NoTrapAfterNoreturn;
99char NVPTXLowerUnreachable::ID = 1;
102 "Lower Unreachable",
false,
false)
104StringRef NVPTXLowerUnreachable::getPassName()
const {
105 return "add an exit instruction before every unreachable";
113bool NVPTXLowerUnreachable::isLoweredToTrap(
const UnreachableInst &
I)
const {
114 if (
const auto *Call = dyn_cast_or_null<CallInst>(
I.getPrevNode())) {
116 if (
Call->isNonContinuableTrap())
121 if (NoTrapAfterNoreturn &&
Call->doesNotReturn())
126 return TrapUnreachable;
132bool NVPTXLowerUnreachable::runOnFunction(
Function &
F) {
136 if (TrapUnreachable && !NoTrapAfterNoreturn)
143 bool Changed =
false;
146 if (
auto unreachableInst = dyn_cast<UnreachableInst>(&
I)) {
147 if (isLoweredToTrap(*unreachableInst))
157 bool NoTrapAfterNoreturn) {
158 return new NVPTXLowerUnreachable(TrapUnreachable, NoTrapAfterNoreturn);
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
FunctionPass class - This class is used to implement most global optimizations.
virtual bool runOnFunction(Function &F)=0
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
static LLVM_ABI InlineAsm * get(FunctionType *Ty, StringRef AsmString, StringRef Constraints, bool hasSideEffects, bool isAlignStack=false, AsmDialect asmDialect=AD_ATT, bool canThrow=false)
InlineAsm::get - Return the specified uniqued inline asm string.
This is an important class for using LLVM in a threaded context.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
StringRef - Represent a constant reference to a string, i.e.
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
This function has undefined behavior.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createNVPTXLowerUnreachablePass(bool TrapUnreachable, bool NoTrapAfterNoreturn)