diff options
author | Tim Northover <tnorthover@apple.com> | 2018-11-27 11:08:14 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2018-11-27 11:08:14 +0000 |
commit | 81bff5e6ea27d5ff45b01372fdbbdad2fbac98b9 (patch) | |
tree | bcef7a01c91e5aa2e2e8c6c265fd878fb8ad8140 /llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | |
parent | 8577dcc53341f45bef0d0f13f39c05225674f72b (diff) | |
download | bcm5719-llvm-81bff5e6ea27d5ff45b01372fdbbdad2fbac98b9.tar.gz bcm5719-llvm-81bff5e6ea27d5ff45b01372fdbbdad2fbac98b9.zip |
InstCombine: add comment explaining malloc deletion. NFC.
I tried to change this, not quite realising the logic behind what we
were doing. Hopefully this comment will help the next person to come
along.
llvm-svn: 347653
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index a3962a04b50..a8fd47c9d45 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2244,9 +2244,16 @@ static bool isAllocSiteRemovable(Instruction *AI, } Instruction *InstCombiner::visitAllocSite(Instruction &MI) { - // If we have a malloc call which is only used in any amount of comparisons - // to null and free calls, delete the calls and replace the comparisons with - // true or false as appropriate. + // If we have a malloc call which is only used in any amount of comparisons to + // null and free calls, delete the calls and replace the comparisons with true + // or false as appropriate. + + // This is based on the principle that we can substitute our own allocation + // function (which will never return null) rather than knowledge of the + // specific function being called. In some sense this can change the permitted + // outputs of a program (when we convert a malloc to an alloca, the fact that + // the allocation is now on the stack is potentially visible, for example), + // but we believe in a permissible manner. SmallVector<WeakTrackingVH, 64> Users; // If we are removing an alloca with a dbg.declare, insert dbg.value calls |