[llvm] f53d051 - [UBSAN][PS4] For the PS4 target, emit the ud2 ocpode for ubsan traps.

Wolfgang Pieb via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 6 11:49:47 PDT 2021


Author: Wolfgang Pieb
Date: 2021-10-06T11:49:36-07:00
New Revision: f53d05135e98535543fd8edd1a0d6e5e4078c8cc

URL: https://github.com/llvm/llvm-project/commit/f53d05135e98535543fd8edd1a0d6e5e4078c8cc
DIFF: https://github.com/llvm/llvm-project/commit/f53d05135e98535543fd8edd1a0d6e5e4078c8cc.diff

LOG: [UBSAN][PS4] For the PS4 target, emit the ud2 ocpode for ubsan traps.

Reviewed By: probinson

Differential Revision: https://reviews.llvm.org/D111172

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86ISelLowering.cpp
    llvm/test/CodeGen/X86/ubsantrap.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 781948dc1c6c..4c14b43b5079 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -533,7 +533,10 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
 
   setOperationAction(ISD::TRAP, MVT::Other, Legal);
   setOperationAction(ISD::DEBUGTRAP, MVT::Other, Legal);
-  setOperationAction(ISD::UBSANTRAP, MVT::Other, Legal);
+  if (Subtarget.getTargetTriple().isPS4CPU())
+    setOperationAction(ISD::UBSANTRAP, MVT::Other, Expand);
+  else
+    setOperationAction(ISD::UBSANTRAP, MVT::Other, Legal);
 
   // VASTART needs to be custom lowered to use the VarArgsFrameIndex
   setOperationAction(ISD::VASTART           , MVT::Other, Custom);

diff  --git a/llvm/test/CodeGen/X86/ubsantrap.ll b/llvm/test/CodeGen/X86/ubsantrap.ll
index ed9e50bc7caf..5d53a5d5fc14 100644
--- a/llvm/test/CodeGen/X86/ubsantrap.ll
+++ b/llvm/test/CodeGen/X86/ubsantrap.ll
@@ -1,8 +1,12 @@
 ; RUN: llc -mtriple=x86_64-linux-gnu %s -o - | FileCheck %s
+; RUN: llc -mtriple=x86_64-scei-ps4 %s -o - | FileCheck --check-prefix=PS4 %s
 
 define void @test_ubsantrap() {
 ; CHECK-LABEL: test_ubsantrap
 ; CHECK: ud1l 12(%eax), %eax
+; PS4-LABEL: test_ubsantrap
+; PS4-NOT:   ud1
+; PS4:       ud2
   call void @llvm.ubsantrap(i8 12)
   ret void
 }


        


More information about the llvm-commits mailing list