Skip to content

Commit f53d051

Browse files
author
Wolfgang Pieb
committed
[UBSAN][PS4] For the PS4 target, emit the ud2 ocpode for ubsan traps.
Reviewed By: probinson Differential Revision: https://reviews.llvm.org/D111172
1 parent fb3d83a commit f53d051

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,10 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
533533

534534
setOperationAction(ISD::TRAP, MVT::Other, Legal);
535535
setOperationAction(ISD::DEBUGTRAP, MVT::Other, Legal);
536-
setOperationAction(ISD::UBSANTRAP, MVT::Other, Legal);
536+
if (Subtarget.getTargetTriple().isPS4CPU())
537+
setOperationAction(ISD::UBSANTRAP, MVT::Other, Expand);
538+
else
539+
setOperationAction(ISD::UBSANTRAP, MVT::Other, Legal);
537540

538541
// VASTART needs to be custom lowered to use the VarArgsFrameIndex
539542
setOperationAction(ISD::VASTART , MVT::Other, Custom);

llvm/test/CodeGen/X86/ubsantrap.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
; RUN: llc -mtriple=x86_64-linux-gnu %s -o - | FileCheck %s
2+
; RUN: llc -mtriple=x86_64-scei-ps4 %s -o - | FileCheck --check-prefix=PS4 %s
23

34
define void @test_ubsantrap() {
45
; CHECK-LABEL: test_ubsantrap
56
; CHECK: ud1l 12(%eax), %eax
7+
; PS4-LABEL: test_ubsantrap
8+
; PS4-NOT: ud1
9+
; PS4: ud2
610
call void @llvm.ubsantrap(i8 12)
711
ret void
812
}

0 commit comments

Comments
 (0)