[llvm] [CodeGen] Do not emit TRAP for `unreachable` after `@llvm.trap` (PR #94570)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 6 03:15:25 PDT 2024


================
@@ -15,11 +17,19 @@ define i32 @call_exit() noreturn nounwind {
 
 ; CHECK-LABEL: trap:
 ; CHECK: ud2
+; CHECK-NOT: ud2
+define i32 @trap() noreturn nounwind {
+  tail call void @llvm.trap()
+  unreachable
+}
+
+; CHECK-LABEL: trap_fn_attr:
+; CHECK: callq {{_?}}trap_func
 ; TRAP_AFTER_NORETURN: ud2
 ; NO_TRAP_AFTER_NORETURN-NOT: ud2
 ; NORMAL-NOT: ud2
-define i32 @trap() noreturn nounwind {
-  tail call void @llvm.trap()
+define i32 @trap_fn_attr() noreturn nounwind {
+  tail call void @llvm.trap() #0
   unreachable
 }
 
----------------
arsenm wrote:

Test noreturn/not-noreturn indirect call before unreachable? 

https://github.com/llvm/llvm-project/pull/94570


More information about the llvm-commits mailing list