mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-16 11:30:51 +00:00
More instcombine cleanup aimed towards improving debug line info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131559 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1f2cb9824d
commit
59f15918c2
@ -111,10 +111,10 @@ Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) {
|
||||
|
||||
Value *Src = Builder->CreateBitCast(MI->getArgOperand(1), NewSrcPtrTy);
|
||||
Value *Dest = Builder->CreateBitCast(MI->getArgOperand(0), NewDstPtrTy);
|
||||
Instruction *L = new LoadInst(Src, "tmp", MI->isVolatile(), SrcAlign);
|
||||
InsertNewInstBefore(L, *MI);
|
||||
InsertNewInstBefore(new StoreInst(L, Dest, MI->isVolatile(), DstAlign),
|
||||
*MI);
|
||||
LoadInst *L = Builder->CreateLoad(Src, MI->isVolatile());
|
||||
L->setAlignment(SrcAlign);
|
||||
StoreInst *S = Builder->CreateStore(L, Dest, MI->isVolatile());
|
||||
S->setAlignment(DstAlign);
|
||||
|
||||
// Set the size of the copy to 0, it will be deleted on the next iteration.
|
||||
MI->setArgOperand(2, Constant::getNullValue(MemOpLength->getType()));
|
||||
@ -154,8 +154,9 @@ Instruction *InstCombiner::SimplifyMemSet(MemSetInst *MI) {
|
||||
|
||||
// Extract the fill value and store.
|
||||
uint64_t Fill = FillC->getZExtValue()*0x0101010101010101ULL;
|
||||
InsertNewInstBefore(new StoreInst(ConstantInt::get(ITy, Fill),
|
||||
Dest, false, Alignment), *MI);
|
||||
StoreInst *S = Builder->CreateStore(ConstantInt::get(ITy, Fill), Dest,
|
||||
MI->isVolatile());
|
||||
S->setAlignment(Alignment);
|
||||
|
||||
// Set the size of the copy to 0, it will be deleted on the next iteration.
|
||||
MI->setLength(Constant::getNullValue(LenC->getType()));
|
||||
@ -405,20 +406,21 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
||||
if (LHSKnownNegative && RHSKnownNegative) {
|
||||
// The sign bit is set in both cases: this MUST overflow.
|
||||
// Create a simple add instruction, and insert it into the struct.
|
||||
Instruction *Add = BinaryOperator::CreateAdd(LHS, RHS, "", &CI);
|
||||
Worklist.Add(Add);
|
||||
Value *Add = Builder->CreateAdd(LHS, RHS);
|
||||
Add->takeName(&CI);
|
||||
Constant *V[] = {
|
||||
UndefValue::get(LHS->getType()),ConstantInt::getTrue(II->getContext())
|
||||
UndefValue::get(LHS->getType()),
|
||||
ConstantInt::getTrue(II->getContext())
|
||||
};
|
||||
Constant *Struct = ConstantStruct::get(II->getContext(), V, 2, false);
|
||||
return InsertValueInst::Create(Struct, Add, 0);
|
||||
}
|
||||
|
||||
|
||||
if (LHSKnownPositive && RHSKnownPositive) {
|
||||
// The sign bit is clear in both cases: this CANNOT overflow.
|
||||
// Create a simple add instruction, and insert it into the struct.
|
||||
Instruction *Add = BinaryOperator::CreateNUWAdd(LHS, RHS, "", &CI);
|
||||
Worklist.Add(Add);
|
||||
Value *Add = Builder->CreateNUWAdd(LHS, RHS);
|
||||
Add->takeName(&CI);
|
||||
Constant *V[] = {
|
||||
UndefValue::get(LHS->getType()),
|
||||
ConstantInt::getFalse(II->getContext())
|
||||
@ -1276,24 +1278,19 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
|
||||
if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
|
||||
NewCaller = InvokeInst::Create(NewCallee,
|
||||
II->getNormalDest(), II->getUnwindDest(),
|
||||
NewArgs.begin(), NewArgs.end(),
|
||||
Caller->getName(), Caller);
|
||||
NewArgs.begin(), NewArgs.end());
|
||||
cast<InvokeInst>(NewCaller)->setCallingConv(II->getCallingConv());
|
||||
cast<InvokeInst>(NewCaller)->setAttributes(NewPAL);
|
||||
} else {
|
||||
NewCaller = CallInst::Create(NewCallee, NewArgs.begin(), NewArgs.end(),
|
||||
Caller->getName(), Caller);
|
||||
NewCaller = CallInst::Create(NewCallee, NewArgs.begin(), NewArgs.end());
|
||||
if (cast<CallInst>(Caller)->isTailCall())
|
||||
cast<CallInst>(NewCaller)->setTailCall();
|
||||
cast<CallInst>(NewCaller)->
|
||||
setCallingConv(cast<CallInst>(Caller)->getCallingConv());
|
||||
cast<CallInst>(NewCaller)->setAttributes(NewPAL);
|
||||
}
|
||||
if (!Caller->getType()->isVoidTy())
|
||||
ReplaceInstUsesWith(*Caller, NewCaller);
|
||||
Caller->eraseFromParent();
|
||||
Worklist.Remove(Caller);
|
||||
return 0;
|
||||
|
||||
return NewCaller;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,9 @@ define i8 @uaddtest2(i8 %A, i8 %B, i1* %overflowPtr) {
|
||||
; CHECK: @uaddtest2
|
||||
; CHECK-NEXT: %and.A = and i8 %A, 127
|
||||
; CHECK-NEXT: %and.B = and i8 %B, 127
|
||||
; CHECK-NEXT: %1 = add nuw i8 %and.A, %and.B
|
||||
; CHECK-NEXT: %x = add nuw i8 %and.A, %and.B
|
||||
; CHECK-NEXT: store i1 false, i1* %overflowPtr
|
||||
; CHECK-NEXT: ret i8 %1
|
||||
; CHECK-NEXT: ret i8 %x
|
||||
}
|
||||
|
||||
define i8 @uaddtest3(i8 %A, i8 %B, i1* %overflowPtr) {
|
||||
@ -46,9 +46,9 @@ define i8 @uaddtest3(i8 %A, i8 %B, i1* %overflowPtr) {
|
||||
; CHECK: @uaddtest3
|
||||
; CHECK-NEXT: %or.A = or i8 %A, -128
|
||||
; CHECK-NEXT: %or.B = or i8 %B, -128
|
||||
; CHECK-NEXT: %1 = add i8 %or.A, %or.B
|
||||
; CHECK-NEXT: %x = add i8 %or.A, %or.B
|
||||
; CHECK-NEXT: store i1 true, i1* %overflowPtr
|
||||
; CHECK-NEXT: ret i8 %1
|
||||
; CHECK-NEXT: ret i8 %x
|
||||
}
|
||||
|
||||
define i8 @uaddtest4(i8 %A, i1* %overflowPtr) {
|
||||
|
Loading…
Reference in New Issue
Block a user