llvm.dbg.declare intrinsic does not use any llvm::Values. It's magic!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127282 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2011-03-08 22:12:11 +00:00
parent 19ba42eda2
commit 5aa3fa6d82
3 changed files with 3 additions and 41 deletions

View File

@ -218,7 +218,6 @@ private:
Instruction *transformZExtICmp(ICmpInst *ICI, Instruction &CI,
bool DoXform = true);
bool WillNotOverflowSignedAdd(Value *LHS, Value *RHS);
DbgDeclareInst *hasOneUsePlusDeclare(Value *V);
Value *EmitGEPOffset(User *GEP);
public:

View File

@ -87,10 +87,8 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI,
// If the allocation has multiple uses, only promote it if we are strictly
// increasing the alignment of the resultant allocation. If we keep it the
// same, we open the door to infinite loops of various kinds. (A reference
// from a dbg.declare doesn't count as a use for this purpose.)
if (!AI.hasOneUse() && !hasOneUsePlusDeclare(&AI) &&
CastElTyAlign == AllocElTyAlign) return 0;
// same, we open the door to infinite loops of various kinds.
if (!AI.hasOneUse() && CastElTyAlign == AllocElTyAlign) return 0;
uint64_t AllocElTySize = TD->getTypeAllocSize(AllocElTy);
uint64_t CastElTySize = TD->getTypeAllocSize(CastElTy);
@ -128,15 +126,10 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI,
New->setAlignment(AI.getAlignment());
New->takeName(&AI);
// If the allocation has one real use plus a dbg.declare, just remove the
// declare.
if (DbgDeclareInst *DI = hasOneUsePlusDeclare(&AI)) {
EraseInstFromFunction(*(Instruction*)DI);
}
// If the allocation has multiple real uses, insert a cast and change all
// things that used it to use the new cast. This will also hack on CI, but it
// will die soon.
else if (!AI.hasOneUse()) {
if (!AI.hasOneUse()) {
// New is the allocation instruction, pointer typed. AI is the original
// allocation instruction, also pointer typed. Thus, cast to use is BitCast.
Value *NewCast = AllocaBuilder.CreateBitCast(New, AI.getType(), "tmpcast");

View File

@ -364,34 +364,12 @@ static bool equivalentAddressValues(Value *A, Value *B) {
return false;
}
// If this instruction has two uses, one of which is a llvm.dbg.declare,
// return the llvm.dbg.declare.
DbgDeclareInst *InstCombiner::hasOneUsePlusDeclare(Value *V) {
if (!V->hasNUses(2))
return 0;
for (Value::use_iterator UI = V->use_begin(), E = V->use_end();
UI != E; ++UI) {
User *U = *UI;
if (DbgDeclareInst *DI = dyn_cast<DbgDeclareInst>(U))
return DI;
if (isa<BitCastInst>(U) && U->hasOneUse()) {
if (DbgDeclareInst *DI = dyn_cast<DbgDeclareInst>(*U->use_begin()))
return DI;
}
}
return 0;
}
Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
Value *Val = SI.getOperand(0);
Value *Ptr = SI.getOperand(1);
// If the RHS is an alloca with a single use, zapify the store, making the
// alloca dead.
// If the RHS is an alloca with a two uses, the other one being a
// llvm.dbg.declare, zapify the store and the declare, making the
// alloca dead. We must do this to prevent declares from affecting
// codegen.
if (!SI.isVolatile()) {
if (Ptr->hasOneUse()) {
if (isa<AllocaInst>(Ptr))
@ -400,17 +378,9 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
if (isa<AllocaInst>(GEP->getOperand(0))) {
if (GEP->getOperand(0)->hasOneUse())
return EraseInstFromFunction(SI);
if (DbgDeclareInst *DI = hasOneUsePlusDeclare(GEP->getOperand(0))) {
EraseInstFromFunction(*DI);
return EraseInstFromFunction(SI);
}
}
}
}
if (DbgDeclareInst *DI = hasOneUsePlusDeclare(Ptr)) {
EraseInstFromFunction(*DI);
return EraseInstFromFunction(SI);
}
}
// Attempt to improve the alignment.