Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Initial comments.
llvm/lib/Transforms/IPO/Attributor.cpp | ||
---|---|---|
379 ↗ | (On Diff #210414) | -1 instead |
1125 ↗ | (On Diff #210414) | Do we make sure dereferenceable(0) is invalid IR? If not, we should. (The logic you use above relies on it and other places might be as well.) |
1148 ↗ | (On Diff #210414) | This can be commited separately with the other nonnull changes above. Please change the order in this conditional to first check the attributes and then call isKnownNonZero, or better, remove the attribute checks and make sure isKnownNonZero performs them. |
1226 ↗ | (On Diff #210414) | comments describing the members missing |
1229 ↗ | (On Diff #210414) | While it practically doesn't make a difference (I think) I would have suspected both states to be asked here. |
1379 ↗ | (On Diff #210414) | Add a TODO here wrt. tacking the globally flag as well, or just do it. |
1382 ↗ | (On Diff #210414) | Here and below it might make sense to move the declaration into the conditional: if (auto *DerefAA = ... ) |
1397 ↗ | (On Diff #210414) | If Offset is not 0, Base cannot be null (due to the inbounds properties). I thought about relying on the attribute to know this but that is actually not always possible. Instead, I think you can here say something like: Furthermore, we could strip non-inbounds offsets as well, I think. Thought, we then have to be more careful with the difference calculation, e.g., only non-negative Offset values would then be allowed. What do you think? |
1410 ↗ | (On Diff #210414) | true should be !NullPointerIsDefined(&getAnchorScope(), V.getType()->getPointerAddressSpace()) to allow nullptr as valid pointer. Shouldn't one of the two checks above subsume the other? |
1467 ↗ | (On Diff #210414) | Why not call computeAssumedDerefenceableBytes on the CS.getArgOperand(ArgNo) value? |
1804 ↗ | (On Diff #210414) | Whitelist check missing here and above (and in existing code). |
Address comments.
I'll split a patch for nonnull initialization and fix whitelist in a few days.
llvm/lib/Transforms/IPO/Attributor.cpp | ||
---|---|---|
1148 ↗ | (On Diff #210414) |
I think isKnownNonZero would not check parameter attribute in call site so it is not correct. |
1229 ↗ | (On Diff #210414) | Even though NonNullGlobalState was not valid, we can deduce dereferenceable_or_null so I think this is appropriate. |
1397 ↗ | (On Diff #210414) |
I'll try it later. |
1467 ↗ | (On Diff #210414) | It is already called below. |
This LGTM assuming you tried it on the test suite. Clang format the patch please and see the two comments below.
llvm/lib/Transforms/IPO/Attributor.cpp | ||
---|---|---|
1229 ↗ | (On Diff #210692) | Change the name to something meaningful or remove it, should not be necessary anyway. |
1395 ↗ | (On Diff #210692) | if you do not track them, set them to false. I think tracking nonnull should be easy, you compute it below almost in all cases anyway. |
Address comments and add stats. test-suite passed. However as far as I see it, no new dereferenceable was deduced.
if (!Attr.isEnumAttribute()) return;
Will block the attribute to reach stats. Could you re-run (with --cmake-define=TEST_SUITE_COLLECT_STATS=ON)?
Will block the attribute to reach stats. Could you re-run (with --cmake-define=TEST_SUITE_COLLECT_STATS=ON)?
Oh, I see. All test passed and here is a summary:
attributor.NumCSArgumentDereferenceable 79604.0 attributor.NumFnArgumentDereferenceable 1105.0 attributor.NumFnReturnedDereferenceable 123.0