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

volatile dropped #3

Open
spth opened this issue Sep 21, 2016 · 1 comment
Open

volatile dropped #3

spth opened this issue Sep 21, 2016 · 1 comment

Comments

@spth
Copy link

@spth spth commented Sep 21, 2016

A common idiom for memory-mapped I/O is this:

void f(void)
{
  (*(volatile uint8_t*)42) = 23;
}

clang-3.8 correctly compiles this into a volatile store in LLVM IR:

define void @f() #0 {
  store volatile i8 23, i8* inttoptr (i64 42 to i8*), align 1
  ret void
}

However, the cbe drops the volatile:

void f(void) {
  *((uint8_t*)(uintptr_t)UINT64_C(42)) = 23;
}

Philipp

@spth
Copy link
Author

@spth spth commented Sep 21, 2016

The problem happens for reading from an address just as for writing to an address.

Philipp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.