Skip to content

slice::as_chunks lowered to poison #63

@xdoardo

Description

@xdoardo

This test generates poison values when targeting CHERIoT:

define dso_local { ptr addrspace(200), i32 } @chunks4(ptr addrspace(200) align 1 %x.0, i32 %x.1) unnamed_addr addrspace(200) #2 {
start:
  %_2 = alloca [32 x i8], align 8, addrspace(200)
; call <[u8]>::as_chunks::<4>
  call void @_RINvMNtCseGUygyxNKUp_4core5sliceSh9as_chunksKj4_ECs9We5GNEBTqK_15slice_as_chunks(ptr addrspace(200) sret([32 x i8]) align 8 %_2, ptr addrspace(200) align 1 %x.0, i32 %x.1, ptr addrspace(200) align 8 @alloc_009ef07d224df88a1692249518be7cbf) #6
  %_0.0 = load ptr addrspace(200), ptr addrspace(200) %_2, align 8
  %0 = getelementptr inbounds i8, ptr addrspace(200) %_2, i32 8
  %_0.1 = load i32, ptr addrspace(200) %0, align 8
  %1 = insertvalue { ptr addrspace(200), i32 } poison, ptr addrspace(200) %_0.0, 0
  %2 = insertvalue { ptr addrspace(200), i32 } %1, i32 %_0.1, 1
  ret { ptr addrspace(200), i32 } %2
}

...


; <[u8]>::as_chunks_unchecked::<4>
; Function Attrs: inlinehint nounwind
define dso_local { ptr addrspace(200), i32 } @_RINvMNtCseGUygyxNKUp_4core5sliceSh19as_chunks_uncheckedKj4_ECs9We5GNEBTqK_15slice_as_chunks(ptr addrspace(200) align 1 %self.0, i32 %self.1, ptr addrspace(200) align 8 %0) unnamed_addr addrspace(200) #0 {
...

bb4:                                              ; preds = %bb5
  %_13.0 = load ptr addrspace(200), ptr addrspace(200) %data, align 8
  %_13.1 = load i32, ptr addrspace(200) %new_len, align 4
  %2 = insertvalue { ptr addrspace(200), i32 } poison, ptr addrspace(200) %_13.0, 0
  %3 = insertvalue { ptr addrspace(200), i32 } %2, i32 %_13.1, 1
  ret { ptr addrspace(200), i32 } %3
...

I think it might be due to some checks done in MIR.

Metadata

Metadata

Assignees

Labels

bugA non-panicking bug in the compiler.needs investigationThe solution is not obvious or feasibility must be studied.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions