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