Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add various features. Fix one bug. #191

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

ampresent
Copy link

@ampresent ampresent commented Nov 26, 2021

  • bugfix
    location hasher bugfix

  • feature
    callbacks: PLUGIN_FINISH_PARSE_FUNCTION, PLUGIN_INCLUDE_FILE
    attributes: typedecl.stub typedecl.main_variant,decl.attributes, vardecl.node, varnode.referred/referring, decl.external, decl.context
    attributes made writeable: decl.static, decl.initial, decl.public
    global: current_function_decl, main_input_filename, get_location
    pretty print: print_declaration support
    function: decl.walk_tree

Yihao Wu added 19 commits November 25, 2021 22:12
This is one great callbacks provided by GCC.

Signed-off-by: Yihao Wu <[email protected]>
We have set_location. Why not get_location? This tells us much information
on variable and function and more locations.

Signed-off-by: Yihao Wu <[email protected]>
We definitely want to know the filename we are compiling.

Signed-off-by: Yihao Wu <[email protected]>
There are times we want to know where the structure is defined or sth.

Signed-off-by: Yihao Wu <[email protected]>
This is very frequently used when working in all different callbacks.

Signed-off-by: Yihao Wu <[email protected]>
We want to know for example, is this variable defined in a translation unit
or in a function scope, or which struct contains this field.

Signed-off-by: Yihao Wu <[email protected]>
This is useful when, for example we want to know what data structure
has a function accessed, without caring qualifiers.

Signed-off-by: Yihao Wu <[email protected]>
print_declaration gives much more graceful results than dump_generic_node
when the node is decl. On the other hand, dump_generic_node always gives
very ugly ones.

Signed-off-by: Yihao Wu <[email protected]>
This is needed when we want to use GCC's pretty print to do some code
generation work.

Signed-off-by: Yihao Wu <[email protected]>
This is needed when we want to use GCC's pretty print to do some code
generation work. For example, assigning NULL to initial, makes it have
no initial value any more.

Signed-off-by: Yihao Wu <[email protected]>
This is needed when we want to use GCC's pretty print to do some code
generation work.

Signed-off-by: Yihao Wu <[email protected]>
This is provided by GCC, better have it.

Signed-off-by: Yihao Wu <[email protected]>
I've encountered strange bugs caused by this location hasher. So better
not rely on pointer address, but the real content. As an example, the
find-global-state test case was wrong because of this wrong hasher.

Notice these two snippets:

1)
int test2(int p)
{
  static int q = 0;
  q += p;
  return p * q;
}

2)
int test2(int p)
{
  static int q = 0;
  q = q + p;
  return p * q;
}

These two are not identical in compilers eyes. With "q += p", q is only
acccessed once, the intermediate value q+p is nothing but a temporary value
asserted by the compiler, eg. "q.2". While with "q = q + p", q is accessed
twice, because q at both lhs and rhs are the original q, not temp variable.

Signed-off-by: Yihao Wu <[email protected]>
Better support all callbacks which GCC supports.

Signed-off-by: Yihao Wu <[email protected]>
Of course we want this not only for types but declaraions too.
People give various attributes to functions and variables.

Signed-off-by: Yihao Wu <[email protected]>
Cgraph gives us callers and callees, and Varpool gives us referring and
referred. It's good to have themtoo.

Signed-off-by: Yihao Wu <[email protected]>
Just like FunctionDecl.node points to function nodes, they are similar.

Signed-off-by: Yihao Wu <[email protected]>
GCC supports not only walking of gimple, but general purpose decl.
It's good to have them. For example we want to walk down the of
initializing tree a global data structure variable.

Signed-off-by: Yihao Wu <[email protected]>
To tell a function is inline or not. Note that this only indicates if the
functions is attributed with "inline", it can't tell whether gcc really
decides to inline it.

Signed-off-by: Yihao Wu <[email protected]>
@ampresent
Copy link
Author

ampresent commented Nov 26, 2021

  • feature

attributes: functionDecl.inline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant