llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.44k stars 12.17k forks source link

[AArch64] compile crash on "Unexpected function-local entity in 'imports' CU field" #90042

Closed vfdff closed 7 months ago

vfdff commented 7 months ago
target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-gnu"

!llvm.module.flags = !{!0}
!llvm.dbg.cu = !{!1}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = distinct !DICompileUnit(language: DW_LANG_Fortran90, file: !2, producer: " F90 Flang - 1.5 2017-05-01", isOptimized: true, flags: "'+flang -march=armv8.6-a+sve -O3 -ffast-math -I/new_home/zhongyunde/WRF/wrf-build-bisheng/install/include -cpp -DOPTSIMD -g -DOPT4 -DOPT5 -DOPT3 -DOPT7 -DCHECK -DOPT6 -Rpass=loop-vectorize -Rpass-missed=loop-vectorize -Rpass-analysis=loop-vectorize -S ../src/wave/wamcor_mod.f90 -v -save-temps -funsafe-math-optimizations -I/new_home/zhongyunde/WRF/WRF-scripts/../wrf-build-bisheng/install/include -I/new_home/zhongyunde/WRF/WRF-scripts/../wrf-build-bisheng/install/lib'", runtimeVersion: 0, emissionKind: FullDebug, enums: !3, retainedTypes: !3, globals: !4, imports: !9, nameTableKind: None)
!2 = !DIFile(filename: "../src/wave/wamcor_mod.f90", directory: "/home/zhongyunde/masnum/wave/objs")
!3 = !{}
!4 = !{!5}
!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
!6 = distinct !DIGlobalVariable(name: "flagmpi", scope: !7, file: !2, type: !8, isLocal: false, isDefinition: true)
!7 = !DIModule(scope: !1, name: "wamvar_mod", file: !2)
!8 = !DIBasicType(name: "integer", size: 32, align: 32, encoding: DW_ATE_signed)
!9 = !{!10}
!10 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !11, entity: !15, file: !2, line: 110)
!11 = distinct !DISubprogram(name: "mean2", scope: !12, file: !2, line: 110, type: !13, scopeLine: 110, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !1, retainedNodes: !3)
!12 = !DIModule(scope: !1, name: "wamcor_mod", file: !2)
!13 = !DISubroutineType(types: !14)
!14 = !{null}
!15 = !DIModule(scope: !1, name: "iso_fortran_env", file: !2)
llvmbot commented 7 months ago

@llvm/issue-subscribers-debuginfo

Author: Allen (vfdff)

* the IR is generated by classic-flang and reduced with **llvm-reduce**, and it compile fails: https://godbolt.org/z/sPs3GrxGK > Assertion `!isa_and_nonnull<DILocalScope>(IE->getScope()) && "Unexpected function-local entity in 'imports' CU field."' failed. ``` target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128" target triple = "aarch64-unknown-linux-gnu" !llvm.module.flags = !{!0} !llvm.dbg.cu = !{!1} !0 = !{i32 2, !"Debug Info Version", i32 3} !1 = distinct !DICompileUnit(language: DW_LANG_Fortran90, file: !2, producer: " F90 Flang - 1.5 2017-05-01", isOptimized: true, flags: "'+flang -march=armv8.6-a+sve -O3 -ffast-math -I/new_home/zhongyunde/WRF/wrf-build-bisheng/install/include -cpp -DOPTSIMD -g -DOPT4 -DOPT5 -DOPT3 -DOPT7 -DCHECK -DOPT6 -Rpass=loop-vectorize -Rpass-missed=loop-vectorize -Rpass-analysis=loop-vectorize -S ../src/wave/wamcor_mod.f90 -v -save-temps -funsafe-math-optimizations -I/new_home/zhongyunde/WRF/WRF-scripts/../wrf-build-bisheng/install/include -I/new_home/zhongyunde/WRF/WRF-scripts/../wrf-build-bisheng/install/lib'", runtimeVersion: 0, emissionKind: FullDebug, enums: !3, retainedTypes: !3, globals: !4, imports: !9, nameTableKind: None) !2 = !DIFile(filename: "../src/wave/wamcor_mod.f90", directory: "/home/zhongyunde/masnum/wave/objs") !3 = !{} !4 = !{!5} !5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression()) !6 = distinct !DIGlobalVariable(name: "flagmpi", scope: !7, file: !2, type: !8, isLocal: false, isDefinition: true) !7 = !DIModule(scope: !1, name: "wamvar_mod", file: !2) !8 = !DIBasicType(name: "integer", size: 32, align: 32, encoding: DW_ATE_signed) !9 = !{!10} !10 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !11, entity: !15, file: !2, line: 110) !11 = distinct !DISubprogram(name: "mean2", scope: !12, file: !2, line: 110, type: !13, scopeLine: 110, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !1, retainedNodes: !3) !12 = !DIModule(scope: !1, name: "wamcor_mod", file: !2) !13 = !DISubroutineType(types: !14) !14 = !{null} !15 = !DIModule(scope: !1, name: "iso_fortran_env", file: !2) ```
vfdff commented 7 months ago

Related to D144004 , would you help to check the input itself is not legal ? @dzhidzhoev

dwblaikie commented 7 months ago

Yeah, this looks like invalid IR from classic flang, then. Check what clang produces for similar coed - I think the using decl goes in the subprogram's entity list (one of the lists on the subprogram, I don't recall which/what their names are), not on the CU.