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

common/bitutil: use result of TestBytes to prevent dead code elimination #19846

Merged
merged 1 commit into from
Jul 17, 2019

Conversation

dr2chase
Copy link
Contributor

…nation

Gollvm has very aggressive dead code elimination that completely
removes one of these two benchmarks. To prevent this, use the
result of the benchmark (a boolean), and to be "fair", make the
transformation to both benchmarks.

To be reliably assured of not removing the code, "use" means
assigning to an exported global. Non-exported globals and
//go:noinline functions are possibly subject to this optimization.

…nation

Gollvm has very aggressive dead code elimination that completely
removes one of these two benchmarks.  To prevent this, use the
result of the benchmark (a boolean), and to be "fair", make the
transformation to both benchmarks.

To be reliably assured of not removing the code, "use" means
assigning to an exported global.  Non-exported globals and
//go:noinline functions are possibly subject to this optimization.
@fjl
Copy link
Contributor

fjl commented Jul 17, 2019

Thanks! While you're here with this change: would be nice if the compiler recognized _ = expr and never inlined/DCEd expr for these cases :)

@fjl fjl changed the title bitutil_test: use result of [safe]TestBytes to thwart dead code elimi… common/bitutil: use result of [safe]TestBytes to prevent dead code elimination Jul 17, 2019
@fjl fjl changed the title common/bitutil: use result of [safe]TestBytes to prevent dead code elimination common/bitutil: use result of TestBytes to prevent dead code elimination Jul 17, 2019
@fjl fjl merged commit 31a1f16 into ethereum:master Jul 17, 2019
@dr2chase
Copy link
Contributor Author

I'll bring it up, we might want to do something more explicit, maybe a function "Use(interface{})" that is recognized as an intrinsic, causing the effect but discarding the call and interface conversion.

gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Dec 19, 2024
…ion (ethereum#19846)

Gollvm has very aggressive dead code elimination that completely
removes one of these two benchmarks.  To prevent this, use the
result of the benchmark (a boolean), and to be "fair", make the
transformation to both benchmarks.

To be reliably assured of not removing the code, "use" means
assigning to an exported global.  Non-exported globals and
//go:noinline functions are possibly subject to this optimization.
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Dec 21, 2024
…ion (ethereum#19846)

Gollvm has very aggressive dead code elimination that completely
removes one of these two benchmarks.  To prevent this, use the
result of the benchmark (a boolean), and to be "fair", make the
transformation to both benchmarks.

To be reliably assured of not removing the code, "use" means
assigning to an exported global.  Non-exported globals and
//go:noinline functions are possibly subject to this optimization.
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Dec 26, 2024
…ion (ethereum#19846)

Gollvm has very aggressive dead code elimination that completely
removes one of these two benchmarks.  To prevent this, use the
result of the benchmark (a boolean), and to be "fair", make the
transformation to both benchmarks.

To be reliably assured of not removing the code, "use" means
assigning to an exported global.  Non-exported globals and
//go:noinline functions are possibly subject to this optimization.
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Dec 28, 2024
…ion (ethereum#19846)

Gollvm has very aggressive dead code elimination that completely
removes one of these two benchmarks.  To prevent this, use the
result of the benchmark (a boolean), and to be "fair", make the
transformation to both benchmarks.

To be reliably assured of not removing the code, "use" means
assigning to an exported global.  Non-exported globals and
//go:noinline functions are possibly subject to this optimization.
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.

2 participants