summaryrefslogtreecommitdiff
path: root/lib/Analysis/ConstantFolding.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-03 01:05:45 +0000
committerChris Lattner <sabre@nondot.org>2009-12-03 01:05:45 +0000
commite568fa2d29c58aaedcaa832f805949d5e4371b4b (patch)
tree990914485ae8f999525436152b06e26eb1a843a6 /lib/Analysis/ConstantFolding.cpp
parent35e86af8e5cc76b94690d8e06517b7daa254d314 (diff)
downloadllvm-e568fa2d29c58aaedcaa832f805949d5e4371b4b.tar.gz
llvm-e568fa2d29c58aaedcaa832f805949d5e4371b4b.tar.bz2
llvm-e568fa2d29c58aaedcaa832f805949d5e4371b4b.tar.xz
fix PR5673 by being more careful about pointers to functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90369 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ConstantFolding.cpp')
-rw-r--r--lib/Analysis/ConstantFolding.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp
index 96f738edad..4b0b9a54c7 100644
--- a/lib/Analysis/ConstantFolding.cpp
+++ b/lib/Analysis/ConstantFolding.cpp
@@ -569,9 +569,16 @@ static Constant *SymbolicallyEvaluateGEP(Constant *const *Ops, unsigned NumOps,
SmallVector<Constant*, 32> NewIdxs;
do {
if (const SequentialType *ATy = dyn_cast<SequentialType>(Ty)) {
- // The only pointer indexing we'll do is on the first index of the GEP.
- if (isa<PointerType>(ATy) && !NewIdxs.empty())
- break;
+ if (isa<PointerType>(ATy)) {
+ // The only pointer indexing we'll do is on the first index of the GEP.
+ if (!NewIdxs.empty())
+ break;
+
+ // Only handle pointers to sized types, not pointers to functions.
+ if (!ATy->getElementType()->isSized())
+ return 0;
+ }
+
// Determine which element of the array the offset points into.
APInt ElemSize(BitWidth, TD->getTypeAllocSize(ATy->getElementType()));
if (ElemSize == 0)