summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2016-12-05 21:40:33 +0000
committerTim Northover <tnorthover@apple.com>2016-12-05 21:40:33 +0000
commit6ad7b9f83712f171acec4d55c3b295c15cb3037c (patch)
tree1a31d75008ecec521f6644623f285f3affddcb17
parentc38860b0d22c205e95f5c80970c6daeec362256f (diff)
downloadbcm5719-llvm-6ad7b9f83712f171acec4d55c3b295c15cb3037c.tar.gz
bcm5719-llvm-6ad7b9f83712f171acec4d55c3b295c15cb3037c.zip
GlobalISel: improve translation fallback for constants.
Returning 0 (NoReg) from getOrCreateVReg leads to unexpected situations later in the translation. It's better to return a valid (if undefined) register and let the rest of the instruction carry on as planned. llvm-svn: 288709
-rw-r--r--llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp2
-rw-r--r--llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll23
2 files changed, 19 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index e8d1ce0586d..a580e745171 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -74,7 +74,7 @@ unsigned IRTranslator::getOrCreateVReg(const Value &Val) {
if (!TPC->isGlobalISelAbortEnabled()) {
MIRBuilder.getMF().getProperties().set(
MachineFunctionProperties::Property::FailedISel);
- return 0;
+ return VReg;
}
reportTranslationError(Val, "unable to translate constant");
}
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll
index d9e8004ceb5..25d6c1f191c 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll
@@ -1,6 +1,8 @@
; RUN: not llc -O0 -global-isel -verify-machineinstrs %s -o - 2>&1 | FileCheck %s --check-prefix=ERROR
; RUN: llc -O0 -global-isel -global-isel-abort=0 -verify-machineinstrs %s -o - 2>&1 | FileCheck %s --check-prefix=FALLBACK
-; RUN: llc -O0 -global-isel -global-isel-abort=2 -verify-machineinstrs %s -o - 2>&1 | FileCheck %s --check-prefix=FALLBACK_WITH_REPORT
+; RUN: llc -O0 -global-isel -global-isel-abort=2 -verify-machineinstrs %s -o %t.out 2> %t.err
+; RUN: FileCheck %s --check-prefix=FALLBACK-WITH-REPORT-OUT < %t.out
+; RUN: FileCheck %s --check-prefix=FALLBACK-WITH-REPORT-ERR < %t.err
; This file checks that the fallback path to selection dag works.
; The test is fragile in the sense that it must be updated to expose
; something that fails with global-isel.
@@ -16,11 +18,22 @@ target triple = "aarch64--"
; FALLBACK: ldr q0,
; FALLBACK-NEXT: bl __fixunstfti
;
-; FALLBACK_WITH_REPORT: warning: Instruction selection used fallback path for ABIi128
-; FALLBACK_WITH_REPORT: ldr q0,
-; FALLBACK_WITH_REPORT-NEXT: bl __fixunstfti
+; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for ABIi128
+; FALLBACK-WITH-REPORT-OUT-LABEL: ABIi128:
+; FALLBACK-WITH-REPORT-OUT: ldr q0,
+; FALLBACK-WITH-REPORT-OUT-NEXT: bl __fixunstfti
define i128 @ABIi128(i128 %arg1) {
- %farg1 = bitcast i128 %arg1 to fp128
+ %farg1 = bitcast i128 %arg1 to fp128
%res = fptoui fp128 %farg1 to i128
ret i128 %res
}
+
+; It happens that we don't handle ConstantArray instances yet during
+; translation. Any other constant would be fine too.
+
+; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for constant
+; FALLBACK-WITH-REPORT-OUT-LABEL: constant:
+; FALLBACK-WITH-REPORT-OUT: fmov d0, #1.0
+define [1 x double] @constant() {
+ ret [1 x double] [double 1.0]
+}
OpenPOWER on IntegriCloud