This is an archive of the discontinued LLVM Phabricator instance.

[WIP] LLVM Optimization Remark for Attributes
Needs ReviewPublic

Authored by wsmoses on Jul 23 2019, 3:54 PM.

Details

Reviewers
aaron.ballman
Summary

This is a *work in progress* patch illustrating how an optimization remark that prints out derived function/argument attributes could be implemented.

Such remarks would be useful both for developers and end users to debug programs, either learning that an expected attribute was learned, or an unexpected attribute was learned (for example a pointer never being written to).

This is in preparation for the creation of a RFC, not intending to go in at the moment.

Evidently the following might not be the final interface, but one could imagine something like the following:

$ ./clang foobar.c -g -Rannotations -O3
   foobar.c:2:1: remark: derived following attributes for function f: fn_attr("norecurse") fn_attr("nounwind") fn_attr("readonly") arg_attr(0, "nocapture") arg_attr(0, "readonly") [-Rannotations]
   double f(double* a) {

foobar.c:

double f(double* a) {
    return a[0];
}

This diff also includes possible frontend changes to be able to parse the arguments when added to functions

__attribute__(( fn_attr("readonly") ))
double g(double* a) {
    return h(a);
}

Diff Detail

Event Timeline

wsmoses created this revision.Jul 23 2019, 3:54 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 23 2019, 3:54 PM
wsmoses updated this revision to Diff 211371.Jul 23 2019, 3:58 PM
wsmoses edited the summary of this revision. (Show Details)
wsmoses edited the summary of this revision. (Show Details)
wsmoses edited the summary of this revision. (Show Details)Jul 23 2019, 4:01 PM
wsmoses edited the summary of this revision. (Show Details)Jul 23 2019, 4:40 PM
wsmoses edited the summary of this revision. (Show Details)
wsmoses updated this revision to Diff 211382.Jul 23 2019, 8:01 PM
wsmoses removed subscribers: cfe-commits, llvm-commits.
lenary added a subscriber: lenary.Jul 24 2019, 3:05 PM