mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-11 21:38:19 +00:00
More instcombine cleanup, towards improving debug line info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131604 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1212,7 +1212,7 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
|
|||||||
// Add the chain argument and attributes.
|
// Add the chain argument and attributes.
|
||||||
Value *NestVal = Tramp->getArgOperand(2);
|
Value *NestVal = Tramp->getArgOperand(2);
|
||||||
if (NestVal->getType() != NestTy)
|
if (NestVal->getType() != NestTy)
|
||||||
NestVal = new BitCastInst(NestVal, NestTy, "nest", Caller);
|
NestVal = Builder->CreateBitCast(NestVal, NestTy, "nest");
|
||||||
NewArgs.push_back(NestVal);
|
NewArgs.push_back(NestVal);
|
||||||
NewAttrs.push_back(AttributeWithIndex::get(NestIdx, NestAttr));
|
NewAttrs.push_back(AttributeWithIndex::get(NestIdx, NestAttr));
|
||||||
}
|
}
|
||||||
|
@ -57,12 +57,14 @@ Instruction *InstCombiner::visitAllocaInst(AllocaInst &AI) {
|
|||||||
Value *Idx[2];
|
Value *Idx[2];
|
||||||
Idx[0] = NullIdx;
|
Idx[0] = NullIdx;
|
||||||
Idx[1] = NullIdx;
|
Idx[1] = NullIdx;
|
||||||
Value *V = GetElementPtrInst::CreateInBounds(New, Idx, Idx + 2,
|
Instruction *GEP =
|
||||||
New->getName()+".sub", It);
|
GetElementPtrInst::CreateInBounds(New, Idx, Idx + 2,
|
||||||
|
New->getName()+".sub");
|
||||||
|
InsertNewInstBefore(GEP, *It);
|
||||||
|
|
||||||
// Now make everything use the getelementptr instead of the original
|
// Now make everything use the getelementptr instead of the original
|
||||||
// allocation.
|
// allocation.
|
||||||
return ReplaceInstUsesWith(AI, V);
|
return ReplaceInstUsesWith(AI, GEP);
|
||||||
} else if (isa<UndefValue>(AI.getArraySize())) {
|
} else if (isa<UndefValue>(AI.getArraySize())) {
|
||||||
return ReplaceInstUsesWith(AI, Constant::getNullValue(AI.getType()));
|
return ReplaceInstUsesWith(AI, Constant::getNullValue(AI.getType()));
|
||||||
}
|
}
|
||||||
|
@ -240,9 +240,9 @@ bool InstCombiner::SimplifyAssociativeOrCommutative(BinaryOperator &I) {
|
|||||||
Constant *C2 = cast<Constant>(Op1->getOperand(1));
|
Constant *C2 = cast<Constant>(Op1->getOperand(1));
|
||||||
|
|
||||||
Constant *Folded = ConstantExpr::get(Opcode, C1, C2);
|
Constant *Folded = ConstantExpr::get(Opcode, C1, C2);
|
||||||
Instruction *New = BinaryOperator::Create(Opcode, A, B, Op1->getName(),
|
Instruction *New = BinaryOperator::Create(Opcode, A, B);
|
||||||
&I);
|
InsertNewInstBefore(New, I);
|
||||||
Worklist.Add(New);
|
New->takeName(Op1);
|
||||||
I.setOperand(0, New);
|
I.setOperand(0, New);
|
||||||
I.setOperand(1, Folded);
|
I.setOperand(1, Folded);
|
||||||
// Conservatively clear the optional flags, since they may not be
|
// Conservatively clear the optional flags, since they may not be
|
||||||
@ -599,7 +599,7 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Okay, we can do the transformation: create the new PHI node.
|
// Okay, we can do the transformation: create the new PHI node.
|
||||||
PHINode *NewPN = PHINode::Create(I.getType(), PN->getNumIncomingValues(), "");
|
PHINode *NewPN = PHINode::Create(I.getType(), PN->getNumIncomingValues());
|
||||||
InsertNewInstBefore(NewPN, *PN);
|
InsertNewInstBefore(NewPN, *PN);
|
||||||
NewPN->takeName(PN);
|
NewPN->takeName(PN);
|
||||||
|
|
||||||
@ -1088,8 +1088,8 @@ Instruction *InstCombiner::visitFree(CallInst &FI) {
|
|||||||
// free undef -> unreachable.
|
// free undef -> unreachable.
|
||||||
if (isa<UndefValue>(Op)) {
|
if (isa<UndefValue>(Op)) {
|
||||||
// Insert a new store to null because we cannot modify the CFG here.
|
// Insert a new store to null because we cannot modify the CFG here.
|
||||||
new StoreInst(ConstantInt::getTrue(FI.getContext()),
|
Builder->CreateStore(ConstantInt::getTrue(FI.getContext()),
|
||||||
UndefValue::get(Type::getInt1PtrTy(FI.getContext())), &FI);
|
UndefValue::get(Type::getInt1PtrTy(FI.getContext())));
|
||||||
return EraseInstFromFunction(FI);
|
return EraseInstFromFunction(FI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,8 +332,8 @@ define i64 @test31(i64 %A) nounwind readnone ssp noredzone {
|
|||||||
%F = or i64 %D, %E
|
%F = or i64 %D, %E
|
||||||
ret i64 %F
|
ret i64 %F
|
||||||
; CHECK: @test31
|
; CHECK: @test31
|
||||||
; CHECK-NEXT: %E1 = and i64 %A, 4294908984
|
; CHECK-NEXT: %E = and i64 %A, 4294908984
|
||||||
; CHECK-NEXT: %F = or i64 %E1, 32962
|
; CHECK-NEXT: %F = or i64 %E, 32962
|
||||||
; CHECK-NEXT: ret i64 %F
|
; CHECK-NEXT: ret i64 %F
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user