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 (
const auto *Call = dyn_cast_or_null<CallInst>(
I.getPrevNode())) {
120 if (
Call->isNonContinuableTrap())
125 if (NoTrapAfterNoreturn &&
Call->doesNotReturn())
130 return TrapUnreachable;
136bool NVPTXLowerUnreachable::runOnFunction(
Function &
F) {
140 if (TrapUnreachable && !NoTrapAfterNoreturn)
147 bool Changed =
false;
150 if (
auto unreachableInst = dyn_cast<UnreachableInst>(&
I)) {
151 if (isLoweredToTrap(*unreachableInst))
161 bool NoTrapAfterNoreturn) {
162 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 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 &)