diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-01 11:31:48 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-01 11:31:48 +0000 |
commit | 9fc3dc77814c557c5dc3405a1952435f44035ed3 (patch) | |
tree | 51fbcfecd0c4136e12f7d03bddd62f89909269f5 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 82a57543d6d610713c56e8e7ce8c73ca810c39eb (diff) | |
download | bcm5719-llvm-9fc3dc77814c557c5dc3405a1952435f44035ed3.tar.gz bcm5719-llvm-9fc3dc77814c557c5dc3405a1952435f44035ed3.zip |
SimplifyCFG: Don't crash when forming a switch bitmap with an undef default value.
Fixes PR13985.
llvm-svn: 164934
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index a5e4d44b85e..6da791bb1cb 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -3351,8 +3351,11 @@ SwitchLookupTable::SwitchLookupTable(Module &M, APInt TableInt(TableSize * IT->getBitWidth(), 0); for (uint64_t I = TableSize; I > 0; --I) { TableInt <<= IT->getBitWidth(); - ConstantInt *Val = cast<ConstantInt>(TableContents[I - 1]); - TableInt |= Val->getValue().zext(TableInt.getBitWidth()); + // Insert values into the bitmap. Undef values are set to zero. + if (!isa<UndefValue>(TableContents[I - 1])) { + ConstantInt *Val = cast<ConstantInt>(TableContents[I - 1]); + TableInt |= Val->getValue().zext(TableInt.getBitWidth()); + } } BitMap = ConstantInt::get(M.getContext(), TableInt); BitMapElementTy = IT; |