[llvm-commits] [llvm] r159876 - in /llvm/trunk: lib/Transforms/InstCombine/InstructionCombining.cpp test/Transforms/InstCombine/badmalloc.ll test/Transforms/InstCombine/invoke.ll test/Transforms/InstCombine/malloc-free-delete.ll test/Transforms/InstCom

Duncan Sands baldrick at free.fr
Mon Jul 9 09:00:16 PDT 2012


Hi Nuno,

On 08/07/12 22:01, Nuno Lopes wrote:
>>> --- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
>>> +++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Fri Jul  6
>>> 18:09:25 2012
>>> @@ -1137,12 +1137,29 @@
>>>         }
>>>       }
>>>       if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(U)) {
>>> -      if (II->getIntrinsicID() == Intrinsic::lifetime_start ||
>>> -          II->getIntrinsicID() == Intrinsic::lifetime_end) {
>>> +      switch (II->getIntrinsicID()) {
>>> +      default: return false;
>>> +      case Intrinsic::memmove:
>>> +      case Intrinsic::memcpy:
>>> +      case Intrinsic::memset: {
>>> +        MemIntrinsic *MI = cast<MemIntrinsic>(II);
>>> +        if (MI->isVolatile() || MI->getRawDest() != V)
>>
>> why exclude volatile stores?  If all that is being done to the allocated memory
>> is doing a bunch of volatile stores to it, I don't see why you can't discard
>> them and the allocation too.
>
> I thought about that, but.. I guess it's better not to mess around with
> volatiles. And I don't even think it's legal (C standard wise) to remove it.

we already remove volatile stores to alloca's, so why not to heap allocations
too?

Ciao, Duncan.




More information about the llvm-commits mailing list