83 StringRef getPassName()
const override;
85 bool isLoweredToTrap(
const UnreachableInst &
I)
const;
89 NVPTXLowerUnreachable(
bool TrapUnreachable,
bool NoTrapAfterNoreturn)
90 : FunctionPass(ID), TrapUnreachable(TrapUnreachable),
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 {
126 return TrapUnreachable;
132bool NVPTXLowerUnreachable::runOnFunction(Function &
F) {
136 if (TrapUnreachable && !NoTrapAfterNoreturn)
139 LLVMContext &
C =
F.getContext();
140 FunctionType *ExitFTy = FunctionType::get(Type::getVoidTy(
C),
false);
147 if (isLoweredToTrap(*unreachableInst))
157 bool NoTrapAfterNoreturn) {
158 return new NVPTXLowerUnreachable(TrapUnreachable, NoTrapAfterNoreturn);
static bool runOnFunction(Function &F, bool PostInlining)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
bool doesNotReturn() const
Determine if the call cannot return.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
bool isNonContinuableTrap() const
Return true if the call is for a noreturn trap intrinsic.
FunctionPass class - This class is used to implement most global optimizations.
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.
StringRef - Represent a constant reference to a string, i.e.
This function has undefined behavior.
@ 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)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto dyn_cast_or_null(const Y &Val)