Skip to content

Atomic instructions unsupported & Cause crashing of clang #49

Description

@AzureianGH

(command: ez80-clang -S -o C:\CEdev\examples\hello_world\src\test.S .\tests\00\out.ll -nostdinc -Xclang -fforce-mangle-main-argc-argv -fno-autolink -fno-addrsig -fno-threadsafe-statics -fno-aligned-allocation -mllvm -profile-guided-section-prefix=false -mllvm -z80-gas-style -ffunction-sections -fdata-sections -fno-math-errno -D__TICE__=1 -DNDEBUG=1)

fatal error: error in backend: unable to legalize instruction: %17:_(s8), %18:_(s1) = G_ATOMIC_CMPXCHG_WITH_SUCCESS %10:_(p0), %19:_, %15:_ :: (load store acquire acquire (s8) on %ir._cctor_init_d) (in function: _cctor_check)
PLEASE submit a bug report to https://github.com/CE-Programming/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: C:\\CEdev\\bin\\ez80-clang.exe -S -o C:\\CEdev\\examples\\hello_world\\src\\test.S .\\tests\\00\\out.ll -nostdinc -Xclang -fforce-mangle-main-argc-argv -fno-autolink -fno-addrsig -fno-threadsafe-statics -fno-aligned-allocation -mllvm -profile-guided-section-prefix=false -mllvm -z80-gas-style -ffunction-sections -fdata-sections -fno-math-errno -D__TICE__=1 -DNDEBUG=1
1.      Code generation
2.      Running pass 'Function Pass Manager' on module '.\tests\00\out.ll'.
3.      Running pass 'Legalizer' on function '@_cctor_check'
Exception Code: 0xE0000046
#0 0x76424984 (C:\WINDOWS\System32\KERNELBASE.dll+0x164984)
#1 0x003b4d06 (C:\CEdev\bin\ez80-clang.exe+0x2c4d06)
#2 0x01000000 (C:\CEdev\bin\ez80-clang.exe+0xf10000)
ez80-clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 19.1.0 (https://github.com/CE-Programming/llvm-project ef28e9c54cd1333a6091ab2ffbd315b465fc5090)
Target: ez80
Thread model: posix
InstalledDir: C:\CEdev\bin
ez80-clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.

When compiling LLVM IR, ez80-clang crashes in the SelectionDAG/GlobalISel Legalizer pass. The failure occurs when compiling a cmpxchg instruction.

Reproducible:

@_cctor_init_state = global [1 x i8] [i8 0], align 1

define void @_cctor_check(i32 %_cctor_init_a) {
entry:
    %_cctor_init_c = zext i32 %_cctor_init_a to i64
    %_cctor_init_d = getelementptr inbounds [1 x i8], ptr @_cctor_init_state, i64 0, i64 %_cctor_init_c
    
    ; CMPXCHG kills it here
    %_cctor_init_cmp = cmpxchg ptr %_cctor_init_d, i8 0, i8 1 acquire acquire
    ret void
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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