Skip to content

Conversation

xbauch
Copy link
Contributor

@xbauch xbauch commented Nov 26, 2018

In driver.adb call Follow_Irep on every symbol in symbol table.
In ireps_generator.py reuse To_JSON to implement Follow_Irep: traverse the irep tree to follow I_Symbol_Type nodes. The irep table is not modified: we only change what ireps are referred to in some node (of the irep tree).

@xbauch xbauch force-pushed the testsuite/primitive_pointer branch from 276b48f to 80cd0e2 Compare November 26, 2018 14:04
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to take a closer look tomorrow, but I feel like the additions to the python code need some cleanup and some explanation for what is happening in there.

@@ -51,6 +52,8 @@ package body Driver is
procedure Translate_Standard_Types;
procedure Initialize_CProver_Internal_Variables (Start_Body : Irep);
procedure Add_CProver_Internal_Symbols;
procedure Follow_Type_Declarations (Old_Table : Symbol_Table;
New_Table : in out Symbol_Table);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we create a new symbol table rather than following symbols in the old one?

Also, if you're not reading fron New_Table it should just be out rather than in out I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I'm rewriting the symbols and I don't think I can modify a hash map while iterating over it. The second part: yes, will rewrite to just out.

for Sym_Iter in Old_Table.Iterate loop
declare
Ignored : Boolean;
Unused : Symbol_Maps.Cursor;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused_Inserted and Unused_Position?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied it from a function above this one, but ok, this sounds more descriptive.

@@ -1835,6 +1835,8 @@ package body Tree_Walk is
when E_Record_Subtype => Do_Itype_Record_Subtype (N),
when E_Signed_Integer_Type => Do_Itype_Integer_Type (N),
when E_Floating_Point_Type => Create_Dummy_Irep,
when E_Anonymous_Access_Type => Make_Pointer_Type

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be unrelated to the follow functionality?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, although it is required to make the primitive_pointer test work. So, separate commit or separate PR?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preference for me would be separate PR but separate commit at the least

write(s, "")
write(s, "with GNATCOLL.JSON; use GNATCOLL.JSON;") # JSON
write(s, "with GNATCOLL.JSON; use GNATCOLL.JSON;") # JSON

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated formatting change? I don't really mind this being part of this PR but could you do it in a separate commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be here, will remove.

Value : constant Irep := Current_Symbol.Value;
begin
Modified_Symbol.SymType :=
Follow_Irep (SymType, Follow_Symbol'Access);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be easier to follow if we just passed the Old_Table as a parameter to Follow_Irep and did the Follow_Symbol logic over there? Or is there some other reason why we have to use the function pointer here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was the original plan but I couldn't figure out how to declare Symbol_Table in Ireps.adb. I always ended up with circular dependencies.

@@ -1596,6 +1612,15 @@ def generate_code(self, optimize, schema_file_names):
continuation(b)
write(b, "")

write(b, "function Follow_Irep (L : Irep_List;")
# with indent(b):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented out code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, will be removed.

@@ -1816,6 +1841,98 @@ def generate_code(self, optimize, schema_file_names):
write(b, "end To_JSON;")
write(b, "")

write_comment_block(b, "Follow_Irep")
write(b, "function Follow_Irep (I : Irep;")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this bit is complicated enough to warrant being factored out into its own function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean another python script?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also uncomfortable with how big this new code inserted is. I understand it's codegen stuff, which normally is long, but I'm also under the impression that it has to be factored out into a function, and then called here.

Copy link
Contributor

@NlightNFotis NlightNFotis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just an organisational comment. I'm not too fussed about it. Good job.

@@ -1816,6 +1841,98 @@ def generate_code(self, optimize, schema_file_names):
write(b, "end To_JSON;")
write(b, "")

write_comment_block(b, "Follow_Irep")
write(b, "function Follow_Irep (I : Irep;")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also uncomfortable with how big this new code inserted is. I understand it's codegen stuff, which normally is long, but I'm also under the impression that it has to be factored out into a function, and then called here.

@xbauch xbauch force-pushed the testsuite/primitive_pointer branch from 80cd0e2 to d5f6f99 Compare November 28, 2018 13:30
@xbauch xbauch mentioned this pull request Nov 28, 2018
@xbauch xbauch force-pushed the testsuite/primitive_pointer branch 2 times, most recently from 2b87045 to 79445d0 Compare December 4, 2018 13:11
@NlightNFotis
Copy link
Contributor

@xbauch The tests show that gnat2goto now crashes on (almost?) all tests? Was it like this before, and/or is it depending on another PR going in?

@xbauch
Copy link
Contributor Author

xbauch commented Dec 4, 2018

@NlightNFotis better?

@hannes-steffenhagen-diffblue
Copy link
Contributor

Some of the CI failures may be fixed by a rebase (which you'll need anyway)

@xbauch xbauch force-pushed the testsuite/primitive_pointer branch from 92cec80 to 724d839 Compare December 5, 2018 09:05
sonodtt pushed a commit to sonodtt/gnat2goto that referenced this pull request Dec 6, 2018
Context: array copies are called via a wrapper function - this took the
array length as a parameter. Now this is set directly (the parameter is 
kept and assigned to a dummy var to minimise code change as we might 
want to revert this in future. The dummy var is to prevent gnat error 
over unused var.
Petr Bauch added 2 commits December 6, 2018 14:26
The TO_JSON part at least.
In driver.adb call Follow_Irep on every symbol in symbol table.
In ireps_generator.py reuse to_json to implement follow_irep: traverse the irep
tree to follow I_Symbol_Type ireps.
@xbauch xbauch force-pushed the testsuite/primitive_pointer branch 2 times, most recently from 54cc8c5 to 72a22cd Compare December 6, 2018 15:02
Copy link
Contributor

@NlightNFotis NlightNFotis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks to be in a good shape now.

@xbauch xbauch force-pushed the testsuite/primitive_pointer branch from d2dae7e to 39df83c Compare December 6, 2018 15:56
@xbauch xbauch merged commit 8718af2 into diffblue:master Dec 6, 2018
@xbauch xbauch deleted the testsuite/primitive_pointer branch March 14, 2019 10:24
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.

4 participants