Skip to content

ICE: assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32 #110885

Closed
@WendyWjt

Description

@WendyWjt

Hi I got two confusions when trying to use global_asm and integrate some assembly codes.

  1. I got the internal compiler error listed as below;
  2. The error messages look wierd with arrows confusingly pointing to blankets or some existing labels. (If I just misunderstood them please correct me)

Any Help would be appreciated very much :D

Code

use core::arch::global_asm;

global_asm!(include_str!("./arm/func.S"), options(raw));
global_asm!(include_str!("./bug/bug.s"), options(raw));

fn main() {

}

func.S:

#include "macro_a.S"
#include "macro_b.S"
#include "macro_c.S"

.text
.arch armv8-a+crypto

.globl SOME_FUNC_A
.type SOME_FUNC_A,%function
.align 4
SOME_FUNC_A:
    IN_STP                                      // 寄存器保护
    b.eq .LEnc_1_process                      // 跳转
    b.eq .LEnc_2_process                      // 跳转
    b .LEnc_3_process                         // 跳转

.LEnc_1_process:
    LOAD_HASH_TABLE                            // 加载g
    b.le .LEnc_end                              // 第一次64字节处理完毕,判断剩余长度
    b .LEnc_1_loop                            // 进入循环处理流程

.LEnc_2_process:
    LOAD_HASH_TABLE                                                // load hash table
    b.le .LEnc_end
    b .LEnc_2_loop

.LEnc_3_process:
    LOAD_HASH_TABLE
    b.le .LEnc_end
    b .LEnc_3_loop

.LEnc_1_loop:
    ENC1_LOOP                         // 处理64字节
    b.le .LEnc_end                          // 剩余块数为0, 退出循环
    b .LEnc_1_loop                        // 继续循环

.LEnc_2_loop:
    ENC2_LOOP
    b.le .LEnc_end                          // <= 0
    b .LEnc_2_loop

.LEnc_3_loop:
    ENC3_LOOP
    b.le .LEnc_end                          // <= 0
    b .LEnc_3_loop

.LEnc_end:
    HASH_BLOCK
    OUT_STP

.LEnc_ret:
    ret
.size SOME_FUNC_A,.-SOME_FUNC_A

bug.s:

#include "macro_a.S"
#include "macro_b.S"
#include "macro_c.S"

.globl SOME_FUNC_A
.type SOME_FUNC_A,%function
.align 4
SOME_FUNC_A:
    IN_STP                                      // 寄存器保护
    b.eq .LEnc_1_process                      // 跳转1处理逻辑
    b.eq .LEnc_2_process                      // 跳转2处理逻辑
    b .LEnc_3_process                         // 跳转3处理逻辑

.LEnc_1_process:
    b .LEnc_1_loop                            // 进入循环处理流程

.LEnc_1_loop:
    b .LEnc_1_loop                        // 继续循环
.size SOME_FUNC_A,.-SOME_FUNC_A

Meta

rustc --version --verbose:

<version>
rustc 1.67.0 (fc594f156 2023-01-24)
binary: rustc
commit-hash: fc594f15669680fa70d255faec3ca3fb507c3405
commit-date: 2023-01-24
host: aarch64-unknown-linux-gnu
release: 1.67.0
LLVM version: 15.0.6

Error output

<output>
Backtrace

<backtrace>

   Compiling main v0.1.0 (/usr1/w00620137/rust_dev/test/main)
error: unrecognized instruction mnemonic
   |
note: instantiated into assembly here
  --> <inline asm>:12:16
   |
12 |     IN_STP                                      // 寄存器保护
   |                ^

error: unrecognized instruction mnemonic
   |
note: instantiated into assembly here
  --> <inline asm>:18:22
   |
18 |     LOAD_HASH_TABLE                            // 加载g
   |                      ^

error: unrecognized instruction mnemonic
   |
note: instantiated into assembly here
  --> <inline asm>:23:27
   |
23 |     LOAD_HASH_TABLE                                                // load hash table
   |                           ^

error: unrecognized instruction mnemonic
   |
note: instantiated into assembly here
  --> <inline asm>:29:12
   |
29 |     b.le .LEnc_end
   |            ^

error: unrecognized instruction mnemonic
   |
note: instantiated into assembly here
  --> <inline asm>:33:37
   |
33 |     ENC1_LOOP                         // 处理64字节
   |                                     ^

error: unrecognized instruction mnemonic
   |
note: instantiated into assembly here
  --> <inline asm>:39:28
   |
39 |     b.le .LEnc_end                          // <= 0
   |                            ^

error: unrecognized instruction mnemonic
   |
note: instantiated into assembly here
  --> <inline asm>:44:33
   |
44 |     b.le .LEnc_end                          // <= 0
   |                                 ^

error: unrecognized instruction mnemonic
   |
note: instantiated into assembly here
  --> <inline asm>:53:5
   |
53 | .size SOME_FUNC_A,.-SOME_FUNC_A
   |     ^

error: unrecognized instruction mnemonic
   |
note: instantiated into assembly here
  --> <inline asm>:53:21
   |
53 | .size SOME_FUNC_A,.-SOME_FUNC_A
   |                     ^

error: symbol 'SOME_FUNC_A' is already defined
   |
note: instantiated into assembly here
  --> <inline asm>:62:48
   |
62 |     IN_STP                                      // 寄存器保护
   |                                                ^

thread 'rustc' panicked at 'assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32', compiler/rustc_span/src/lib.rs:1698:17
stack backtrace:
   0: rust_begin_unwind
             at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:64:14
   2: core::panicking::panic
             at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:111:5
   3: <rustc_span::SourceFile>::lookup_file_pos
   4: <rustc_span::SourceFile>::lookup_file_pos_with_col_display
   5: <rustc_span::source_map::SourceMap>::lookup_char_pos
   6: <rustc_errors::emitter::EmitterWriter>::get_multispan_max_line_num
   7: <rustc_errors::emitter::EmitterWriter>::emit_messages_default
   8: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic
   9: <rustc_errors::json::Diagnostic>::from_errors_diagnostic
  10: <rustc_errors::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
  11: <rustc_errors::HandlerInner>::emit_diagnostic
  12: <() as rustc_errors::diagnostic_builder::EmissionGuarantee>::diagnostic_builder_emit_producing_guarantee
  13: <rustc_codegen_ssa::back::write::SharedEmitterMain>::check
  14: <rustc_codegen_ssa::back::write::OngoingCodegen<rustc_codegen_llvm::LlvmCodegenBackend>>::join
  15: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::join_codegen
  16: <rustc_interface::queries::Linker>::link
  17: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  18: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.67.0 (fc594f156 2023-01-24) running on aarch64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `main` due to 10 previous errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inline-assemblyArea: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions