forked from OSchip/llvm-project
[BOLT] Handle insertion of updated CFI at the first basic block
Summary: Fix corner case of insertion of updated CFI with unset `PrevBB`. Handle it in the same way as inserting past hot-cold split point. (cherry picked from FBD24943911)
This commit is contained in:
parent
1cf23e5ee8
commit
f9d00d418b
|
@ -1576,8 +1576,8 @@ void ShrinkWrapping::insertUpdatedCFI(unsigned CSR, int SPValPush,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Are we at the hot-cold split point?
|
// Are we at the first basic block or hot-cold split point?
|
||||||
if (BF.isSplit() && PrevBB && BB->isCold() != PrevBB->isCold()) {
|
if (!PrevBB || (BF.isSplit() && BB->isCold() != PrevBB->isCold())) {
|
||||||
if (InAffectedZoneAtBegin) {
|
if (InAffectedZoneAtBegin) {
|
||||||
insertCFIsForPushOrPop(*BB, BB->begin(), CSR, true, 0, SPValPush);
|
insertCFIsForPushOrPop(*BB, BB->begin(), CSR, true, 0, SPValPush);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
# This test reproduces the issue with inserting updated CFI in shrink wrapping
|
||||||
|
# into the first basic block.
|
||||||
|
|
||||||
|
# REQUIRES: system-linux
|
||||||
|
|
||||||
|
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
|
||||||
|
# RUN: link_fdata %s %t.o %t.fdata
|
||||||
|
# RUN: strip --strip-unneeded %t.o
|
||||||
|
# RUN: %host_cc %t.o -o %t.exe -Wl,-q -nostdlib
|
||||||
|
# RUN: llvm-bolt %t.exe -o %t.out -data %t.fdata -frame-opt=all -lite=0 \
|
||||||
|
# RUN: -print-fop 2>&1 | FileCheck %s
|
||||||
|
|
||||||
|
# Check shrink wrapping results:
|
||||||
|
# CHECK: BOLT-INFO: Shrink wrapping moved 0 spills inserting load/stores and 1 spills inserting push/pops
|
||||||
|
|
||||||
|
# Check that CFI is successfully inserted into the first basic block:
|
||||||
|
# CHECK: Binary Function "_start" after frame-optimizer
|
||||||
|
# CHECK: .LBB0 (2 instructions, align : 1)
|
||||||
|
# CHECK-NEXT: Entry Point
|
||||||
|
# CHECK: 00000000: !CFI {{.*}}
|
||||||
|
# CHECK-NEXT: 00000000: je .Ltmp{{.*}}
|
||||||
|
|
||||||
|
.globl _start
|
||||||
|
_start:
|
||||||
|
.cfi_startproc
|
||||||
|
# FDATA: 0 [unknown] 0 1 _start 0 0 6
|
||||||
|
# !CFI OpOffset for reg3/rbx is inserted into this block.
|
||||||
|
je a
|
||||||
|
b: jne _start
|
||||||
|
# FDATA: 1 _start #b# 1 _start #c# 0 3
|
||||||
|
|
||||||
|
c:
|
||||||
|
push %rbx
|
||||||
|
.cfi_offset 3, 4
|
||||||
|
pop %rbx
|
||||||
|
|
||||||
|
# This basic block is treated as having 0 execution count.
|
||||||
|
# push and pop will be sinked into this block.
|
||||||
|
a:
|
||||||
|
ud2
|
||||||
|
.cfi_endproc
|
Loading…
Reference in New Issue