mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-13 08:26:02 +00:00
ARMEB: Fix byte order of EH frame unwinding instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208689 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1137,8 +1137,11 @@ void ARMELFStreamer::emitFnEnd() {
|
|||||||
"Compact model must use __aeabi_cpp_unwind_pr0 as personality");
|
"Compact model must use __aeabi_cpp_unwind_pr0 as personality");
|
||||||
assert(Opcodes.size() == 4u &&
|
assert(Opcodes.size() == 4u &&
|
||||||
"Unwind opcode size for __aeabi_cpp_unwind_pr0 must be equal to 4");
|
"Unwind opcode size for __aeabi_cpp_unwind_pr0 must be equal to 4");
|
||||||
EmitBytes(StringRef(reinterpret_cast<const char*>(Opcodes.data()),
|
uint64_t Intval = Opcodes[0] |
|
||||||
Opcodes.size()));
|
Opcodes[1] << 8 |
|
||||||
|
Opcodes[2] << 16 |
|
||||||
|
Opcodes[3] << 24;
|
||||||
|
EmitIntValue(Intval, Opcodes.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch to the section containing FnStart
|
// Switch to the section containing FnStart
|
||||||
@@ -1210,8 +1213,15 @@ void ARMELFStreamer::FlushUnwindOpcodes(bool NoHandlerData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Emit unwind opcodes
|
// Emit unwind opcodes
|
||||||
EmitBytes(StringRef(reinterpret_cast<const char *>(Opcodes.data()),
|
assert((Opcodes.size() % 4) == 0 &&
|
||||||
Opcodes.size()));
|
"Unwind opcode size for __aeabi_cpp_unwind_pr0 must be multiple of 4");
|
||||||
|
for (unsigned I = 0; I != Opcodes.size(); I += 4) {
|
||||||
|
uint64_t Intval = Opcodes[I] |
|
||||||
|
Opcodes[I + 1] << 8 |
|
||||||
|
Opcodes[I + 2] << 16 |
|
||||||
|
Opcodes[I + 3] << 24;
|
||||||
|
EmitIntValue(Intval, 4);
|
||||||
|
}
|
||||||
|
|
||||||
// According to ARM EHABI section 9.2, if the __aeabi_unwind_cpp_pr1() or
|
// According to ARM EHABI section 9.2, if the __aeabi_unwind_cpp_pr1() or
|
||||||
// __aeabi_unwind_cpp_pr2() is used, then the handler data must be emitted
|
// __aeabi_unwind_cpp_pr2() is used, then the handler data must be emitted
|
||||||
|
73
test/CodeGen/ARM/big-endian-eh-unwind.ll
Normal file
73
test/CodeGen/ARM/big-endian-eh-unwind.ll
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
; RUN: llc -march armeb -mattr v7 -filetype obj -o - %s | llvm-objdump -s - | FileCheck %s
|
||||||
|
|
||||||
|
; ARM EHABI for big endian
|
||||||
|
; This test case checks whether frame unwinding instructions are laid out in big endian format.
|
||||||
|
;
|
||||||
|
; This is the LLVM assembly generated from following C++ code:
|
||||||
|
;
|
||||||
|
; extern void foo(int);
|
||||||
|
; void test(int a, int b) {
|
||||||
|
; try {
|
||||||
|
; foo(a);
|
||||||
|
; } catch (...) {
|
||||||
|
; foo(b);
|
||||||
|
; }
|
||||||
|
;}
|
||||||
|
|
||||||
|
define void @_Z4testii(i32 %a, i32 %b) #0 {
|
||||||
|
entry:
|
||||||
|
invoke void @_Z3fooi(i32 %a)
|
||||||
|
to label %try.cont unwind label %lpad
|
||||||
|
|
||||||
|
lpad: ; preds = %entry
|
||||||
|
%0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
|
||||||
|
catch i8* null
|
||||||
|
%1 = extractvalue { i8*, i32 } %0, 0
|
||||||
|
%2 = tail call i8* @__cxa_begin_catch(i8* %1) #2
|
||||||
|
invoke void @_Z3fooi(i32 %b)
|
||||||
|
to label %invoke.cont2 unwind label %lpad1
|
||||||
|
|
||||||
|
invoke.cont2: ; preds = %lpad
|
||||||
|
tail call void @__cxa_end_catch()
|
||||||
|
br label %try.cont
|
||||||
|
|
||||||
|
try.cont: ; preds = %entry, %invoke.cont2
|
||||||
|
ret void
|
||||||
|
|
||||||
|
lpad1: ; preds = %lpad
|
||||||
|
%3 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
|
||||||
|
cleanup
|
||||||
|
invoke void @__cxa_end_catch()
|
||||||
|
to label %eh.resume unwind label %terminate.lpad
|
||||||
|
|
||||||
|
eh.resume: ; preds = %lpad1
|
||||||
|
resume { i8*, i32 } %3
|
||||||
|
|
||||||
|
terminate.lpad: ; preds = %lpad1
|
||||||
|
%4 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
|
||||||
|
catch i8* null
|
||||||
|
%5 = extractvalue { i8*, i32 } %4, 0
|
||||||
|
tail call void @__clang_call_terminate(i8* %5) #3
|
||||||
|
unreachable
|
||||||
|
}
|
||||||
|
|
||||||
|
declare void @_Z3fooi(i32) #0
|
||||||
|
|
||||||
|
declare i32 @__gxx_personality_v0(...)
|
||||||
|
|
||||||
|
declare i8* @__cxa_begin_catch(i8*)
|
||||||
|
|
||||||
|
declare void @__cxa_end_catch()
|
||||||
|
|
||||||
|
; Function Attrs: noinline noreturn nounwind
|
||||||
|
define linkonce_odr hidden void @__clang_call_terminate(i8*) #1 {
|
||||||
|
%2 = tail call i8* @__cxa_begin_catch(i8* %0) #2
|
||||||
|
tail call void @_ZSt9terminatev() #3
|
||||||
|
unreachable
|
||||||
|
}
|
||||||
|
|
||||||
|
declare void @_ZSt9terminatev()
|
||||||
|
|
||||||
|
; CHECK-LABEL: Contents of section .ARM.extab:
|
||||||
|
; CHECK-NEXT: 0000 00000000 00b0b0b0
|
||||||
|
|
Reference in New Issue
Block a user