forked from OSchip/llvm-project
- new SROA mallocs should have the mallocs running-or'ed, not the malloc's bitcast
- fix ProcessInternalGlobal() debug output llvm-svn: 86317
This commit is contained in:
parent
e04ed0c68f
commit
bde558c536
|
@ -1296,14 +1296,16 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, CallInst *CI,
|
||||||
FieldGlobals.push_back(NGV);
|
FieldGlobals.push_back(NGV);
|
||||||
|
|
||||||
unsigned TypeSize = TD->getTypeAllocSize(FieldTy);
|
unsigned TypeSize = TD->getTypeAllocSize(FieldTy);
|
||||||
if (const StructType* ST = dyn_cast<StructType>(FieldTy))
|
if (const StructType *ST = dyn_cast<StructType>(FieldTy))
|
||||||
TypeSize = TD->getStructLayout(ST)->getSizeInBytes();
|
TypeSize = TD->getStructLayout(ST)->getSizeInBytes();
|
||||||
const Type* IntPtrTy = TD->getIntPtrType(CI->getContext());
|
const Type *IntPtrTy = TD->getIntPtrType(CI->getContext());
|
||||||
Value *NMI = CallInst::CreateMalloc(CI, IntPtrTy, FieldTy,
|
Value *NMI = CallInst::CreateMalloc(CI, IntPtrTy, FieldTy,
|
||||||
ConstantInt::get(IntPtrTy, TypeSize),
|
ConstantInt::get(IntPtrTy, TypeSize),
|
||||||
NElems,
|
NElems,
|
||||||
CI->getName() + ".f" + Twine(FieldNo));
|
CI->getName() + ".f" + Twine(FieldNo));
|
||||||
FieldMallocs.push_back(NMI);
|
CallInst *NCI = dyn_cast<BitCastInst>(NMI) ?
|
||||||
|
extractMallocCallFromBitCast(NMI) : cast<CallInst>(NMI);
|
||||||
|
FieldMallocs.push_back(NCI);
|
||||||
new StoreInst(NMI, NGV, CI);
|
new StoreInst(NMI, NGV, CI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1530,8 +1532,7 @@ static bool TryToOptimizeStoreOfMallocToGlobal(GlobalVariable *GV,
|
||||||
CI->replaceAllUsesWith(Cast);
|
CI->replaceAllUsesWith(Cast);
|
||||||
CI->eraseFromParent();
|
CI->eraseFromParent();
|
||||||
CI = dyn_cast<BitCastInst>(Malloc) ?
|
CI = dyn_cast<BitCastInst>(Malloc) ?
|
||||||
extractMallocCallFromBitCast(Malloc):
|
extractMallocCallFromBitCast(Malloc) : cast<CallInst>(Malloc);
|
||||||
cast<CallInst>(Malloc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GVI = PerformHeapAllocSRoA(GV, CI, getMallocArraySize(CI, TD), TD);
|
GVI = PerformHeapAllocSRoA(GV, CI, getMallocArraySize(CI, TD), TD);
|
||||||
|
@ -1688,24 +1689,26 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV,
|
||||||
|
|
||||||
if (!AnalyzeGlobal(GV, GS, PHIUsers)) {
|
if (!AnalyzeGlobal(GV, GS, PHIUsers)) {
|
||||||
#if 0
|
#if 0
|
||||||
cerr << "Global: " << *GV;
|
DEBUG(errs() << "Global: " << *GV);
|
||||||
cerr << " isLoaded = " << GS.isLoaded << "\n";
|
DEBUG(errs() << " isLoaded = " << GS.isLoaded << "\n");
|
||||||
cerr << " StoredType = ";
|
DEBUG(errs() << " StoredType = ");
|
||||||
switch (GS.StoredType) {
|
switch (GS.StoredType) {
|
||||||
case GlobalStatus::NotStored: cerr << "NEVER STORED\n"; break;
|
case GlobalStatus::NotStored: DEBUG(errs() << "NEVER STORED\n"); break;
|
||||||
case GlobalStatus::isInitializerStored: cerr << "INIT STORED\n"; break;
|
case GlobalStatus::isInitializerStored: DEBUG(errs() << "INIT STORED\n");
|
||||||
case GlobalStatus::isStoredOnce: cerr << "STORED ONCE\n"; break;
|
break;
|
||||||
case GlobalStatus::isStored: cerr << "stored\n"; break;
|
case GlobalStatus::isStoredOnce: DEBUG(errs() << "STORED ONCE\n"); break;
|
||||||
|
case GlobalStatus::isStored: DEBUG(errs() << "stored\n"); break;
|
||||||
}
|
}
|
||||||
if (GS.StoredType == GlobalStatus::isStoredOnce && GS.StoredOnceValue)
|
if (GS.StoredType == GlobalStatus::isStoredOnce && GS.StoredOnceValue)
|
||||||
cerr << " StoredOnceValue = " << *GS.StoredOnceValue << "\n";
|
DEBUG(errs() << " StoredOnceValue = " << *GS.StoredOnceValue << "\n");
|
||||||
if (GS.AccessingFunction && !GS.HasMultipleAccessingFunctions)
|
if (GS.AccessingFunction && !GS.HasMultipleAccessingFunctions)
|
||||||
cerr << " AccessingFunction = " << GS.AccessingFunction->getName()
|
DEBUG(errs() << " AccessingFunction = " << GS.AccessingFunction->getName()
|
||||||
<< "\n";
|
<< "\n");
|
||||||
cerr << " HasMultipleAccessingFunctions = "
|
DEBUG(errs() << " HasMultipleAccessingFunctions = "
|
||||||
<< GS.HasMultipleAccessingFunctions << "\n";
|
<< GS.HasMultipleAccessingFunctions << "\n");
|
||||||
cerr << " HasNonInstructionUser = " << GS.HasNonInstructionUser<<"\n";
|
DEBUG(errs() << " HasNonInstructionUser = "
|
||||||
cerr << "\n";
|
<< GS.HasNonInstructionUser<<"\n");
|
||||||
|
DEBUG(errs() << "\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// If this is a first class global and has only one accessing function
|
// If this is a first class global and has only one accessing function
|
||||||
|
|
Loading…
Reference in New Issue