[PATCH] D19549: Fold compares irrespective of whether allocation can be elided
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 27 13:36:46 PDT 2016
sanjoy requested changes to this revision.
This revision now requires changes to proceed.
================
Comment at: lib/Analysis/CaptureTracking.cpp:312
@@ -311,1 +311,3 @@
break;
+ // Comparison against value stored in global variable.
+ unsigned OtherIndex = (I->getOperand(0) == V) ? 1 : 0;
----------------
Please add a sentence or two here on why this is correct i.e. you're
optimistically assuming that the pointer does not escape, and given
that it does not escape, its value could could not have been "guessed
into existence" and separately stored in a global variable.
I.e. we're avoiding situations like this:
```
store <some value> to <global>
%val = load <global>
if (%val == %ptr)
escape(%val)
```
since `<some value>` cannot be equal to `%ptr` if `%ptr` does not escape.
================
Comment at: lib/Analysis/InstructionSimplify.cpp:2087
@@ -2085,1 +2086,3 @@
+ // Fold Comparisons for non-escaping pointer even if the allocation call
+ // cannot be elided.
----------------
s/Comparisons/comparisons and s/NULL/null. Can you also make the description one continuous paragraph?
================
Comment at: lib/Analysis/InstructionSimplify.cpp:2100
@@ +2099,3 @@
+ // compare dominates the pointer escape
+ if (MI && !PointerMayBeCaptured(MI, false, false))
+ return ConstantInt::get(GetCompareTy(LHS), !CmpInst::isTrueWhenEqual(Pred));
----------------
I think you need to pass `true` for both `ReturnCaptures` and `StoreCaptures`. Can you also add a test case that would've caught this?
Repository:
rL LLVM
http://reviews.llvm.org/D19549
More information about the llvm-commits
mailing list