[llvm-commits] [llvm] r151003 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/invariant.ll

Duncan Sands baldrick at free.fr
Tue Feb 21 00:21:00 PST 2012


Hi Nick,

> --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Feb 20 17:32:26 2012
> @@ -2511,10 +2511,13 @@
>             if (!II->use_empty())
>               return false;
>             ConstantInt *Size = cast<ConstantInt>(II->getArgOperand(0));
> -          if (Size->isAllOnesValue()) {
> -            Value *PtrArg = getVal(II->getArgOperand(1));
> -            Value *Ptr = PtrArg->stripPointerCasts();
> -            if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Ptr))
> +          Value *PtrArg = getVal(II->getArgOperand(1));
> +          Value *Ptr = PtrArg->stripPointerCasts();
> +          if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Ptr)) {
> +            Type *ElemTy = cast<PointerType>(GV->getType())->getElementType();
> +            if (!Size->isAllOnesValue()&&

so previously you only added to Invariants if it was -1, while now you don't add
to Invariants if it is -1?  I.e. completely the opposite?  Can you please add a
comment explaining why you exclude -1 here.

> +                Size->getValue().getLimitedValue()>=
> +                TD->getTypeStoreSize(ElemTy))
>                 Invariants.insert(GV);
>             }
>             // Continue even if we do nothing.

Ciao, Duncan.



More information about the llvm-commits mailing list