[llvm-commits] [llvm] r50256 - /llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp
Chris Lattner
clattner at apple.com
Fri Apr 25 09:12:28 PDT 2008
On Apr 24, 2008, at 11:37 PM, Nate Begeman wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=50256&view=rev
> Log:
> Teach the PruningFunctionCloner how to look through loads with
> ConstantExpression GEPs pointing into constant globals.
Nice, one minor tweak:
> +
> + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ops[0]))
> + if (const LoadInst *LI = dyn_cast<LoadInst>(I))
Please change the order of the first two lines. In theory there might
be a zero-operand instruction in the future, and it would be nice to
not accidentally read invalid memory. This is definitely a
'theoretical' concern, but good to take care of now.
Thanks Nate!
-Chris
>
> + if (!LI->isVolatile() && CE->getOpcode() ==
> Instruction::GetElementPtr)
> + if (GlobalVariable *GV = dyn_cast<GlobalVariable>(CE-
> >getOperand(0)))
> + if (GV->isConstant() && !GV->isDeclaration())
> + return ConstantFoldLoadThroughGEPConstantExpr(GV-
> >getInitializer(),
> + CE);
> +
> + return ConstantFoldInstOperands(I->getOpcode(), I->getType(),
> &Ops[0],
> + Ops.size(), TD);
> }
>
> /// CloneAndPruneFunctionInto - This works exactly like
> CloneFunctionInto,
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list