1 ; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -strip-debug < %s | FileCheck %s
2 ; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s
4 ; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -strip-debug < %s --try-experimental-debuginfo-iterators | FileCheck %s
5 ; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s --try-experimental-debuginfo-iterators | FileCheck %s
7 ; Test case for BUG-27615
8 ; Test that simplify cond branch produce same result for debug and non-debug builds
9 ; CHECK: select i1 %or.cond, i32 -1, i32 5
12 ; ModuleID = './csmith107.i.debug.ll'
13 source_filename = "./csmith107.i.debug.ll"
15 @a = global i16 0, !dbg !0
16 @b = global i32 0, !dbg !4
17 @c = global ptr null, !dbg !9
19 define i16 @fn1() !dbg !17 {
21 store i32 -1, ptr @b, align 1
22 %_tmp1.pre = load i16, ptr @a, align 1, !dbg !20
23 %_tmp2.pre = load ptr, ptr @c, align 1
24 tail call void @llvm.dbg.value(metadata i16 6, metadata !22, metadata !23), !dbg !24
25 tail call void @llvm.dbg.value(metadata i16 %_tmp1.pre, metadata !25, metadata !23), !dbg !20
26 %_tmp3 = load i16, ptr %_tmp2.pre, align 1
27 %_tmp4 = icmp ne i16 %_tmp3, 0
28 %_tmp6 = icmp ne i16 %_tmp1.pre, 0
29 %or.cond = and i1 %_tmp6, %_tmp4
30 br i1 %or.cond, label %bb5, label %bb1
33 store i32 5, ptr @b, align 1
36 bb5: ; preds = %bb1, %bb2
40 ; Function Attrs: nounwind readnone
41 declare void @llvm.dbg.value(metadata, metadata, metadata) #0
43 attributes #0 = { nounwind readnone }
46 !llvm.module.flags = !{!15, !16}
48 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
49 !1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true)
50 !2 = !DIFile(filename: "csmith107.i.c", directory: "/tmp")
51 !3 = !DIBasicType(name: "int", size: 16, align: 16, encoding: DW_ATE_signed)
52 !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
53 !5 = !DIGlobalVariable(name: "b", scope: null, file: !2, line: 3, type: !6, isLocal: false, isDefinition: true)
54 !6 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint32_t", file: !2, line: 1, baseType: !7)
55 !7 = !DIDerivedType(tag: DW_TAG_typedef, name: "__u32_t", file: !2, baseType: !8)
56 !8 = !DIBasicType(name: "unsigned long", size: 32, align: 16, encoding: DW_ATE_unsigned)
57 !9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())
58 !10 = !DIGlobalVariable(name: "c", scope: null, file: !2, line: 4, type: !11, isLocal: false, isDefinition: true)
59 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, size: 16, align: 16)
60 !12 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "FlexC Compiler v6.36 (LLVM)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !13, retainedTypes: !13, globals: !14)
63 !15 = !{i32 2, !"Dwarf Version", i32 4}
64 !16 = !{i32 2, !"Debug Info Version", i32 3}
65 !17 = distinct !DISubprogram(name: "fn1", scope: !2, file: !2, line: 5, type: !18, isLocal: false, isDefinition: true, scopeLine: 5, isOptimized: false, unit: !12, retainedNodes: !13)
66 !18 = !DISubroutineType(types: !19)
68 !20 = !DILocation(line: 8, column: 16, scope: !21)
69 !21 = !DILexicalBlock(scope: !17, file: !2, line: 7, column: 29)
70 !22 = !DILocalVariable(name: "d", scope: !21, line: 8, type: !3)
72 !24 = !DILocation(line: 8, column: 9, scope: !21)
73 !25 = !DILocalVariable(name: "e", scope: !21, line: 8, type: !3)