avr-llvm / llvm

[MERGED UPSTREAM] AVR backend for the LLVM compiler library
220 stars 21 forks source link

Data layout specification is incompatible with atomic loads and stores #214

Closed shepmaster closed 8 years ago

shepmaster commented 8 years ago

Rust generates atomic loads and stores using the alignment specified by the data layout. However, it's forbidden to load from e.g. a 16-bit value with less than 16-bits of alignment.

This can be fixed by changing the data layout:

e-p:16:16:16-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-n8

Although I'm not sure what all potential fallout this might have (#213 maybe?)

rjordans commented 8 years ago

Do we want/have the floating point specified in the above data layout yet?

shepmaster commented 8 years ago

@rjordans ¯_(ツ)_/¯ It's already there in some form.

dylanmckay commented 8 years ago

This seems like a good idea. Would like to wait until you updated #213 so I can check it fixes it.

shepmaster commented 8 years ago

Would like to wait until you updated #213 so I can check it fixes it.

Oh, #213 happens after I've made this change locally; I'm worried that this change causes that issue. Still trying to reproduce and reduce that issue :-)

Amanieu commented 8 years ago

Since avr doesn't support atomic operations you should add "max-atomic-width": 0 to the Rust target specification. This will disable atomic types in libcore.

shepmaster commented 8 years ago

Since avr doesn't support atomic operations you should add "max-atomic-width": 0 to the Rust target specification. This will disable atomic types in libcore.

We actually have some minimal emulation of atomic types: disable interrupts, perform the operation, re-enable interrupts.

dylanmckay commented 8 years ago

Fixed in 5f12f20bafa50b178395177cb98aef7de5f68e73