From f67e9bb406bc6b2907f069234c8d002ae52181ed Mon Sep 17 00:00:00 2001 From: Torok Edwin Date: Sun, 16 Nov 2008 17:21:25 +0000 Subject: [PATCH] If SI->size() is 0, we are not allowed to dereference ->begin(). This fixed PR3078. llvm-svn: 59416 --- lib/Transforms/IPO/ArgumentPromotion.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index d66e2c46202..00d06bab154 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()); }