Inline extractMallocCall to sole use and delete [NFC]
This commit is contained in:
1 parent
4b0fc924a9
commit
67a3331e4f
3 files changed
+2
-22
No files matched your search
@@ -118,18 +118,6 @@ bool isStrdupLikeFn(const Value *V, const TargetLibraryInfo *TLI,
|
||||
// malloc Call Utility Functions.
|
||||
//
|
||||
|
||||
/// extractMallocCall - Returns the corresponding CallInst if the instruction
|
||||
/// is a malloc call. Since CallInst::CreateMalloc() only creates calls, we
|
||||
/// ignore InvokeInst here.
|
||||
const CallInst *
|
||||
extractMallocCall(const Value *I,
|
||||
function_ref<const TargetLibraryInfo &(Function &)> GetTLI);
|
||||
inline CallInst *
|
||||
extractMallocCall(Value *I,
|
||||
function_ref<const TargetLibraryInfo &(Function &)> GetTLI) {
|
||||
return const_cast<CallInst *>(extractMallocCall((const Value *)I, GetTLI));
|
||||
}
|
||||
|
||||
/// getMallocAllocatedType - Returns the Type allocated by malloc call.
|
||||
/// The Type depends on the number of bitcast uses of the malloc call:
|
||||
/// 0: PointerType is the malloc calls' return type.
|
||||
|
||||
@@ -334,15 +334,6 @@ bool llvm::isStrdupLikeFn(const Value *V, const TargetLibraryInfo *TLI,
|
||||
return getAllocationData(V, StrDupLike, TLI, LookThroughBitCast).hasValue();
|
||||
}
|
||||
|
||||
/// extractMallocCall - Returns the corresponding CallInst if the instruction
|
||||
/// is a malloc call. Since CallInst::CreateMalloc() only creates calls, we
|
||||
/// ignore InvokeInst here.
|
||||
const CallInst *llvm::extractMallocCall(
|
||||
const Value *I,
|
||||
function_ref<const TargetLibraryInfo &(Function &)> GetTLI) {
|
||||
return isMallocLikeFn(I, GetTLI) ? dyn_cast<CallInst>(I) : nullptr;
|
||||
}
|
||||
|
||||
static Value *computeArraySize(const CallInst *CI, const DataLayout &DL,
|
||||
const TargetLibraryInfo *TLI,
|
||||
bool LookThroughSExt = false) {
|
||||
|
||||
@@ -1140,7 +1140,8 @@ optimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal,
|
||||
// Optimize away any trapping uses of the loaded value.
|
||||
if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC, DL, GetTLI))
|
||||
return true;
|
||||
} else if (CallInst *CI = extractMallocCall(StoredOnceVal, GetTLI)) {
|
||||
} else if (isMallocLikeFn(StoredOnceVal, GetTLI)) {
|
||||
auto *CI = cast<CallInst>(StoredOnceVal);
|
||||
auto *TLI = &GetTLI(*CI->getFunction());
|
||||
Type *MallocType = getMallocAllocatedType(CI, TLI);
|
||||
if (MallocType && tryToOptimizeStoreOfMallocToGlobal(GV, CI, MallocType,
|
||||
|
||||
Reference in new issue
Block a user