Index: lib/Target/ARM/ARMTargetMachine.cpp =================================================================== --- lib/Target/ARM/ARMTargetMachine.cpp +++ lib/Target/ARM/ARMTargetMachine.cpp @@ -74,6 +74,10 @@ EnableGlobalMerge("arm-global-merge", cl::Hidden, cl::desc("Enable the global merge pass")); +static cl::opt EnableTrapUnreachable("arm-trap-unreachable", + cl::Hidden, cl::ZeroOrMore, cl::init(false), + cl::desc("Enable generating trap for unreachable")); + namespace llvm { void initializeARMExecutionDomainFixPass(PassRegistry&); } @@ -238,6 +242,9 @@ this->Options.EABIVersion = EABI::EABI5; } + if (EnableTrapUnreachable) + this->Options.TrapUnreachable = true; + initAsmInfo(); } Index: test/CodeGen/ARM/trap-unreachable.ll =================================================================== --- /dev/null +++ test/CodeGen/ARM/trap-unreachable.ll @@ -0,0 +1,8 @@ +; RUN: llc -mtriple=thumbv7 -arm-trap-unreachable < %s | FileCheck %s +; CHECK: .inst.n 0xdefe + +define void @test() #0 { + unreachable +} + +attributes #0 = { nounwind }