Commit 5b004e30 by Karl Schimpf

Fix textual emission of label instructions in ARM assembler.

The integrated ARM assembler was incorrectly assuming that an (instruction) label defines a corresponding assembler instruction. Therefore, placement into the buffer was incorrect. This CL fixes this mistake. This fixes assembler translator problems with ARM branch, movw, and movt instructions. BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334 R=stichnot@chromium.org Review URL: https://codereview.chromium.org/1430973003 .
parent 37af5b0f
......@@ -842,8 +842,6 @@ void InstARM32Br::emit(const Cfg *Func) const {
}
void InstARM32Br::emitIAS(const Cfg *Func) const {
if (!Func->getContext()->getFlags().getAllowUnsafeIas())
return emitUsingTextFixup(Func);
auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
if (Label) {
Asm->b(Asm->getOrCreateLocalLabel(Label->getNumber()), getPredicate());
......@@ -923,6 +921,10 @@ void InstARM32Call::dump(const Cfg *Func) const {
void InstARM32Label::emit(const Cfg *Func) const {
if (!BuildDefs::dump())
return;
// A label is not really an instruction. Hence, we need to fix the
// emitted text size.
if (auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>())
Asm->decEmitTextSize(InstSize);
Ostream &Str = Func->getContext()->getStrEmit();
Str << getName(Func) << ":";
}
......@@ -1025,8 +1027,6 @@ template <> void InstARM32Movw::emit(const Cfg *Func) const {
}
template <> void InstARM32Movw::emitIAS(const Cfg *Func) const {
if (!Func->getContext()->getFlags().getAllowUnsafeIas())
return emitUsingTextFixup(Func);
assert(getSrcSize() == 1);
auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->movw(getDest(), getSrc(0), getPredicate());
......@@ -1053,8 +1053,6 @@ template <> void InstARM32Movt::emit(const Cfg *Func) const {
}
template <> void InstARM32Movt::emitIAS(const Cfg *Func) const {
if (!Func->getContext()->getFlags().getAllowUnsafeIas())
return emitUsingTextFixup(Func);
assert(getSrcSize() == 2);
auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->movt(getDest(), getSrc(1), getPredicate());
......
......@@ -12,12 +12,12 @@
; RUN: --args -Om1 | FileCheck %s --check-prefix=DIS
; Compile using integrated assembler.
; RUN: %p2i --filetype=iasm -i %s --target=arm32 --args -Om1 -unsafe-ias \
; RUN: %p2i --filetype=iasm -i %s --target=arm32 --args -Om1 \
; RUN: | FileCheck %s --check-prefix=IASM
; Show bytes in assembled integrated code.
; RUN: %p2i --filetype=iasm -i %s --target=arm32 --assemble --disassemble \
; RUN: --args -Om1 -unsafe-ias | FileCheck %s --check-prefix=DIS
; RUN: --args -Om1 | FileCheck %s --check-prefix=DIS
define internal void @simple_uncond_branch() {
; DIS-LABEL: 00000000 <simple_uncond_branch>:
......
......@@ -11,12 +11,12 @@
; RUN: --args -O2 | FileCheck %s --check-prefix=DIS
; Compile using integrated assembler.
; RUN: %p2i --filetype=iasm -i %s --target=arm32 --args -O2 -unsafe-ias \
; RUN: %p2i --filetype=iasm -i %s --target=arm32 --args -O2 \
; RUN: | FileCheck %s --check-prefix=IASM
; Show bytes in assembled integrated code.
; RUN: %p2i --filetype=iasm -i %s --target=arm32 --assemble --disassemble \
; RUN: --args -O2 -unsafe-ias | FileCheck %s --check-prefix=DIS
; RUN: --args -O2 | FileCheck %s --check-prefix=DIS
@filler = internal global [128 x i8] zeroinitializer, align 4
......
......@@ -14,11 +14,11 @@
; Compile using integrated assembler.
; RUN: %p2i --filetype=iasm -i %s --target=arm32 --args -O2 -mattr=hwdiv-arm \
; RUN: -unsafe-ias | FileCheck %s --check-prefix=IASM
; RUN: | FileCheck %s --check-prefix=IASM
; Show bytes in assembled integrated code.
; RUN: %p2i --filetype=iasm -i %s --target=arm32 --assemble --disassemble \
; RUN: --args -O2 -mattr=hwdiv-arm -unsafe-ias \
; RUN: --args -O2 -mattr=hwdiv-arm \
; RUN: | FileCheck %s --check-prefix=DIS
define internal i32 @SdivTwoRegs(i32 %a, i32 %b) {
......
......@@ -14,11 +14,11 @@
; Compile using integrated assembler.
; RUN: %p2i --filetype=iasm -i %s --target=arm32 --args -O2 -mattr=hwdiv-arm \
; RUN: -unsafe-ias | FileCheck %s --check-prefix=IASM
; RUN: | FileCheck %s --check-prefix=IASM
; Show bytes in assembled integrated code.
; RUN: %p2i --filetype=iasm -i %s --target=arm32 --assemble --disassemble \
; RUN: --args -O2 -mattr=hwdiv-arm -unsafe-ias \
; RUN: --args -O2 -mattr=hwdiv-arm \
; RUN: | FileCheck %s --check-prefix=DIS
define internal i32 @UdivTwoRegs(i32 %a, i32 %b) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment