mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Enhance analysis passes so that they apply the same analysis to malloc calls as to MallocInst.
Reviewed by Eli Friedman. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82281 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "llvm/Analysis/ConstantFolding.h"
|
||||
#include "llvm/Analysis/Dominators.h"
|
||||
#include "llvm/Analysis/LoopInfo.h"
|
||||
#include "llvm/Analysis/MallocHelper.h"
|
||||
#include "llvm/Analysis/PointerTracking.h"
|
||||
#include "llvm/Analysis/ScalarEvolution.h"
|
||||
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
|
||||
@@ -99,6 +100,14 @@ const SCEV *PointerTracking::computeAllocationCount(Value *P,
|
||||
return SE->getSCEV(arraySize);
|
||||
}
|
||||
|
||||
if (CallInst *CI = extractMallocCall(V)) {
|
||||
Value *arraySize = getMallocArraySize(CI, P->getContext(), TD);
|
||||
Ty = getMallocAllocatedType(CI);
|
||||
if (!Ty || !arraySize) return SE->getCouldNotCompute();
|
||||
// arraySize elements of type Ty.
|
||||
return SE->getSCEV(arraySize);
|
||||
}
|
||||
|
||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
|
||||
if (GV->hasDefinitiveInitializer()) {
|
||||
Constant *C = GV->getInitializer();
|
||||
|
||||
Reference in New Issue
Block a user