From f53d05135e98535543fd8edd1a0d6e5e4078c8cc Mon Sep 17 00:00:00 2001 From: Wolfgang Pieb Date: Tue, 5 Oct 2021 10:28:46 -0700 Subject: [PATCH] [UBSAN][PS4] For the PS4 target, emit the ud2 ocpode for ubsan traps. Reviewed By: probinson Differential Revision: https://reviews.llvm.org/D111172 --- llvm/lib/Target/X86/X86ISelLowering.cpp | 5 ++++- llvm/test/CodeGen/X86/ubsantrap.ll | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 781948d..4c14b43 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 ed9e50b..5d53a5d 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 } -- 2.7.4