Stream: t-compiler/help

Topic: i1 for function pointer in LLVM output?


osa1 (Aug 04 2020 at 09:00, on Zulip):

I see this line in LLVM output of a crate: (context: https://github.com/rust-lang/rust/issues/75089)

; core::fmt::num::imp::<impl core::fmt::Display for i32>::fmt
; Function Attrs: nounwind
declare zeroext i1 @"_ZN4core3fmt3num3imp52_$LT$impl$u20$core..fmt..Display$u20$for$u20$i32$GT$3fmt17h9ba9fea9cadf7bd5E"(i32* noalias readonly align 4 dereferenceable(4), %"core::fmt::Formatter"* align 4 dereferenceable(36)) unnamed_addr #1

I'm confused about the i1 part here. I don't understand LLVM syntax in details, but I think this is declaring address of a function, but the type is i1 which is just one bit? This can't be right. Am I missing anything? What exactly does this line declare?

nagisa (Aug 04 2020 at 14:44, on Zulip):

that's the return type.

osa1 (Aug 04 2020 at 14:54, on Zulip):

Interesting.. how can it return a single bit value for Result<(), Error>? It takes two arguments so I think it's not taking an argument for the return value Erroreither.

Jonas Schievink (Aug 04 2020 at 14:56, on Zulip):

Error is a ZST, so you only need 1 bit to represent the result

osa1 (Aug 04 2020 at 15:00, on Zulip):

Makes sense, thanks.

Last update: Sep 27 2020 at 14:30UTC