Skip to content

[MLIR][LLVM] Failed to round-trip inlined asm #135709

@Kuree

Description

@Kuree

Godbolt: https://godbolt.org/z/7YnW8KGvY

Error message:

Operand for indirect constraint must have elementtype attribute
  call void asm sideeffect "movl $$3,$0", "=*imr,~{memory},~{dirflag},~{fpsr},~{flags}"(ptr %2)

Input:

; ModuleID = './bug.c'
source_filename = "./bug.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32 @main() #0 {
entry:
  %retval = alloca i32, align 4
  %x = alloca i32, align 4
  store i32 0, ptr %retval, align 4
  call void asm sideeffect "movl $$3,$0", "=*imr,~{memory},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %x) #1, !srcloc !6
  ret i32 0
}

attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3, !4}
!llvm.ident = !{!5}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{i32 7, !"frame-pointer", i32 2}
!5 = !{!"clang version 21.0.0git (https://github.com/llvm/llvm-project 9fb792496687df1136d78e828cffe4f7f04a7043)"}
!6 = !{i64 44}

How to reproduce:

mlir-translate --import-llvm inputl.ll | mlir-translate --mlir-to-llvmir

The input is a legal llvm file. Compile to x86:

clang input.ll -o test

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions