aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEdwin Török <edwintorok@gmail.com>2008-11-16 17:21:25 +0000
committerEdwin Török <edwintorok@gmail.com>2008-11-16 17:21:25 +0000
commit134c437c9def3d8b904fabf88d79d5f24163ecc9 (patch)
treeb966a62ae626d8ddfdf05ff6dfe781f9db3b4159 /lib
parent9c7d65730d9c332e3039af7e7e7db11d72fe88a7 (diff)
downloadexternal_llvm-134c437c9def3d8b904fabf88d79d5f24163ecc9.zip
external_llvm-134c437c9def3d8b904fabf88d79d5f24163ecc9.tar.gz
external_llvm-134c437c9def3d8b904fabf88d79d5f24163ecc9.tar.bz2
If SI->size() is 0, we are not allowed to dereference ->begin().
This fixed PR3078. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59416 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/IPO/ArgumentPromotion.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp
index d66e2c4..00d06ba 100644
--- a/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -565,9 +565,11 @@ Function *ArgPromotion::DoPromotion(Function *F,
// Add a parameter to the function for each element passed in.
for (ScalarizeTable::iterator SI = ArgIndices.begin(),
E = ArgIndices.end(); SI != E; ++SI) {
+ unsigned num = SI->size();
+ // not allowed to dereference ->begin() if size() is 0
Params.push_back(GetElementPtrInst::getIndexedType(I->getType(),
- &*SI->begin(),
- SI->size()));
+ num ? &*SI->begin(): 0,
+ num));
assert(Params.back());
}