mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-12 13:30:51 +00:00
Fix a crash in InstCombine where we could try to truncate a switch comparison to zero width.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231761 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bb6a88c25d
commit
3a3665fd38
@ -2060,7 +2060,8 @@ Instruction *InstCombiner::visitSwitchInst(SwitchInst &SI) {
|
||||
// x86 generates redundant zero-extenstion instructions if the operand is
|
||||
// truncated to i8 or i16.
|
||||
bool TruncCond = false;
|
||||
if (BitWidth > NewWidth && NewWidth >= DL.getLargestLegalIntTypeSize()) {
|
||||
if (NewWidth > 0 && BitWidth > NewWidth &&
|
||||
NewWidth >= DL.getLargestLegalIntTypeSize()) {
|
||||
TruncCond = true;
|
||||
IntegerType *Ty = IntegerType::get(SI.getContext(), NewWidth);
|
||||
Builder->SetInsertPoint(&SI);
|
||||
|
7
test/Transforms/InstCombine/switch-truncate-crash.ll
Normal file
7
test/Transforms/InstCombine/switch-truncate-crash.ll
Normal file
@ -0,0 +1,7 @@
|
||||
; RUN: opt -instcombine < %s
|
||||
|
||||
define void @test() {
|
||||
switch i32 0, label %out [i32 0, label %out]
|
||||
out:
|
||||
ret void
|
||||
}
|
Loading…
Reference in New Issue
Block a user