Skip to content

LLVM "Can't select" error while compiling onewire crate #166

Open
@Gaelan

Description

@Gaelan

While trying to compile the onewire crate, I ran into this:

$ rustup run avr-toolchain xargo build --target avr-atmega328p --release
    Updating crates.io index
  Downloaded onewire v0.3.13
   Compiling byteorder v1.3.4
   Compiling onewire v0.3.13
LLVM ERROR: Cannot select: 0x7fd640068b38: i8 = ROL 0x7fd640067908
  0x7fd640067908: i8 = ROL 0x7fd640068f48
    0x7fd640068f48: i8 = ROL 0x7fd6400678a0
      0x7fd6400678a0: i8 = add nsw 0x7fd640067428, Constant:i8<-31>
        0x7fd640067428: i8,ch = load<(dereferenceable load 1 from %ir.0, !range !9)> 0x7fd63efb77a8, 0x7fd640067768, undef:i16
          0x7fd640067768: i16,ch = CopyFromReg 0x7fd63efb77a8, Register:i16 %0
            0x7fd640068ee0: i16 = Register %0
          0x7fd6400673c0: i16 = undef
        0x7fd640067560: i8 = Constant<-31>
In function: _ZN7onewire7ds18b2017MeasureResolution7time_ms17hd07d86a70e0fb2a8E
error: Could not compile `onewire`.

To learn more, run the command again with --verbose.

The symbol mentioned by the error is this time_ms method:

#[repr(u8)]
#[derive(Debug, Copy, Clone)]
pub enum MeasureResolution {
    TC8 = 0b0001_1111,
    TC4 = 0b0011_1111,
    TC2 = 0b0101_1111,
    TC = 0b0111_1111,
}

impl MeasureResolution {
    pub fn time_ms(&self) -> u16 {
        match self {
            &MeasureResolution::TC8 => 94,
            &MeasureResolution::TC4 => 188,
            &MeasureResolution::TC2 => 375,
            &MeasureResolution::TC => 750,
        }
    }
}

This presumably is an LLVM bug, but I'm filing here first because I have no idea how close the llvm fork here is to upstream, and I don't want to file a bug report for something that's already fixed there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions