diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -533,7 +533,10 @@ 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 --- 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 }