1; RUN: opt -S -simplifycfg -strip-debug < %s | FileCheck %s 2; RUN: opt -S -simplifycfg < %s | FileCheck %s 3 4; Test case for BUG-27615 5; Test that simplify cond branch produce same result for debug and non-debug builds 6; CHECK: select i1 %or.cond, i32 -1, i32 5 7; CHECK-NOT: bb1: 8 9; ModuleID = './csmith107.i.debug.ll' 10source_filename = "./csmith107.i.debug.ll" 11 12@a = global i16 0, !dbg !0 13@b = global i32 0, !dbg !4 14@c = global i16* null, !dbg !9 15 16define i16 @fn1() !dbg !17 { 17bb2: 18 store i32 -1, i32* @b, align 1 19 %_tmp1.pre = load i16, i16* @a, align 1, !dbg !20 20 %_tmp2.pre = load i16*, i16** @c, align 1 21 tail call void @llvm.dbg.value(metadata i16 6, metadata !22, metadata !23), !dbg !24 22 tail call void @llvm.dbg.value(metadata i16 %_tmp1.pre, metadata !25, metadata !23), !dbg !20 23 %_tmp3 = load i16, i16* %_tmp2.pre, align 1 24 %_tmp4 = icmp ne i16 %_tmp3, 0 25 %_tmp6 = icmp ne i16 %_tmp1.pre, 0 26 %or.cond = and i1 %_tmp6, %_tmp4 27 br i1 %or.cond, label %bb5, label %bb1 28 29bb1: ; preds = %bb2 30 store i32 5, i32* @b, align 1 31 br label %bb5 32 33bb5: ; preds = %bb1, %bb2 34 ret i16 0 35} 36 37; Function Attrs: nounwind readnone 38declare void @llvm.dbg.value(metadata, metadata, metadata) #0 39 40attributes #0 = { nounwind readnone } 41 42!llvm.dbg.cu = !{!12} 43!llvm.module.flags = !{!15, !16} 44 45!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 46!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true) 47!2 = !DIFile(filename: "csmith107.i.c", directory: "/tmp") 48!3 = !DIBasicType(name: "int", size: 16, align: 16, encoding: DW_ATE_signed) 49!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) 50!5 = !DIGlobalVariable(name: "b", scope: null, file: !2, line: 3, type: !6, isLocal: false, isDefinition: true) 51!6 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint32_t", file: !2, line: 1, baseType: !7) 52!7 = !DIDerivedType(tag: DW_TAG_typedef, name: "__u32_t", file: !2, baseType: !8) 53!8 = !DIBasicType(name: "unsigned long", size: 32, align: 16, encoding: DW_ATE_unsigned) 54!9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression()) 55!10 = !DIGlobalVariable(name: "c", scope: null, file: !2, line: 4, type: !11, isLocal: false, isDefinition: true) 56!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, size: 16, align: 16) 57!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) 58!13 = !{} 59!14 = !{!0, !4, !9} 60!15 = !{i32 2, !"Dwarf Version", i32 4} 61!16 = !{i32 2, !"Debug Info Version", i32 3} 62!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) 63!18 = !DISubroutineType(types: !19) 64!19 = !{!3} 65!20 = !DILocation(line: 8, column: 16, scope: !21) 66!21 = !DILexicalBlock(scope: !17, file: !2, line: 7, column: 29) 67!22 = !DILocalVariable(name: "d", scope: !21, line: 8, type: !3) 68!23 = !DIExpression() 69!24 = !DILocation(line: 8, column: 9, scope: !21) 70!25 = !DILocalVariable(name: "e", scope: !21, line: 8, type: !3) 71 72