93 NVPTXLowerUnreachable(
bool TrapUnreachable,
bool NoTrapAfterNoreturn)
95 NoTrapAfterNoreturn(NoTrapAfterNoreturn) {}
99 bool NoTrapAfterNoreturn;
103char NVPTXLowerUnreachable::ID = 1;
106 "Lower Unreachable",
false,
false)
108StringRef NVPTXLowerUnreachable::getPassName()
const {
109 return "add an exit instruction before every unreachable";
117bool NVPTXLowerUnreachable::isLoweredToTrap(
const UnreachableInst &
I)
const {
118 if (!TrapUnreachable)
120 if (!NoTrapAfterNoreturn)
122 const CallInst *
Call = dyn_cast_or_null<CallInst>(
I.getPrevNode());
123 return Call &&
Call->doesNotReturn();
129bool NVPTXLowerUnreachable::runOnFunction(
Function &
F) {
133 if (TrapUnreachable && !NoTrapAfterNoreturn)
140 bool Changed =
false;
143 if (
auto unreachableInst = dyn_cast<UnreachableInst>(&
I)) {
144 if (isLoweredToTrap(*unreachableInst))
154 bool NoTrapAfterNoreturn) {
155 return new NVPTXLowerUnreachable(TrapUnreachable, NoTrapAfterNoreturn);
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This class represents a function call, abstracting a target machine's calling convention.
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 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.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
StringRef - Represent a constant reference to a string, i.e.
static Type * getVoidTy(LLVMContext &C)
This function has undefined behavior.
@ C
The default llvm calling convention, compatible with C.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createNVPTXLowerUnreachablePass(bool TrapUnreachable, bool NoTrapAfterNoreturn)
void initializeNVPTXLowerUnreachablePass(PassRegistry &)