Skip to content

Runtime error when using UBSan with bfloat16 conversion intrinsic #61983

@ostannard

Description

@ostannard

When this code is compiled for AArch64 with UBSan, it reports a UBSan error, even though this is valid code:

#include <arm_neon.h>

float foo(__bf16 a) {
  return vcvtah_f32_bf16(a);
}
$ /work/llvm/build/bin/clang --target=aarch64--none-eabi -march=armv8.2-a+bf16 -c test.c -o - -S -O1 -fsanitize=undefined -fsanitize-minimal-runtime -fno-sanitize-recover
        .text
        .file   "test.c"
        .globl  foo                             // -- Begin function foo
        .p2align        2
        .type   foo,@function
foo:                                    // @foo
        .cfi_startproc
// %bb.0:                               // %entry
        stp     x29, x30, [sp, #-16]!           // 16-byte Folded Spill
        .cfi_def_cfa_offset 16
        mov     x29, sp
        .cfi_def_cfa w29, 16
        .cfi_offset w30, -8
        .cfi_offset w29, -16
        bl      __ubsan_handle_type_mismatch_minimal_abort
.Lfunc_end0:
        .size   foo, .Lfunc_end0-foo
        .cfi_endproc
                                        // -- End function
        .ident  "clang version 17.0.0 ([email protected]:llvm/llvm-project.git 626b7e5dd249f569203e024141c1a2a0f618df9c)"
        .section        ".note.GNU-stack","",@progbits
        .addrsig

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions