mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
rotate CallInst operands, i.e. move callee to the back
of the operand array the motivation for this patch are laid out in my mail to llvm-commits: more efficient access to operands and callee, faster callgraph-construction, smaller compiler binary git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101364 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -94,7 +94,7 @@ static bool isObjectSmallerThan(const Value *V, unsigned Size,
|
||||
} else if (const CallInst* CI = extractMallocCall(V)) {
|
||||
if (!isArrayMalloc(V, &TD))
|
||||
// The size is the argument to the malloc call.
|
||||
if (const ConstantInt* C = dyn_cast<ConstantInt>(CI->getOperand(1)))
|
||||
if (const ConstantInt* C = dyn_cast<ConstantInt>(CI->getOperand(0)))
|
||||
return (C->getZExtValue() < Size);
|
||||
return false;
|
||||
} else if (const Argument *A = dyn_cast<Argument>(V)) {
|
||||
@@ -318,10 +318,10 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
||||
case Intrinsic::memcpy:
|
||||
case Intrinsic::memmove: {
|
||||
unsigned Len = ~0U;
|
||||
if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II->getOperand(3)))
|
||||
if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II->getOperand(2)))
|
||||
Len = LenCI->getZExtValue();
|
||||
Value *Dest = II->getOperand(1);
|
||||
Value *Src = II->getOperand(2);
|
||||
Value *Dest = II->getOperand(0);
|
||||
Value *Src = II->getOperand(1);
|
||||
if (isNoAlias(Dest, Len, P, Size)) {
|
||||
if (isNoAlias(Src, Len, P, Size))
|
||||
return NoModRef;
|
||||
@@ -332,9 +332,9 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
||||
case Intrinsic::memset:
|
||||
// Since memset is 'accesses arguments' only, the AliasAnalysis base class
|
||||
// will handle it for the variable length case.
|
||||
if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II->getOperand(3))) {
|
||||
if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II->getOperand(2))) {
|
||||
unsigned Len = LenCI->getZExtValue();
|
||||
Value *Dest = II->getOperand(1);
|
||||
Value *Dest = II->getOperand(0);
|
||||
if (isNoAlias(Dest, Len, P, Size))
|
||||
return NoModRef;
|
||||
}
|
||||
@@ -352,7 +352,7 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
||||
case Intrinsic::atomic_load_umax:
|
||||
case Intrinsic::atomic_load_umin:
|
||||
if (TD) {
|
||||
Value *Op1 = II->getOperand(1);
|
||||
Value *Op1 = II->getOperand(0);
|
||||
unsigned Op1Size = TD->getTypeStoreSize(Op1->getType());
|
||||
if (isNoAlias(Op1, Op1Size, P, Size))
|
||||
return NoModRef;
|
||||
@@ -361,14 +361,14 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
||||
case Intrinsic::lifetime_start:
|
||||
case Intrinsic::lifetime_end:
|
||||
case Intrinsic::invariant_start: {
|
||||
unsigned PtrSize = cast<ConstantInt>(II->getOperand(1))->getZExtValue();
|
||||
if (isNoAlias(II->getOperand(2), PtrSize, P, Size))
|
||||
unsigned PtrSize = cast<ConstantInt>(II->getOperand(0))->getZExtValue();
|
||||
if (isNoAlias(II->getOperand(1), PtrSize, P, Size))
|
||||
return NoModRef;
|
||||
break;
|
||||
}
|
||||
case Intrinsic::invariant_end: {
|
||||
unsigned PtrSize = cast<ConstantInt>(II->getOperand(2))->getZExtValue();
|
||||
if (isNoAlias(II->getOperand(3), PtrSize, P, Size))
|
||||
unsigned PtrSize = cast<ConstantInt>(II->getOperand(1))->getZExtValue();
|
||||
if (isNoAlias(II->getOperand(2), PtrSize, P, Size))
|
||||
return NoModRef;
|
||||
break;
|
||||
}
|
||||
|
@@ -772,9 +772,9 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy,
|
||||
case Instruction::ICmp:
|
||||
case Instruction::FCmp: assert(0 && "Invalid for compares");
|
||||
case Instruction::Call:
|
||||
if (Function *F = dyn_cast<Function>(Ops[0]))
|
||||
if (Function *F = dyn_cast<Function>(Ops[NumOps - 1]))
|
||||
if (canConstantFoldCallTo(F))
|
||||
return ConstantFoldCall(F, Ops+1, NumOps-1);
|
||||
return ConstantFoldCall(F, Ops, NumOps - 1);
|
||||
return 0;
|
||||
case Instruction::PtrToInt:
|
||||
// If the input is a inttoptr, eliminate the pair. This requires knowing
|
||||
|
@@ -252,7 +252,7 @@ bool GlobalsModRef::AnalyzeUsesOfPointer(Value *V,
|
||||
} else if (CallInst *CI = dyn_cast<CallInst>(*UI)) {
|
||||
// Make sure that this is just the function being called, not that it is
|
||||
// passing into the function.
|
||||
for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i)
|
||||
for (unsigned i = 0, e = CI->getNumOperands() - 1; i != e; ++i)
|
||||
if (CI->getOperand(i) == V) return true;
|
||||
} else if (InvokeInst *II = dyn_cast<InvokeInst>(*UI)) {
|
||||
// Make sure that this is just the function being called, not that it is
|
||||
|
@@ -103,7 +103,7 @@ static Value *computeArraySize(const CallInst *CI, const TargetData *TD,
|
||||
|
||||
// If malloc calls' arg can be determined to be a multiple of ElementSize,
|
||||
// return the multiple. Otherwise, return NULL.
|
||||
Value *MallocArg = CI->getOperand(1);
|
||||
Value *MallocArg = CI->getOperand(0);
|
||||
Value *Multiple = NULL;
|
||||
if (ComputeMultiple(MallocArg, ElementSize, Multiple,
|
||||
LookThroughSExt))
|
||||
@@ -120,7 +120,7 @@ const CallInst *llvm::isArrayMalloc(const Value *I, const TargetData *TD) {
|
||||
Value *ArraySize = computeArraySize(CI, TD);
|
||||
|
||||
if (ArraySize &&
|
||||
ArraySize != ConstantInt::get(CI->getOperand(1)->getType(), 1))
|
||||
ArraySize != ConstantInt::get(CI->getOperand(0)->getType(), 1))
|
||||
return CI;
|
||||
|
||||
// CI is a non-array malloc or we can't figure out that it is an array malloc.
|
||||
|
@@ -117,7 +117,7 @@ getCallSiteDependencyFrom(CallSite CS, bool isReadOnlyCall,
|
||||
Pointer = V->getOperand(0);
|
||||
PointerSize = AA->getTypeStoreSize(V->getType());
|
||||
} else if (isFreeCall(Inst)) {
|
||||
Pointer = Inst->getOperand(1);
|
||||
Pointer = Inst->getOperand(0);
|
||||
// calls to free() erase the entire structure
|
||||
PointerSize = ~0ULL;
|
||||
} else if (isa<CallInst>(Inst) || isa<InvokeInst>(Inst)) {
|
||||
@@ -197,9 +197,9 @@ getPointerDependencyFrom(Value *MemPtr, uint64_t MemSize, bool isLoad,
|
||||
// pointer, not on query pointers that are indexed off of them. It'd
|
||||
// be nice to handle that at some point.
|
||||
AliasAnalysis::AliasResult R =
|
||||
AA->alias(II->getOperand(3), ~0U, MemPtr, ~0U);
|
||||
AA->alias(II->getOperand(2), ~0U, MemPtr, ~0U);
|
||||
if (R == AliasAnalysis::MustAlias) {
|
||||
InvariantTag = II->getOperand(1);
|
||||
InvariantTag = II->getOperand(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ getPointerDependencyFrom(Value *MemPtr, uint64_t MemSize, bool isLoad,
|
||||
// pointer, not on query pointers that are indexed off of them. It'd
|
||||
// be nice to handle that at some point.
|
||||
AliasAnalysis::AliasResult R =
|
||||
AA->alias(II->getOperand(2), ~0U, MemPtr, ~0U);
|
||||
AA->alias(II->getOperand(1), ~0U, MemPtr, ~0U);
|
||||
if (R == AliasAnalysis::MustAlias)
|
||||
return MemDepResult::getDef(II);
|
||||
}
|
||||
@@ -366,7 +366,7 @@ MemDepResult MemoryDependenceAnalysis::getDependency(Instruction *QueryInst) {
|
||||
MemSize = AA->getTypeStoreSize(LI->getType());
|
||||
}
|
||||
} else if (isFreeCall(QueryInst)) {
|
||||
MemPtr = QueryInst->getOperand(1);
|
||||
MemPtr = QueryInst->getOperand(0);
|
||||
// calls to free() erase the entire structure, not just a field.
|
||||
MemSize = ~0UL;
|
||||
} else if (isa<CallInst>(QueryInst) || isa<InvokeInst>(QueryInst)) {
|
||||
@@ -378,12 +378,12 @@ MemDepResult MemoryDependenceAnalysis::getDependency(Instruction *QueryInst) {
|
||||
case Intrinsic::lifetime_start:
|
||||
case Intrinsic::lifetime_end:
|
||||
case Intrinsic::invariant_start:
|
||||
MemPtr = QueryInst->getOperand(2);
|
||||
MemSize = cast<ConstantInt>(QueryInst->getOperand(1))->getZExtValue();
|
||||
MemPtr = QueryInst->getOperand(1);
|
||||
MemSize = cast<ConstantInt>(QueryInst->getOperand(0))->getZExtValue();
|
||||
break;
|
||||
case Intrinsic::invariant_end:
|
||||
MemPtr = QueryInst->getOperand(3);
|
||||
MemSize = cast<ConstantInt>(QueryInst->getOperand(2))->getZExtValue();
|
||||
MemPtr = QueryInst->getOperand(2);
|
||||
MemSize = cast<ConstantInt>(QueryInst->getOperand(1))->getZExtValue();
|
||||
break;
|
||||
default:
|
||||
CallSite QueryCS = CallSite::get(QueryInst);
|
||||
|
@@ -953,7 +953,7 @@ bool llvm::CannotBeNegativeZero(const Value *V, unsigned Depth) {
|
||||
if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(I))
|
||||
// sqrt(-0.0) = -0.0, no other negative results are possible.
|
||||
if (II->getIntrinsicID() == Intrinsic::sqrt)
|
||||
return CannotBeNegativeZero(II->getOperand(1), Depth+1);
|
||||
return CannotBeNegativeZero(II->getOperand(0), Depth+1);
|
||||
|
||||
if (const CallInst *CI = dyn_cast<CallInst>(I))
|
||||
if (const Function *F = CI->getCalledFunction()) {
|
||||
@@ -966,7 +966,7 @@ bool llvm::CannotBeNegativeZero(const Value *V, unsigned Depth) {
|
||||
if (F->getName() == "fabsl") return true;
|
||||
if (F->getName() == "sqrt" || F->getName() == "sqrtf" ||
|
||||
F->getName() == "sqrtl")
|
||||
return CannotBeNegativeZero(CI->getOperand(1), Depth+1);
|
||||
return CannotBeNegativeZero(CI->getOperand(0), Depth+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user