mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-23 14:25:07 +00:00
eliminate CallInst::ArgOffset
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108522 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -772,13 +772,13 @@ protected:
|
||||
NewInstruction = IC->ReplaceInstUsesWith(*CI, With);
|
||||
}
|
||||
bool isFoldable(unsigned SizeCIOp, unsigned SizeArgOp, bool isString) const {
|
||||
if (ConstantInt *SizeCI = dyn_cast<ConstantInt>(CI->getArgOperand(SizeCIOp - CallInst::ArgOffset))) {
|
||||
if (ConstantInt *SizeCI = dyn_cast<ConstantInt>(CI->getArgOperand(SizeCIOp))) {
|
||||
if (SizeCI->isAllOnesValue())
|
||||
return true;
|
||||
if (isString)
|
||||
return SizeCI->getZExtValue() >=
|
||||
GetStringLength(CI->getArgOperand(SizeArgOp - CallInst::ArgOffset));
|
||||
if (ConstantInt *Arg = dyn_cast<ConstantInt>(CI->getArgOperand(SizeArgOp - CallInst::ArgOffset)))
|
||||
GetStringLength(CI->getArgOperand(SizeArgOp));
|
||||
if (ConstantInt *Arg = dyn_cast<ConstantInt>(CI->getArgOperand(SizeArgOp)))
|
||||
return SizeCI->getZExtValue() >= Arg->getZExtValue();
|
||||
}
|
||||
return false;
|
||||
|
@@ -548,9 +548,9 @@ protected:
|
||||
CI->eraseFromParent();
|
||||
}
|
||||
bool isFoldable(unsigned SizeCIOp, unsigned, bool) const {
|
||||
if (ConstantInt *SizeCI = dyn_cast<ConstantInt>(CI->getArgOperand(SizeCIOp
|
||||
- CallInst::ArgOffset)))
|
||||
return SizeCI->isAllOnesValue();
|
||||
if (ConstantInt *SizeCI =
|
||||
dyn_cast<ConstantInt>(CI->getArgOperand(SizeCIOp)))
|
||||
return SizeCI->isAllOnesValue();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
@@ -969,7 +969,7 @@ void SROA::isSafeForScalarRepl(Instruction *I, AllocaInst *AI, uint64_t Offset,
|
||||
ConstantInt *Length = dyn_cast<ConstantInt>(MI->getLength());
|
||||
if (Length)
|
||||
isSafeMemAccess(AI, Offset, Length->getZExtValue(), 0,
|
||||
UI.getOperandNo() == CallInst::ArgOffset, Info);
|
||||
UI.getOperandNo() == 0, Info);
|
||||
else
|
||||
MarkUnsafe(Info);
|
||||
} else if (LoadInst *LI = dyn_cast<LoadInst>(User)) {
|
||||
@@ -1787,7 +1787,7 @@ static bool isOnlyCopiedFromConstantGlobal(Value *V, MemTransferInst *&TheCopy,
|
||||
if (isOffset) return false;
|
||||
|
||||
// If the memintrinsic isn't using the alloca as the dest, reject it.
|
||||
if (UI.getOperandNo() != CallInst::ArgOffset) return false;
|
||||
if (UI.getOperandNo() != 0) return false;
|
||||
|
||||
// If the source of the memcpy/move is not a constant global, reject it.
|
||||
if (!PointsToConstantGlobal(MI->getSource()))
|
||||
|
@@ -421,7 +421,7 @@ bool SimplifyFortifiedLibCalls::fold(CallInst *CI, const TargetData *TD) {
|
||||
FT->getParamType(3) != TD->getIntPtrType(Context))
|
||||
return false;
|
||||
|
||||
if (isFoldable(3 + CallInst::ArgOffset, 2 + CallInst::ArgOffset, false)) {
|
||||
if (isFoldable(3, 2, false)) {
|
||||
EmitMemCpy(CI->getArgOperand(0), CI->getArgOperand(1), CI->getArgOperand(2),
|
||||
1, false, B, TD);
|
||||
replaceCall(CI->getArgOperand(0));
|
||||
@@ -444,7 +444,7 @@ bool SimplifyFortifiedLibCalls::fold(CallInst *CI, const TargetData *TD) {
|
||||
FT->getParamType(3) != TD->getIntPtrType(Context))
|
||||
return false;
|
||||
|
||||
if (isFoldable(3 + CallInst::ArgOffset, 2 + CallInst::ArgOffset, false)) {
|
||||
if (isFoldable(3, 2, false)) {
|
||||
EmitMemMove(CI->getArgOperand(0), CI->getArgOperand(1), CI->getArgOperand(2),
|
||||
1, false, B, TD);
|
||||
replaceCall(CI->getArgOperand(0));
|
||||
@@ -462,7 +462,7 @@ bool SimplifyFortifiedLibCalls::fold(CallInst *CI, const TargetData *TD) {
|
||||
FT->getParamType(3) != TD->getIntPtrType(Context))
|
||||
return false;
|
||||
|
||||
if (isFoldable(3 + CallInst::ArgOffset, 2 + CallInst::ArgOffset, false)) {
|
||||
if (isFoldable(3, 2, false)) {
|
||||
Value *Val = B.CreateIntCast(CI->getArgOperand(1), B.getInt8Ty(),
|
||||
false);
|
||||
EmitMemSet(CI->getArgOperand(0), Val, CI->getArgOperand(2), false, B, TD);
|
||||
@@ -487,7 +487,7 @@ bool SimplifyFortifiedLibCalls::fold(CallInst *CI, const TargetData *TD) {
|
||||
// st[rp]cpy_chk call which may fail at runtime if the size is too long.
|
||||
// TODO: It might be nice to get a maximum length out of the possible
|
||||
// string lengths for varying.
|
||||
if (isFoldable(2 + CallInst::ArgOffset, 1 + CallInst::ArgOffset, true)) {
|
||||
if (isFoldable(2, 1, true)) {
|
||||
Value *Ret = EmitStrCpy(CI->getArgOperand(0), CI->getArgOperand(1), B, TD,
|
||||
Name.substr(2, 6));
|
||||
replaceCall(Ret);
|
||||
@@ -505,7 +505,7 @@ bool SimplifyFortifiedLibCalls::fold(CallInst *CI, const TargetData *TD) {
|
||||
FT->getParamType(3) != TD->getIntPtrType(Context))
|
||||
return false;
|
||||
|
||||
if (isFoldable(3 + CallInst::ArgOffset, 2 + CallInst::ArgOffset, false)) {
|
||||
if (isFoldable(3, 2, false)) {
|
||||
Value *Ret = EmitStrNCpy(CI->getArgOperand(0), CI->getArgOperand(1),
|
||||
CI->getArgOperand(2), B, TD, Name.substr(2, 7));
|
||||
replaceCall(Ret);
|
||||
|
Reference in New Issue
Block a user