From 4bb928c11010e1ba38b19ee89ac77ed1d096a76a Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 24 Oct 2018 18:10:38 +0000 Subject: ARM: Use BKPT instead of TRAP to implement llvm.debugtrap. The BKPT instruction is specified to cause a software breakpoint, and at least on Linux results in a SIGTRAP. This makes it more suitable for implementing debugtrap than TRAP (aka UDF #254), which is specified to cause an undefined instruction exception and results in a SIGILL on Linux. Moreover, BKPT is not marked as a terminator, which is not only consistent with the IR instruction but allows the analyzeBlock function to correctly analyze a basic block containing the instruction, which fixes an assertion failure in the machine block placement pass previously triggered by the included test case. Because BKPT is only supported starting with ARMv5T, we continue to use UDF #254 when targeting v4T. Differential Revision: https://reviews.llvm.org/D53614 llvm-svn: 345171 --- llvm/test/CodeGen/ARM/debugtrap.ll | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'llvm/test/CodeGen/ARM/debugtrap.ll') diff --git a/llvm/test/CodeGen/ARM/debugtrap.ll b/llvm/test/CodeGen/ARM/debugtrap.ll index 5064a4ec2ca..88ca81c4f2c 100644 --- a/llvm/test/CodeGen/ARM/debugtrap.ll +++ b/llvm/test/CodeGen/ARM/debugtrap.ll @@ -1,7 +1,10 @@ ; This test ensures the @llvm.debugtrap() call is not removed when generating ; the 'pop' instruction to restore the callee saved registers on ARM. -; RUN: llc < %s -mtriple=armv7 -O0 -filetype=asm | FileCheck %s +; RUN: llc < %s -mtriple=armv4 -O0 -filetype=asm | FileCheck --check-prefixes=CHECK,V4 %s +; RUN: llc < %s -mtriple=armv5 -O0 -filetype=asm | FileCheck --check-prefixes=CHECK,V5 %s +; RUN: llc < %s -mtriple=thumbv4 -O0 -filetype=asm | FileCheck --check-prefixes=CHECK,V4 %s +; RUN: llc < %s -mtriple=thumbv5 -O0 -filetype=asm | FileCheck --check-prefixes=CHECK,V5 %s declare void @llvm.debugtrap() nounwind declare void @foo() nounwind @@ -9,8 +12,9 @@ declare void @foo() nounwind define void @test() nounwind { entry: ; CHECK: bl foo + ; V4-NEXT: udf #254 + ; V5-NEXT: bkpt #0 ; CHECK-NEXT: pop - ; CHECK-NEXT: .inst 0xe7ffdefe call void @foo() call void @llvm.debugtrap() ret void -- cgit v1.2.3