This is an archive of the discontinued LLVM Phabricator instance.

[FunctionAttrs] Annotate function arguments with call site information
AbandonedPublic

Authored by jdoerfert on Jul 31 2018, 7:17 PM.

Details

Summary

If a function is internal and all call sites are statically known, we can
try to derive attributes for the arguments. With this patch we introduce
this attribute deduction for the following attributes:

  • non-null
  • no-capture
  • read-none
  • read-only
  • write-only
  • no-alias
  • alignment
  • dereferencable
  • dereferencable_or_null

Note that many internal functions are inlined, but some are not. This
could be caused by size constrains, recursion, or because the internal
function is used as a "callback", thus an indirect call that might or
might not be visible in the current module. While this patch does not
require callback calls to be identified, it is especially designed to
allow them later on. One type of callback that can significantly benefit
from proper attribute deduction are outlined functions passed to OpenMP
runtime calls. Though, in practice we see various kinds of callbacks
including user defined higher-order functions and calls to builtins like
qsort.

Note that this patch should be a generalization of D4609.

Diff Detail

Event Timeline

jdoerfert created this revision.Jul 31 2018, 7:17 PM
jdoerfert edited the summary of this revision. (Show Details)Aug 1 2018, 10:46 AM
jdoerfert updated this revision to Diff 158654.Aug 1 2018, 3:39 PM

Fixed spelling, stripped casts, added the tests from D4609

jdoerfert updated this revision to Diff 158736.Aug 2 2018, 5:16 AM

Remove large macro in favor of a switch

jdoerfert updated this revision to Diff 158742.Aug 2 2018, 6:13 AM

Use call sites for now and improve testing of non-null deduction

jdoerfert added inline comments.Aug 2 2018, 7:43 AM
lib/Transforms/IPO/FunctionAttrs.cpp
1194

Here we need to check NullPointerIsDefined too.

uenoku added a subscriber: uenoku.Aug 22 2019, 10:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2019, 10:05 AM
jdoerfert abandoned this revision.Aug 26 2019, 11:07 AM

This is a pre-Attributor patch. Though, some logic and tests might be salvaged.