Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bolt/include/bolt/Core/BinaryFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,11 @@ class BinaryFunction {
Offset = I->first;
}
assert(I->first == Offset && "CFI pointing to unknown instruction");
if (I == Instructions.begin()) {
// When dealing with RememberState, we place this CFI in FrameInstructions.
// We want to ensure RememberState and RestoreState CFIs are in the same
// list in order to properly populate the StateStack.
if (I == Instructions.begin() &&
Inst.getOperation() != MCCFIInstruction::OpRememberState) {
CIEFrameInstructions.emplace_back(std::forward<MCCFIInstruction>(Inst));
return;
}
Expand Down
34 changes: 34 additions & 0 deletions bolt/test/AArch64/cfi-state-list.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This test checks that BOLT does not split remember and restore CFI states
// into different lists, which would cause an assertion failure.

# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s

# CHECK: BOLT-INFO: Starting stub-insertion pass

.text
.global main
.type main, %function

main:
.cfi_startproc
.cfi_remember_state
mov w0, wzr
b.ne .L1
.L0:
mov w0, wzr
.L1:
cmp x0, #0
b.lt .L2
.L2:
nop
.cfi_restore_state
mov x8, xzr
b.ls .L0
ret
.cfi_endproc
.size main, .-main

## Force relocation mode.
.reloc 0, R_AARCH64_NONE
Loading