summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
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
commit77c36d68f3358c77101e0b9ec05a028f8eb70221 (patch)
tree1bdf4b09eb6384b6de1508563c39a9e2141c72a7 /llvm/lib/Analysis
parent4bc256ec9d3946e4938116003b092b243bc00c2a (diff)
downloadbcm5719-llvm-77c36d68f3358c77101e0b9ec05a028f8eb70221.tar.gz
bcm5719-llvm-77c36d68f3358c77101e0b9ec05a028f8eb70221.zip
fix PR5673 by being more careful about pointers to functions.
llvm-svn: 90369
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 96f738edad4..4b0b9a54c77 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/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)
OpenPOWER on IntegriCloud