Skip to content

Cleanup duplicate static inline functions at/after linking #1987

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

Closed
wants to merge 1 commit into from

Conversation

tautschnig
Copy link
Collaborator

No description provided.

#ifndef TEST2
#include "foo.h"
#else
inline void foo(int x)
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment in either the code or the .desc files what you're expecting here. I might be being thick, but I don't follow what you're expecting to differ, except that the non-static inline foo would leave an external-linkage version of the function body around for a potential linked object expecting an extern void foo(int), which doesn't in fact exist in this test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have added explanations in the .desc files.

Copy link
Contributor

Choose a reason for hiding this comment

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

Aha, excellent, thankyou!

@@ -1,4 +1,4 @@
static int foo(int a)
{
return a+1;
return a + 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This makes sure the functions are actually different so that the static variant doesn't get ignored after the changes in this PR.

continue;

std::string new_name = id2string(rename_it->second);
std::string::size_type suffix_pos = new_name.find("$link");
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of this grungy string decomposition, how about annotating such symbols with a comment ID_C_original_function_identifier or such?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That would seem nice, but I'm struggling to find a good place to put it in a symbolt?

Copy link
Contributor

Choose a reason for hiding this comment

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

I've been sticking annotations like this on the type myself. We should agree on a policy though, or make a breaking change to add symbolt::attributes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I do think that the name and the type are really disjoint, so I'd much rather sort this out via some to-be-added symbolt::attributes.

return false;
return (new_symbol.is_file_local || old_symbol.is_file_local) &&
(new_symbol.type.id() != ID_code ||
new_symbol.value == exprt("compiled") ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Factor out this magic tag exprt?

@@ -634,3 +634,40 @@ void goto_programt::compute_incoming_edges()
}
}

bool goto_programt::instructiont::equal(const instructiont &other) const
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: I'd expect equals, or operator==

@@ -634,3 +634,40 @@ void goto_programt::compute_incoming_edges()
}
}

bool goto_programt::instructiont::equal(const instructiont &other) const
{
return type == other.type && code == other.code && guard == other.guard &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Reading ease: suggest break after each &&

return false;

long jump_difference1 = 0;
if(!ins.targets.empty())
Copy link
Contributor

Choose a reason for hiding this comment

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

Should compare other targets I think -- e.g. catch instructions have several targets.

@tautschnig
Copy link
Collaborator Author

@smowton: all comments either addressed or commented on. @peterschrammel If you have any tests exercising goto-diff beyond what's run as regular regression tests then it may be worth checking with those (due to my refactoring of equality tests).

@smowton
Copy link
Contributor

smowton commented Apr 19, 2018

Looks good, except I'd move the target distance comparison inside instructiont::equals and make goto_programt::equals trivial, as at the moment two different GOTOs would compare alike according to instructiont::equals but unequal in the context of a GOTO program, which doesn't seem quite right.

@tautschnig
Copy link
Collaborator Author

@smowton I was about to implement your suggestion but then figured I'd disagree when looking on how this would impact the unified diff implementation: consider if(x) goto L; some_code; more_code; L: a_target; vs. if(x) goto L; some_code; L: a_target; - I my opinion the programs are different, and the difference lies in some_code;, but all other instructions are the same. The fact that the relative jump distance differs is just an artefact of the additional instruction.

@smowton
Copy link
Contributor

smowton commented Apr 19, 2018

Hmmmm, okay, I won't argue the point further

@peterschrammel
Copy link
Member

@tautschnig, we are retesting this version on our benchmarks.

@peterschrammel
Copy link
Member

@tautschnig, the output is identical to developon our tests.

Copy link
Member

@peterschrammel peterschrammel left a comment

Choose a reason for hiding this comment

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

Please rebase.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

Passed Diffblue compatibility checks (cbmc commit: fd9896f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86271881

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

Passed Diffblue compatibility checks (cbmc commit: 623340a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88760998

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: 9a0de06).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/95548556

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: dcf5904).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/103507544

@tautschnig tautschnig force-pushed the linking-cleanup branch 2 times, most recently from 3b94bf0 to 15dbc4d Compare April 4, 2019 10:08
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: 15dbc4d).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/107061824

@codecov
Copy link

codecov bot commented May 7, 2021

Codecov Report

Base: 78.43% // Head: 78.49% // Increases project coverage by +0.06% 🎉

Coverage data is based on head (1ee95db) compared to base (d7099ae).
Patch coverage: 58.62% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1987      +/-   ##
===========================================
+ Coverage    78.43%   78.49%   +0.06%     
===========================================
  Files         1670     1670              
  Lines       191671   191691      +20     
===========================================
+ Hits        150331   150470     +139     
+ Misses       41340    41221     -119     
Impacted Files Coverage Δ
src/goto-programs/link_goto_model.cpp 78.00% <40.00%> (-9.50%) ⬇️
src/linking/linking.cpp 69.32% <100.00%> (ø)
src/util/bitvector_expr.h 97.41% <0.00%> (+0.46%) ⬆️
src/util/symbol_table.cpp 91.30% <0.00%> (+2.17%) ⬆️
src/util/type.h 98.68% <0.00%> (+7.89%) ⬆️
src/util/validate_helpers.h 100.00% <0.00%> (+11.11%) ⬆️
src/big-int/bigint.cc 89.00% <0.00%> (+14.26%) ⬆️
src/util/validate_expressions.cpp 93.75% <0.00%> (+15.62%) ⬆️
src/util/string_hash.cpp 45.45% <0.00%> (+18.18%) ⬆️
src/util/validate_types.cpp 93.33% <0.00%> (+56.66%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@TGWDB
Copy link
Contributor

TGWDB commented Sep 13, 2021

@tautschnig Any chance of a push to rerun the CI jobs (including the new/missing one)?

This will avoid some occurrences of function$linkN names that are confusing to
users, in particular when specifying loop unwinding limits.
@TGWDB
Copy link
Contributor

TGWDB commented May 3, 2023

Closing due to age (no further comment on PR content), please reopen with rebase on develop if you intent to continue this work.

@TGWDB TGWDB closed this May 3, 2023
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.

7 participants