From 96f9cc02e31f9d8722eec33f13ddb0f75eb67ccc Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Tue, 4 Mar 2008 19:22:54 +0000 Subject: [PATCH] Use appropriate index to get the result value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47897 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/StructRetPromotion.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp index 2d1ddfb98d8..7ea85493ee8 100644 --- a/lib/Transforms/IPO/StructRetPromotion.cpp +++ b/lib/Transforms/IPO/StructRetPromotion.cpp @@ -302,7 +302,9 @@ void SRETPromotion::updateCallSites(Function *F, Function *NF) { if (C2 && (C2 == Call)) continue; else if (GetElementPtrInst *UGEP = dyn_cast(U2)) { - Value *GR = new GetResultInst(New, 5, "xxx", UGEP); + ConstantInt *Idx = dyn_cast(UGEP->getOperand(2)); + assert (Idx && "Unexpected getelementptr index!"); + Value *GR = new GetResultInst(New, Idx->getZExtValue(), "gr", UGEP); for (Value::use_iterator GI = UGEP->use_begin(), GE = UGEP->use_end(); GI != GE; ++GI) { if (LoadInst *L = dyn_cast(*GI)) {