mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 18:24:23 +00:00
Add some braces to make newer GCCs happy and update CMakeLists.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81443 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -22,6 +22,7 @@ add_llvm_library(LLVMAnalysis
|
|||||||
LoopInfo.cpp
|
LoopInfo.cpp
|
||||||
LoopPass.cpp
|
LoopPass.cpp
|
||||||
LoopVR.cpp
|
LoopVR.cpp
|
||||||
|
MallocHelper.cpp
|
||||||
MemoryDependenceAnalysis.cpp
|
MemoryDependenceAnalysis.cpp
|
||||||
PointerTracking.cpp
|
PointerTracking.cpp
|
||||||
PostDominators.cpp
|
PostDominators.cpp
|
||||||
|
@ -188,7 +188,7 @@ Value* llvm::getMallocArraySize(CallInst* CI) {
|
|||||||
|
|
||||||
Constant* CO = dyn_cast<Constant>(MallocArg);
|
Constant* CO = dyn_cast<Constant>(MallocArg);
|
||||||
BinaryOperator* BO = dyn_cast<BinaryOperator>(MallocArg);
|
BinaryOperator* BO = dyn_cast<BinaryOperator>(MallocArg);
|
||||||
assert(isConstantOne(ElementSize) || CO || BO &&
|
assert((isConstantOne(ElementSize) || CO || BO) &&
|
||||||
"getMallocArraySize and malformed malloc IR");
|
"getMallocArraySize and malformed malloc IR");
|
||||||
|
|
||||||
if (isConstantOne(ElementSize))
|
if (isConstantOne(ElementSize))
|
||||||
|
@ -462,7 +462,7 @@ static Value *checkArraySize(Value *Amt, const Type *IntPtrTy) {
|
|||||||
static Value *createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd,
|
static Value *createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd,
|
||||||
const Type *AllocTy, const Type *IntPtrTy,
|
const Type *AllocTy, const Type *IntPtrTy,
|
||||||
Value *ArraySize, const Twine &NameStr) {
|
Value *ArraySize, const Twine &NameStr) {
|
||||||
assert((!InsertBefore && InsertAtEnd || InsertBefore && !InsertAtEnd) &&
|
assert(((!InsertBefore && InsertAtEnd) || (InsertBefore && !InsertAtEnd)) &&
|
||||||
"createMalloc needs only InsertBefore or InsertAtEnd");
|
"createMalloc needs only InsertBefore or InsertAtEnd");
|
||||||
const PointerType *AllocPtrType = dyn_cast<PointerType>(AllocTy);
|
const PointerType *AllocPtrType = dyn_cast<PointerType>(AllocTy);
|
||||||
assert(AllocPtrType && "CreateMalloc passed a non-pointer allocation type");
|
assert(AllocPtrType && "CreateMalloc passed a non-pointer allocation type");
|
||||||
@ -473,7 +473,7 @@ static Value *createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd,
|
|||||||
Value *AllocSize = ConstantExpr::getSizeOf(AllocPtrType->getElementType());
|
Value *AllocSize = ConstantExpr::getSizeOf(AllocPtrType->getElementType());
|
||||||
AllocSize = ConstantExpr::getTruncOrBitCast(cast<Constant>(AllocSize),
|
AllocSize = ConstantExpr::getTruncOrBitCast(cast<Constant>(AllocSize),
|
||||||
IntPtrTy);
|
IntPtrTy);
|
||||||
if (!IsConstantOne(ArraySize))
|
if (!IsConstantOne(ArraySize)) {
|
||||||
if (IsConstantOne(AllocSize)) {
|
if (IsConstantOne(AllocSize)) {
|
||||||
AllocSize = ArraySize; // Operand * 1 = Operand
|
AllocSize = ArraySize; // Operand * 1 = Operand
|
||||||
} else if (Constant *CO = dyn_cast<Constant>(ArraySize)) {
|
} else if (Constant *CO = dyn_cast<Constant>(ArraySize)) {
|
||||||
@ -483,13 +483,14 @@ static Value *createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd,
|
|||||||
AllocSize = ConstantExpr::getMul(Scale, cast<Constant>(AllocSize));
|
AllocSize = ConstantExpr::getMul(Scale, cast<Constant>(AllocSize));
|
||||||
} else {
|
} else {
|
||||||
Value *Scale = ArraySize;
|
Value *Scale = ArraySize;
|
||||||
if (Scale->getType() != IntPtrTy)
|
if (Scale->getType() != IntPtrTy) {
|
||||||
if (InsertBefore)
|
if (InsertBefore)
|
||||||
Scale = CastInst::CreateIntegerCast(Scale, IntPtrTy, false /*ZExt*/,
|
Scale = CastInst::CreateIntegerCast(Scale, IntPtrTy, false /*ZExt*/,
|
||||||
"", InsertBefore);
|
"", InsertBefore);
|
||||||
else
|
else
|
||||||
Scale = CastInst::CreateIntegerCast(Scale, IntPtrTy, false /*ZExt*/,
|
Scale = CastInst::CreateIntegerCast(Scale, IntPtrTy, false /*ZExt*/,
|
||||||
"", InsertAtEnd);
|
"", InsertAtEnd);
|
||||||
|
}
|
||||||
// Multiply type size by the array size...
|
// Multiply type size by the array size...
|
||||||
if (InsertBefore)
|
if (InsertBefore)
|
||||||
AllocSize = BinaryOperator::CreateMul(Scale, AllocSize,
|
AllocSize = BinaryOperator::CreateMul(Scale, AllocSize,
|
||||||
@ -498,6 +499,7 @@ static Value *createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd,
|
|||||||
AllocSize = BinaryOperator::CreateMul(Scale, AllocSize,
|
AllocSize = BinaryOperator::CreateMul(Scale, AllocSize,
|
||||||
"", InsertAtEnd);
|
"", InsertAtEnd);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create the call to Malloc.
|
// Create the call to Malloc.
|
||||||
BasicBlock* BB = InsertBefore ? InsertBefore->getParent() : InsertAtEnd;
|
BasicBlock* BB = InsertBefore ? InsertBefore->getParent() : InsertAtEnd;
|
||||||
|
Reference in New Issue
Block a user