From bfa25bd1aca993e36222aec4b400bdeff37355ec Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Tue, 6 Sep 2016 04:00:12 +0000 Subject: [PATCH] ARM: workaround bundled operation predication This is a Windows ARM specific issue. If the code path in the if conversion ends up using a relocation which will form a IMAGE_REL_ARM_MOV32T, we end up with a bundle to ensure that the mov.w/mov.t pair is not split up. This is normally fine, however, if the branch is also predicated, then we end up trying to predicate the bundle. For now, report a bundle as being unpredicatable. Although this is false, this would trigger a failure case previously anyways, so this is no worse. That is, there should not be any code which would previously have been if converted and predicated which would not be now. Under certain circumstances, it may be possible to "predicate the bundle". This would require scanning all bundle instructions, and ensure that the bundle contains only predicatable instructions, and converting the bundle into an IT block sequence. If the bundle is larger than the maximal IT block length (4 instructions), it would require materializing multiple IT blocks from the single bundle. llvm-svn: 280689 --- llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp | 3 +++ llvm/test/CodeGen/ARM/Windows/if-cvt-bundle.ll | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 llvm/test/CodeGen/ARM/Windows/if-cvt-bundle.ll diff --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp index 9e0a499..f687523 100644 --- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp +++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp @@ -575,6 +575,9 @@ bool ARMBaseInstrInfo::isPredicable(MachineInstr &MI) const { if (!MI.isPredicable()) return false; + if (MI.isBundle()) + return false; + if (!isEligibleForITBlock(&MI)) return false; diff --git a/llvm/test/CodeGen/ARM/Windows/if-cvt-bundle.ll b/llvm/test/CodeGen/ARM/Windows/if-cvt-bundle.ll new file mode 100644 index 0000000..5521ed7 --- /dev/null +++ b/llvm/test/CodeGen/ARM/Windows/if-cvt-bundle.ll @@ -0,0 +1,24 @@ +; RUN: llc -mtriple thumbv7--windows-itanium -filetype asm -o - %s | FileCheck %s + +declare void @llvm.trap() +declare arm_aapcs_vfpcc zeroext i1 @g() + +define arm_aapcs_vfpcc i8* @f() { +entry: + %call = tail call arm_aapcs_vfpcc zeroext i1 @g() + br i1 %call, label %if.then, label %if.end + +if.then: + ret i8* bitcast (i1 ()* @g to i8*) + +if.end: + tail call void @llvm.trap() + unreachable +} + +; CHECK: push.w {r11, lr} +; CHECK: bl g +; CHECK: movw [[REG:r[0-9]+]], :lower16:g +; CHECK: movt [[REG]], :upper16:g +; CHECK: pop.w {r11, pc} + -- 2.7.4