[llvm-commits] [llvm] r73222 - /llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
Nick Lewycky
nlewycky at google.com
Fri Jun 12 10:17:19 PDT 2009
2009/6/12 Frits van Bommel <fvbommel at wxs.nl>
> Nick Lewycky wrote:
> > + // Check special state that is a part of some instructions.
> > + if (const LoadInst *LI = dyn_cast<LoadInst>(I1))
> > + return LI->isVolatile() == cast<LoadInst>(I2)->isVolatile() &&
> > + LI->getAlignment() == cast<LoadInst>(I2)->getAlignment();
> > + if (const StoreInst *SI = dyn_cast<StoreInst>(I1))
> > + return SI->isVolatile() == cast<StoreInst>(I2)->isVolatile() &&
> > + SI->getAlignment() == cast<StoreInst>(I2)->getAlignment();
> > + if (const CmpInst *CI = dyn_cast<CmpInst>(I1))
> > + return CI->getPredicate() == cast<CmpInst>(I2)->getPredicate();
> > + if (const CallInst *CI = dyn_cast<CallInst>(I1))
> > + return CI->isTailCall() == cast<CallInst>(I2)->isTailCall() &&
> > + CI->getCallingConv() == cast<CallInst>(I2)->getCallingConv()
> &&
> > + CI->getAttributes().getRawPointer() ==
> > + cast<CallInst>(I2)->getAttributes().getRawPointer();
> > + if (const InvokeInst *CI = dyn_cast<InvokeInst>(I1))
> > + return CI->getCallingConv() ==
> cast<InvokeInst>(I2)->getCallingConv() &&
> > + CI->getAttributes().getRawPointer() ==
> > + cast<InvokeInst>(I2)->getAttributes().getRawPointer();
> > + if (const InsertValueInst *IVI = dyn_cast<InsertValueInst>(I1)) {
> > + if (IVI->getNumIndices() !=
> cast<InsertValueInst>(I2)->getNumIndices())
> > + return false;
> > + for (unsigned i = 0, e = IVI->getNumIndices(); i != e; ++i)
> > + if (IVI->idx_begin()[i] !=
> cast<InsertValueInst>(I2)->idx_begin()[i])
> > + return false;
> > + return true;
> > + }
> > + if (const ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(I1)) {
> > + if (EVI->getNumIndices() !=
> cast<ExtractValueInst>(I2)->getNumIndices())
> > + return false;
> > + for (unsigned i = 0, e = EVI->getNumIndices(); i != e; ++i)
> > + if (EVI->idx_begin()[i] !=
> cast<ExtractValueInst>(I2)->idx_begin()[i])
> > + return false;
> > + return true;
> > + }
> > +
> > + return true;
> > }
>
> Shouldn't this have some special handling of GEPs too? A "gep {i32, i8}*
> %arg,
> i32 0, i32 1" is a different operation than "gep {i8, i8}* %arg, i32 0, i32
> 1"
> even though the types of the first operands (which are both pointers) are
> "equivalent".
> (Merging GEPs should probably require that the type *pointed at* by their
> first
> operands are equivalent)
Yes, you're right. Thanks again for doing review! Comparing the elements
that come before the offset being computed is the right fix, but I'd have to
think a bit about how to implement that.
MergeFunctions is not on by default but if someone is relying on it a really
quick fix would be to check for GEP and then compare real Type* of the first
operand instead of looking at the equivalence.
Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090612/0d6b37f4/attachment.html>
More information about the llvm-commits
mailing list