* add some DEBUG statements

* Properly compile this:

struct a {};
int test() {
  struct a b[2];
  if (&b[0] != &b[1])
    abort ();
  return 0;
}

to 'return 0', not abort().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19875 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-01-28 19:32:01 +00:00
parent ce04a6d7f6
commit ad5fec12a0

View File

@ -2198,14 +2198,17 @@ Instruction *InstCombiner::FoldGEPSetCC(User *GEPLHS, Value *RHS,
// index is zero or not. // index is zero or not.
if (Cond == Instruction::SetEQ || Cond == Instruction::SetNE) { if (Cond == Instruction::SetEQ || Cond == Instruction::SetNE) {
Instruction *InVal = 0; Instruction *InVal = 0;
for (unsigned i = 1, e = GEPLHS->getNumOperands(); i != e; ++i) { gep_type_iterator GTI = gep_type_begin(GEPLHS);
for (unsigned i = 1, e = GEPLHS->getNumOperands(); i != e; ++i, ++GTI) {
bool EmitIt = true; bool EmitIt = true;
if (Constant *C = dyn_cast<Constant>(GEPLHS->getOperand(i))) { if (Constant *C = dyn_cast<Constant>(GEPLHS->getOperand(i))) {
if (isa<UndefValue>(C)) // undef index -> undef. if (isa<UndefValue>(C)) // undef index -> undef.
return ReplaceInstUsesWith(I, UndefValue::get(I.getType())); return ReplaceInstUsesWith(I, UndefValue::get(I.getType()));
if (C->isNullValue()) if (C->isNullValue())
EmitIt = false; EmitIt = false;
else if (isa<ConstantInt>(C)) else if (TD->getTypeSize(GTI.getIndexedType()) == 0) {
EmitIt = false; // This is indexing into a zero sized array?
} else if (isa<ConstantInt>(C))
return ReplaceInstUsesWith(I, // No comparison is needed here. return ReplaceInstUsesWith(I, // No comparison is needed here.
ConstantBool::get(Cond == Instruction::SetNE)); ConstantBool::get(Cond == Instruction::SetNE));
} }
@ -4902,7 +4905,9 @@ bool InstCombiner::runOnFunction(Function &F) {
AddUsesToWorkList(*I); AddUsesToWorkList(*I);
++NumDeadInst; ++NumDeadInst;
I->getParent()->getInstList().erase(I); DEBUG(std::cerr << "IC: DCE: " << *I);
I->eraseFromParent();
removeFromWorkList(I); removeFromWorkList(I);
continue; continue;
} }
@ -4929,6 +4934,8 @@ bool InstCombiner::runOnFunction(Function &F) {
} }
} }
DEBUG(std::cerr << "IC: ConstFold to: " << *C << " from: " << *I);
// Add operands to the worklist... // Add operands to the worklist...
AddUsesToWorkList(*I); AddUsesToWorkList(*I);
ReplaceInstUsesWith(*I, C); ReplaceInstUsesWith(*I, C);