Flag functions that should be static if they are only called within a particular compilation unit

ASSIGNED
Assigned to

Status

()

Core
Rewriting and Analysis
P3
normal
ASSIGNED
8 years ago
4 days ago

People

(Reporter: (dormant account), Assigned: Ehren Metcalfe)

Tracking

(Blocks: 1 bug)

Trunk
x86
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

8 years ago
Marking functions as static should let the compiler be smarter about inclining and will make GCC produce a warning if a function ever goes unused.
(Assignee)

Updated

8 years ago
Assignee: nobody → ehren.m
Status: NEW → ASSIGNED
(Reporter)

Updated

8 years ago
Depends on: 537857
(Assignee)

Comment 1

8 years ago
Created attachment 420025 [details]
analysis results

This was generated against revision 89d33cf3490c. The modifications for callgraph to generate the extra columns in 'node' are straightforward but I can post them. Total functions identified: 3987
(Reporter)

Comment 2

8 years ago
This list looks pretty good. I don't think there is much we can do about the C code.

Looks like we should static-ify content/layout/accessibility. Should probably to whip a basic pork tool to do these en-mass(module granularity). C

A bunch of these are public APIs, if we end up maintaining this list we should deal with that. 

You should definitely integrate your changes into callgraph. I think once we take care of the obvious/easy/to/fix stuff we should flag this info in dxr.

Aside: roc mentioned that these issues are most likely to be fixed by contributors working on patching the affected area and these should somehow be flagged during the patch review cycle.
Yeah, this is the kind of thing it would be really good to have during review.
cairo decorates all of it's public symbols with 'cairo_public' so it should be possible to avoid the false positives there.
(Assignee)

Comment 5

8 years ago
Created attachment 420090 [details] [diff] [review]
callgraph patch

Patch for callgraph to add 'isStatic' and 'isMethod' to 'node'. Conceivably, we could do without 'isMethod' since separate sqlite views for functions and methods could be created by parsing the 'name' column.
Attachment #420090 - Flags: review?
(Assignee)

Updated

8 years ago
Attachment #420090 - Flags: review? → review?(dwitte)
(Reporter)

Updated

8 years ago
Depends on: 538014

Comment 6

8 years ago
Comment on attachment 420090 [details] [diff] [review]
callgraph patch

Looks good!
Attachment #420090 - Flags: review?(dwitte) → review+

Comment 7

7 years ago
It seems there is a patch for this. Is it current, and ready to go?

Comment 8

5 days ago
(In reply to Worcester12345 from comment #7)
> It seems there is a patch for this. Is it current, and ready to go?

What is latest status on this bug? Is it working ("FIXED" "WFM")? Is it not going to be fixed ("WONTFIX")?

Thanks.
Flags: needinfo?(michael)
I don't believe that we have code for this in tree right now. I imagine that this patch is stale enough (It's been 8 years!) that it can't land as-is.

I'm inclined to say that this is going to not be fixed anytime soon, but I'll mark it P3 anyway. It would probably need to be done with the sixgill analysis because we don't have full callgraphs in the clang static analysis.
Flags: needinfo?(michael)
Priority: -- → P3

Comment 10

5 days ago
Ehren, can you look at this patch, and bring it up to date?

Thanks.
Flags: needinfo?(ehren.m)
(Assignee)

Comment 11

4 days ago
Hi Worchester. This patch is against 'callgraph' which is a dehydra (treehydra) script. Dehydra is tightly coupled to GCC 4.5 (which I don't believe will compile current firefox) and an ancient SpiderMonkey version so going forward with this patch isn't the best approach.

A custom clang plugin or perhaps modifications to dxr might be the better bet. Although, the 'callgraph patch' might guide you in modifications to sixgill, assuming that's still a GCC plugin.

Note that the attachment 'analysis results' contains an SQL query against the callgraph sqlite db to find functions which have not been marked static but which have no callers outside their compilation unit. The actual patch, 'callgraph patch' is just a modification to callgraph to record which functions (and methods) have been marked static (in order to support the query in 'analysis results').
Flags: needinfo?(ehren.m)
You need to log in before you can comment on or make changes to this bug.