mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-08 18:31:23 +00:00
Simplify
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48161 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7498f90926
commit
641ca93cff
@ -22,6 +22,7 @@
|
|||||||
#include "llvm/Analysis/CallGraph.h"
|
#include "llvm/Analysis/CallGraph.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include "llvm/Support/CallSite.h"
|
#include "llvm/Support/CallSite.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -531,9 +532,11 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
|
|||||||
unsigned NumRetVals = STy->getNumElements();
|
unsigned NumRetVals = STy->getNumElements();
|
||||||
// Create new phi nodes such that phi node number in the PHIs vector
|
// Create new phi nodes such that phi node number in the PHIs vector
|
||||||
// match corresponding return value operand number.
|
// match corresponding return value operand number.
|
||||||
|
Instruction *InsertPt = AfterCallBB->begin();
|
||||||
for (unsigned i = 0; i < NumRetVals; ++i) {
|
for (unsigned i = 0; i < NumRetVals; ++i) {
|
||||||
PHINode *PHI = new PHINode(STy->getElementType(i),
|
PHINode *PHI = new PHINode(STy->getElementType(i),
|
||||||
TheCall->getName(), AfterCallBB->begin());
|
TheCall->getName() + "." + utostr(i),
|
||||||
|
InsertPt);
|
||||||
PHIs.push_back(PHI);
|
PHIs.push_back(PHI);
|
||||||
}
|
}
|
||||||
// TheCall results are used by GetResult instructions.
|
// TheCall results are used by GetResult instructions.
|
||||||
@ -555,25 +558,19 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
|
|||||||
// appropriate.
|
// appropriate.
|
||||||
if (!PHIs.empty()) {
|
if (!PHIs.empty()) {
|
||||||
const Type *RTy = CalledFunc->getReturnType();
|
const Type *RTy = CalledFunc->getReturnType();
|
||||||
if (const StructType *STy = dyn_cast<StructType>(RTy)) {
|
// There is atleast one return value.
|
||||||
unsigned NumRetVals = STy->getNumElements();
|
unsigned NumRetVals = 1;
|
||||||
for (unsigned j = 0; j < NumRetVals; ++j) {
|
if (const StructType *STy = dyn_cast<StructType>(RTy))
|
||||||
PHINode *PHI = PHIs[j];
|
NumRetVals = STy->getNumElements();
|
||||||
// Each PHI node will receive one value from each return instruction.
|
for (unsigned j = 0; j < NumRetVals; ++j) {
|
||||||
for(unsigned i = 0, e = Returns.size(); i != e; ++i) {
|
PHINode *PHI = PHIs[j];
|
||||||
ReturnInst *RI = Returns[i];
|
// Each PHI node will receive one value from each return instruction.
|
||||||
PHI->addIncoming(RI->getReturnValue(j /*PHI number matches operand number*/),
|
for(unsigned i = 0, e = Returns.size(); i != e; ++i) {
|
||||||
RI->getParent());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
|
|
||||||
ReturnInst *RI = Returns[i];
|
ReturnInst *RI = Returns[i];
|
||||||
assert(PHIs.size() == 1 && "Invalid number of PHI nodes");
|
assert(RI->getReturnValue(j)->getType() == PHI->getType() &&
|
||||||
assert(RI->getReturnValue() && "Ret should have value!");
|
|
||||||
assert(RI->getReturnValue()->getType() == PHIs[0]->getType() &&
|
|
||||||
"Ret value not consistent in function!");
|
"Ret value not consistent in function!");
|
||||||
PHIs[0]->addIncoming(RI->getReturnValue(), RI->getParent());
|
PHI->addIncoming(RI->getReturnValue(j /*PHI number matches operand number*/),
|
||||||
|
RI->getParent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user