-
Notifications
You must be signed in to change notification settings - Fork 273
Java frontend: clean up unused clinit symbols #1813
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
Merged
smowton
merged 2 commits into
diffblue:develop
from
smowton:smowton/fix/cleanup-unused-clinits
Feb 14, 2018
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+251 Bytes
regression/cbmc-java/lazyloading_synthetic_method_cleanup1/Test.class
Binary file not shown.
22 changes: 22 additions & 0 deletions
22
regression/cbmc-java/lazyloading_synthetic_method_cleanup1/Test.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
public class Test { | ||
|
||
// Refers to, but never instantiates or refers to static fields of, Unused. | ||
// Thus a clinit-wrapper for Unused should be created, but subsequently | ||
// discarded. | ||
Unused u; | ||
|
||
public static void main() { | ||
|
||
} | ||
|
||
} | ||
|
||
class Unused { | ||
|
||
static int x; | ||
|
||
static { | ||
x = 1; | ||
} | ||
|
||
} |
Binary file added
BIN
+268 Bytes
regression/cbmc-java/lazyloading_synthetic_method_cleanup1/Unused.class
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
...ession/cbmc-java/lazyloading_synthetic_method_cleanup1/check_clinit_normally_present.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CORE | ||
Test.class | ||
--show-goto-functions | ||
java::Unused::clinit_wrapper | ||
Unused\.<clinit>\(\) | ||
|
6 changes: 6 additions & 0 deletions
6
...cbmc-java/lazyloading_synthetic_method_cleanup1/check_clinit_removed_by_lazy_loading.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CORE | ||
Test.class | ||
--lazy-methods --show-goto-functions | ||
-- | ||
java::Unused::clinit_wrapper | ||
Unused\.<clinit>\(\) |
5 changes: 5 additions & 0 deletions
5
regression/cbmc-java/lazyloading_synthetic_method_cleanup1/check_runs_with_lazy_loading.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CORE | ||
Test.class | ||
--lazy-methods | ||
VERIFICATION SUCCESSFUL | ||
|
Binary file added
BIN
+252 Bytes
regression/cbmc-java/lazyloading_synthetic_method_cleanup2/Test.class
Binary file not shown.
26 changes: 26 additions & 0 deletions
26
regression/cbmc-java/lazyloading_synthetic_method_cleanup2/Test.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
public class Test { | ||
|
||
// Refers to, but never instantiates or refers to static fields of, Unused. | ||
// Thus a clinit-wrapper for Unused should be created, but subsequently | ||
// discarded. | ||
Unused1 u; | ||
|
||
public static void main() { | ||
|
||
} | ||
|
||
} | ||
|
||
class Unused1 extends Unused2 { | ||
|
||
} | ||
|
||
class Unused2 { | ||
|
||
static int x; | ||
|
||
static { | ||
x = 1; | ||
} | ||
|
||
} |
Binary file added
BIN
+176 Bytes
regression/cbmc-java/lazyloading_synthetic_method_cleanup2/Unused1.class
Binary file not shown.
Binary file added
BIN
+269 Bytes
regression/cbmc-java/lazyloading_synthetic_method_cleanup2/Unused2.class
Binary file not shown.
7 changes: 7 additions & 0 deletions
7
...ession/cbmc-java/lazyloading_synthetic_method_cleanup2/check_clinit_normally_present.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CORE | ||
Test.class | ||
--show-goto-functions | ||
java::Unused1::clinit_wrapper | ||
java::Unused2::clinit_wrapper | ||
Unused2\.<clinit>\(\) | ||
|
7 changes: 7 additions & 0 deletions
7
...cbmc-java/lazyloading_synthetic_method_cleanup2/check_clinit_removed_by_lazy_loading.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CORE | ||
Test.class | ||
--lazy-methods --show-goto-functions | ||
-- | ||
java::Unused1::clinit_wrapper | ||
java::Unused2::clinit_wrapper | ||
Unused2\.<clinit>\(\) |
5 changes: 5 additions & 0 deletions
5
regression/cbmc-java/lazyloading_synthetic_method_cleanup2/check_runs_with_lazy_loading.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CORE | ||
Test.class | ||
--lazy-methods | ||
VERIFICATION SUCCESSFUL | ||
|
Binary file added
BIN
+333 Bytes
regression/cbmc-java/lazyloading_synthetic_method_cleanup3/Test.class
Binary file not shown.
22 changes: 22 additions & 0 deletions
22
regression/cbmc-java/lazyloading_synthetic_method_cleanup3/Test.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
public class Test { | ||
|
||
public static void main() { | ||
|
||
} | ||
|
||
public static Opaque unused() { | ||
|
||
// Should cause jbmc to create a synthetic static initialiser for Opaque, | ||
// but because this function isn't called by main() it should then be | ||
// cleaned up as unused. | ||
return Opaque.field; | ||
|
||
} | ||
|
||
} | ||
|
||
class Opaque { | ||
|
||
public static Opaque field; | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...ession/cbmc-java/lazyloading_synthetic_method_cleanup3/check_clinit_normally_present.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CORE | ||
Test.class | ||
--show-goto-functions | ||
java::Opaque\.<clinit>:\(\)V | ||
java::Opaque::clinit_wrapper |
6 changes: 6 additions & 0 deletions
6
...cbmc-java/lazyloading_synthetic_method_cleanup3/check_clinit_removed_by_lazy_loading.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CORE | ||
Test.class | ||
--lazy-methods --show-goto-functions | ||
-- | ||
java::Opaque\.<clinit>:\(\)V | ||
java::Opaque::clinit_wrapper |
5 changes: 5 additions & 0 deletions
5
regression/cbmc-java/lazyloading_synthetic_method_cleanup3/check_runs_with_lazy_loading.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CORE | ||
Test.class | ||
--lazy-methods | ||
VERIFICATION SUCCESSFUL | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is this first condition false for symbol entries that are code (surely it is either a user function or a synthetic function?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be read as
is-normal-method || is-synthetic-method
, which I think matches your expectation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - but when is the above condition false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, when the method belongs to a different frontend. For Java that case is currently unsupported, but cross-language or GOTO-binary + Java or similar possibilities are supported by our current architecture, so it would be best not to rule that case out when it's easy to support.
Better summary of this line: "if this method relates to this languaget" (otherwise leave it alone)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes - which matches with the comment 👍