Open iamanonymouscs opened 5 days ago
Crash seems to have started happening around Clang 15 timeframe: https://godbolt.org/z/cszPs9xnP
Crash seems to have started happening around Clang 15 timeframe: https://godbolt.org/z/cszPs9xnP
Reproducible with this IR as well! opt -passes=globalopt
; *** IR Dump Before GlobalOptPass on [module] ***
; ModuleID = '<source>'
source_filename = "<source>"
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"
@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @main, ptr null }]
@a = dso_local alias i32 (...), ptr @foo
; Function Attrs: nounwind uwtable
define dso_local void @foo() #0 !dbg !9 {
entry:
ret void, !dbg !13
}
; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 !dbg !14 {
entry:
%call = call i32 (...) @a(), !dbg !18
ret i32 %call, !dbg !19
}
attributes #0 = { nounwind uwtable "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" }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2, !3, !4, !5, !6, !7}
!llvm.ident = !{!8}
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 20.0.0git (https://github.com/llvm/llvm-project.git 01d233ff403823389f8480897e41aea84ecbb3d3)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "<source>", directory: "/app")
!2 = !{i32 7, !"Dwarf Version", i32 4}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!4 = !{i32 1, !"wchar_size", i32 4}
!5 = !{i32 8, !"PIC Level", i32 2}
!6 = !{i32 7, !"PIE Level", i32 2}
!7 = !{i32 7, !"uwtable", i32 2}
!8 = !{!"clang version 20.0.0git (https://github.com/llvm/llvm-project.git 01d233ff403823389f8480897e41aea84ecbb3d3)"}
!9 = distinct !DISubprogram(name: "foo", scope: !10, file: !10, line: 2, type: !11, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
!10 = !DIFile(filename: "example.c", directory: "/app")
!11 = !DISubroutineType(types: !12)
!12 = !{null}
!13 = !DILocation(line: 2, column: 13, scope: !9)
!14 = distinct !DISubprogram(name: "main", scope: !10, file: !10, line: 3, type: !15, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
!15 = !DISubroutineType(types: !16)
!16 = !{!17}
!17 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!18 = !DILocation(line: 3, column: 50, scope: !14)
!19 = !DILocation(line: 3, column: 43, scope: !14)
Crash seems to have started happening around Clang 15 timeframe: https://godbolt.org/z/cszPs9xnP
I looked at the GlobalOpt and Evaluator class, basically the two differing return types of foo and a, even though they are aliasing causes issues while getting global constants.
InstResult is nullptr here as it is not set at this point.
Before this, the call to evaluateFunction falls through here, there's a check below to see if return value is void ty
clang-20 crashed with
alias
attribute andconstructor
attribute at-O1
and above.Compiler explorer: https://godbolt.org/z/5bqxWjPE5
Also crashed at Clang-19.