Skip to content

Eliminate usage of volatile variables used to prevent dead code elimination #1444

Description

@kunalspathak

Today, there are various uses of volatile variable to make sure the result (and hence the operation itself) doesn't get eliminated through dead code. There is guidance here that describes it. However volatile variables are expensive on ARM64 and should be avoided whenever possible. With volatile variables in place, the measurement could get hidden by just the cost of memory barriers needed to access volatile variable. We should consider eliminating this pattern (specially from BenchStone benchmarks) and instead either

  • accumulate result in a private variable which gets returned
  • accumulate the result in an array that gets returned
  • pass the result to a method that is marked with [NoInling].

I can do this for some benchmarks when I get time. But just want to listen to what others think about it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions