summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-07-23 00:34:11 +0000
committerDan Gohman <gohman@apple.com>2008-07-23 00:34:11 +0000
commitfc74abfba5128544a750fce22fdf13eb0403e3ce (patch)
tree36ed972103bbbb170370e4e6688787ed5f1f9ac8 /lib/Transforms/IPO
parent5e6ebaf4d1d3043d3428b65ee8054c71c24af930 (diff)
downloadllvm-fc74abfba5128544a750fce22fdf13eb0403e3ce.tar.gz
llvm-fc74abfba5128544a750fce22fdf13eb0403e3ce.tar.bz2
llvm-fc74abfba5128544a750fce22fdf13eb0403e3ce.tar.xz
Enable first-class aggregates support.
Remove the GetResultInst instruction. It is still accepted in LLVM assembly and bitcode, where it is now auto-upgraded to ExtractValueInst. Also, remove support for return instructions with multiple values. These are auto-upgraded to use InsertValueInst instructions. The IRBuilder still accepts multiple-value returns, and auto-upgrades them to InsertValueInst instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53941 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r--lib/Transforms/IPO/IPConstantPropagation.cpp4
-rw-r--r--lib/Transforms/IPO/StructRetPromotion.cpp24
2 files changed, 6 insertions, 22 deletions
diff --git a/lib/Transforms/IPO/IPConstantPropagation.cpp b/lib/Transforms/IPO/IPConstantPropagation.cpp
index fa004fda1e..42c02e6a45 100644
--- a/lib/Transforms/IPO/IPConstantPropagation.cpp
+++ b/lib/Transforms/IPO/IPConstantPropagation.cpp
@@ -255,9 +255,7 @@ bool IPCP::PropagateConstantReturn(Function &F) {
// Find the index of the retval to replace with
int index = -1;
- if (GetResultInst *GR = dyn_cast<GetResultInst>(Ins))
- index = GR->getIndex();
- else if (ExtractValueInst *EV = dyn_cast<ExtractValueInst>(Ins))
+ if (ExtractValueInst *EV = dyn_cast<ExtractValueInst>(Ins))
if (EV->hasIndices())
index = *EV->idx_begin();
diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp
index 94bf4c6d5f..aa74944850 100644
--- a/lib/Transforms/IPO/StructRetPromotion.cpp
+++ b/lib/Transforms/IPO/StructRetPromotion.cpp
@@ -97,9 +97,6 @@ bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) {
dyn_cast<StructType>(FArgType->getElementType());
assert (STy && "Invalid sret parameter element type");
- if (nestedStructType(STy))
- return false;
-
// Check if it is ok to perform this promotion.
if (isSafeToUpdateAllCallers(F) == false) {
NumRejectedSRETUses++;
@@ -114,25 +111,13 @@ bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) {
NFirstArg->replaceAllUsesWith(TheAlloca);
// [2] Find and replace ret instructions
- SmallVector<Value *,4> RetVals;
for (Function::iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI)
for(BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ) {
Instruction *I = BI;
++BI;
if (isa<ReturnInst>(I)) {
- RetVals.clear();
- for (unsigned idx = 0; idx < STy->getNumElements(); ++idx) {
- SmallVector<Value*, 2> GEPIdx;
- GEPIdx.push_back(ConstantInt::get(Type::Int32Ty, 0));
- GEPIdx.push_back(ConstantInt::get(Type::Int32Ty, idx));
- Value *NGEPI = GetElementPtrInst::Create(TheAlloca, GEPIdx.begin(),
- GEPIdx.end(),
- "mrv.gep", I);
- Value *NV = new LoadInst(NGEPI, "mrv.ld", I);
- RetVals.push_back(NV);
- }
-
- ReturnInst *NR = ReturnInst::Create(&RetVals[0], RetVals.size(), I);
+ Value *NV = new LoadInst(TheAlloca, "mrv.ld", I);
+ ReturnInst *NR = ReturnInst::Create(NV);
I->replaceAllUsesWith(NR);
I->eraseFromParent();
}
@@ -315,7 +300,7 @@ void SRETPromotion::updateCallSites(Function *F, Function *NF) {
ArgAttrsVec.clear();
New->takeName(Call);
- // Update all users of sret parameter to extract value using getresult.
+ // Update all users of sret parameter to extract value using extractvalue.
for (Value::use_iterator UI = FirstCArg->use_begin(),
UE = FirstCArg->use_end(); UI != UE; ) {
User *U2 = *UI++;
@@ -325,7 +310,8 @@ void SRETPromotion::updateCallSites(Function *F, Function *NF) {
else if (GetElementPtrInst *UGEP = dyn_cast<GetElementPtrInst>(U2)) {
ConstantInt *Idx = dyn_cast<ConstantInt>(UGEP->getOperand(2));
assert (Idx && "Unexpected getelementptr index!");
- Value *GR = new GetResultInst(New, Idx->getZExtValue(), "gr", UGEP);
+ Value *GR = ExtractValueInst::Create(New, Idx->getZExtValue(),
+ "evi", UGEP);
for (Value::use_iterator GI = UGEP->use_begin(),
GE = UGEP->use_end(); GI != GE; ++GI) {
if (LoadInst *L = dyn_cast<LoadInst>(*GI)) {