diff --git a/llvm/lib/CodeGen/TypePromotion.cpp b/llvm/lib/CodeGen/TypePromotion.cpp --- a/llvm/lib/CodeGen/TypePromotion.cpp +++ b/llvm/lib/CodeGen/TypePromotion.cpp @@ -539,8 +539,8 @@ I->setOperand(i, UndefValue::get(ExtTy)); } - // Mutate the result type, unless this is an icmp. - if (!isa(I)) { + // Mutate the result type, unless this is an icmp or switch. + if (!isa(I) && !isa(I)) { I->mutateType(ExtTy); Promoted.insert(I); } diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -2691,6 +2691,7 @@ } void Verifier::visitSwitchInst(SwitchInst &SI) { + Assert(SI.getType()->isVoidTy(), "Switch must have void result type!", &SI); // Check to make sure that all of the constants in the switch instruction // have the same type as the switched-on value. Type *SwitchTy = SI.getCondition()->getType();