llvm-cbe
llvm-cbe copied to clipboard
volatile dropped
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
The problem happens for reading from an address just as for writing to an address.
Philipp