diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp --- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp @@ -63,6 +63,12 @@ "Use 32-bit pointers for accessing const/local/shared address spaces."), cl::init(false), cl::Hidden); +static cl::opt ExitOnUnreachable( + "nvptx-exit-on-unreachable", + cl::desc( + "Lower 'unreachable' as 'exit' instruction."), + cl::init(true), cl::Hidden); + namespace llvm { void initializeGenericToNVVMLegacyPassPass(PassRegistry &); @@ -403,7 +409,8 @@ addPass(createSROAPass()); } - addPass(createNVPTXLowerUnreachablePass()); + if (ExitOnUnreachable) + addPass(createNVPTXLowerUnreachablePass()); } bool NVPTXPassConfig::addInstSelector() {