Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 9c3d059

Browse files
committed
GlobalISel: fall back gracefully when we hit unhandled legalizer default.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288840 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 3074f79 commit 9c3d059

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/CodeGen/GlobalISel/LegalizerInfo.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ LegalizerInfo::getAction(const InstrAspect &Aspect) const {
9393
if (DefaultAction != DefaultActions.end() && DefaultAction->second == Legal)
9494
return std::make_pair(Legal, Ty);
9595

96-
assert(DefaultAction->second == NarrowScalar && "unexpected default");
96+
if (DefaultAction == DefaultActions.end() ||
97+
DefaultAction->second != NarrowScalar)
98+
return std::make_pair(Unsupported, LLT());
9799
return findLegalAction(Aspect, NarrowScalar);
98100
}
99101

test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,11 @@ define void @odd_type(i42* %addr) {
7474
define void @sequence_mapping([2 x i64] %in) {
7575
ret void
7676
}
77+
78+
; Legalizer was asserting when it enountered an unexpected default action.
79+
; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for legal_default
80+
; FALLBACK-WITH-REPORT-LABEL: legal_default:
81+
define void @legal_default(i64 %in) {
82+
insertvalue [2 x i64] undef, i64 %in, 0
83+
ret void
84+
}

0 commit comments

Comments
 (0)