xref: /llvm-project/llvm/test/CodeGen/X86/patchable-prologue-debuginfo.ll (revision b9ae06ba15936c9802d5668cea260ad36a243a10)
1; RUN: llc -verify-machineinstrs < %s | FileCheck %s --check-prefix=CHECK
2
3; Regression test for function patching asserting in some cases when debug info activated.
4; The code below reproduces this crash.
5
6; Compilation flag:  clang -target x86_64-none-linux-gnu -c -O2 -g -fms-hotpatch patchable-prologue-debuginfo.c
7; int func( int val ) {
8;   int neg = -val;
9;   return neg + 1;
10; }
11
12; CHECK: # -- Begin function func
13
14; ModuleID = 'patchable-prologue-debuginfo.c'
15source_filename = "patchable-prologue-debuginfo.c"
16target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
17target triple = "x86_64-none-linux-gnu"
18
19; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable
20define dso_local i32 @func(i32 noundef %val) local_unnamed_addr #0 !dbg !9 {
21entry:
22  call void @llvm.dbg.value(metadata i32 %val, metadata !14, metadata !DIExpression()), !dbg !16
23  call void @llvm.dbg.value(metadata !DIArgList(i32 0, i32 %val), metadata !15, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_minus, DW_OP_stack_value)), !dbg !16
24  %add = sub i32 1, %val, !dbg !17
25  ret i32 %add, !dbg !18
26}
27
28; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
29declare void @llvm.dbg.value(metadata, metadata, metadata) #1
30
31attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "patchable-function"="prologue-short-redirect" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
32attributes #1 = { nocallback nofree nosync nounwind readnone speculatable willreturn }
33
34!llvm.dbg.cu = !{!0}
35!llvm.module.flags = !{!2, !3, !4, !5, !6, !7}
36!llvm.ident = !{!8}
37
38!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 15.0.4 (git@gitlab-ncsa.ubisoft.org:LLVM/llvm-project.git 17850fb41c5bddcd80a9c2714f7e293f49fa8bb2)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
39!1 = !DIFile(filename: "patchable-prologue-debuginfo.c", directory: "D:\\saudi\\bugrepro-llvm-hotpatch-crash")
40!2 = !{i32 7, !"Dwarf Version", i32 4}
41!3 = !{i32 2, !"Debug Info Version", i32 3}
42!4 = !{i32 1, !"wchar_size", i32 4}
43!5 = !{i32 7, !"PIC Level", i32 2}
44!6 = !{i32 7, !"PIE Level", i32 2}
45!7 = !{i32 7, !"uwtable", i32 2}
46!8 = !{!"clang version 15.0.4 (git@gitlab-ncsa.ubisoft.org:LLVM/llvm-project.git 17850fb41c5bddcd80a9c2714f7e293f49fa8bb2)"}
47!9 = distinct !DISubprogram(name: "func", scope: !1, file: !1, line: 1, type: !10, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
48!10 = !DISubroutineType(types: !11)
49!11 = !{!12, !12}
50!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
51!13 = !{!14, !15}
52!14 = !DILocalVariable(name: "val", arg: 1, scope: !9, file: !1, line: 1, type: !12)
53!15 = !DILocalVariable(name: "neg", scope: !9, file: !1, line: 3, type: !12)
54!16 = !DILocation(line: 0, scope: !9)
55!17 = !DILocation(line: 4, column: 16, scope: !9)
56!18 = !DILocation(line: 4, column: 5, scope: !9)
57