File: sink-store.ll

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (109 lines) | stat: -rw-r--r-- 5,170 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
; RUN: opt %s -S -passes=instcombine | FileCheck %s

;; Check that instcombine merges the DIAssignID metadata when merging two
;; stores into a successor. Filecheck directives inline.
;;
;; Generated from the following source:
;; int c;
;; void esc(int*);
;; int get();
;; void fun() {
;;   int local;
;;   if (c) {
;;     get();
;;     local = 2;
;;   } else {
;;     local = 2;
;;   }
;;   esc(&local);
;; }

; CHECK: if.then:
; CHECK-NEXT: %call = call
; CHECK-NEXT: call void @llvm.dbg.assign(metadata i32 2, metadata ![[LOCAL:[0-9]+]], metadata !DIExpression(), metadata ![[MERGED_ID:[0-9]+]], metadata ptr %local, metadata !DIExpression()), !dbg

; CHECK: if.else:
; CHECK-NEXT: call void @llvm.dbg.assign(metadata i32 2, metadata ![[LOCAL]], metadata !DIExpression(), metadata ![[MERGED_ID]], metadata ptr %local, metadata !DIExpression()), !dbg

; CHECK: if.end:
; CHECK-NEXT: store i32 2, ptr %local{{.*}}!DIAssignID ![[MERGED_ID]]

; CHECK: ![[LOCAL]] = !DILocalVariable(name: "local",

@c = dso_local local_unnamed_addr global i32 0, align 4, !dbg !0

; Function Attrs: uwtable mustprogress
define dso_local void @_Z3funv() local_unnamed_addr !dbg !11 {
entry:
  %local = alloca i32, align 4
  %0 = bitcast ptr %local to ptr, !dbg !16
  call void @llvm.lifetime.start.p0i8(i64 4, ptr %0), !dbg !16
  %1 = load i32, ptr @c, align 4, !dbg !17
  %tobool = icmp ne i32 %1, 0, !dbg !17
  br i1 %tobool, label %if.then, label %if.else, !dbg !23

if.then:                                          ; preds = %entry
  %call = call i32 @_Z3getv(), !dbg !24
  store i32 2, ptr %local, align 4, !dbg !26, !DIAssignID !27
  call void @llvm.dbg.assign(metadata i32 2, metadata !15, metadata !DIExpression(), metadata !27, metadata ptr %local, metadata !DIExpression()), !dbg !26
  br label %if.end, !dbg !28

if.else:                                          ; preds = %entry
  store i32 2, ptr %local, align 4, !dbg !29, !DIAssignID !31
  call void @llvm.dbg.assign(metadata i32 2, metadata !15, metadata !DIExpression(), metadata !31, metadata ptr %local, metadata !DIExpression()), !dbg !29
  br label %if.end

if.end:                                           ; preds = %if.else, %if.then
  call void @_Z3escPi(ptr %local), !dbg !32
  call void @llvm.lifetime.end.p0i8(i64 4, ptr %0), !dbg !33
  ret void, !dbg !33
}

declare !dbg !34 dso_local i32 @_Z3getv() local_unnamed_addr
declare !dbg !37 dso_local void @_Z3escPi(ptr) local_unnamed_addr
declare void @llvm.lifetime.start.p0i8(i64 immarg, ptr nocapture)
declare void @llvm.lifetime.end.p0i8(i64 immarg, ptr nocapture)
declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)

!llvm.dbg.cu = !{!2}
!llvm.module.flags = !{!7, !8, !9, !1000}
!llvm.ident = !{!10}

!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
!1 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
!3 = !DIFile(filename: "test.cpp", directory: "/")
!4 = !{}
!5 = !{!0}
!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!7 = !{i32 7, !"Dwarf Version", i32 4}
!8 = !{i32 2, !"Debug Info Version", i32 3}
!9 = !{i32 1, !"wchar_size", i32 4}
!10 = !{!"clang version 12.0.0"}
!11 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !3, file: !3, line: 4, type: !12, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !14)
!12 = !DISubroutineType(types: !13)
!13 = !{null}
!14 = !{!15}
!15 = !DILocalVariable(name: "local", scope: !11, file: !3, line: 5, type: !6)
!16 = !DILocation(line: 5, column: 3, scope: !11)
!17 = !DILocation(line: 6, column: 7, scope: !18)
!18 = distinct !DILexicalBlock(scope: !11, file: !3, line: 6, column: 7)
!23 = !DILocation(line: 6, column: 7, scope: !11)
!24 = !DILocation(line: 7, column: 5, scope: !25)
!25 = distinct !DILexicalBlock(scope: !18, file: !3, line: 6, column: 10)
!26 = !DILocation(line: 8, column: 11, scope: !25)
!27 = distinct !DIAssignID()
!28 = !DILocation(line: 9, column: 3, scope: !25)
!29 = !DILocation(line: 10, column: 11, scope: !30)
!30 = distinct !DILexicalBlock(scope: !18, file: !3, line: 9, column: 10)
!31 = distinct !DIAssignID()
!32 = !DILocation(line: 12, column: 3, scope: !11)
!33 = !DILocation(line: 13, column: 1, scope: !11)
!34 = !DISubprogram(name: "get", linkageName: "_Z3getv", scope: !3, file: !3, line: 3, type: !35, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4)
!35 = !DISubroutineType(types: !36)
!36 = !{!6}
!37 = !DISubprogram(name: "esc", linkageName: "_Z3escPi", scope: !3, file: !3, line: 2, type: !38, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4)
!38 = !DISubroutineType(types: !39)
!39 = !{null, !40}
!40 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64)
!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}