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 | 64f27e78c4af3b69930b1d05b13b80cb025f4079 (patch) | |
tree | 9990ceed68da5c49c5024ea8608f12bb0bc06438 /lib/Transforms | |
parent | 1e1b16c48515d6d54525ab279e4acb5ddd05c83d (diff) | |
download | external_llvm-64f27e78c4af3b69930b1d05b13b80cb025f4079.zip external_llvm-64f27e78c4af3b69930b1d05b13b80cb025f4079.tar.gz external_llvm-64f27e78c4af3b69930b1d05b13b80cb025f4079.tar.bz2 |
SimplifyCFG: Don't crash when forming a switch bitmap with an undef default value.
Fixes PR13985.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164934 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index a5e4d44..6da791b 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/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; |