76 lines · plain
1; RUN: opt -S -mtriple=x86_64 -codegenprepare %s | FileCheck %s2;3; Generated from the following source with:4; clang -O2 -g -S -emit-llvm -mllvm -stop-after=indirectbr-expand test.cpp5;6; extern void use(int);7; extern int foo(long long);8; 9; void test(int p)10; {11; int i = p + 4;12; (void)foo(i); // sign extension of i13; if (p)14; return;15; use(i); // use of original i16; }17;18; PR39845: Check that CodeGenPrepare does not drop the reference to a local when it is19; sign-extended and used later.20;21; CHECK: define{{.*}}test22; CHECK: #dbg_value(i32 %p23; CHECK: #dbg_value(i32 %add24;25define dso_local void @_Z4testi(i32 %p) local_unnamed_addr !dbg !7 {26entry:27 call void @llvm.dbg.value(metadata i32 %p, metadata !12, metadata !DIExpression()), !dbg !1428 %add = add nsw i32 %p, 4, !dbg !1529 call void @llvm.dbg.value(metadata i32 %add, metadata !13, metadata !DIExpression()), !dbg !1630 %conv = sext i32 %add to i64, !dbg !1731 %call = tail call i32 @_Z3foox(i64 %conv), !dbg !1832 %tobool = icmp eq i32 %p, 0, !dbg !1933 br i1 %tobool, label %if.end, label %cleanup, !dbg !2134 35if.end:36 tail call void @_Z3usei(i32 %add), !dbg !2237 br label %cleanup, !dbg !2338 39cleanup:40 ret void, !dbg !2341}42 43declare dso_local i32 @_Z3foox(i64) local_unnamed_addr44declare dso_local void @_Z3usei(i32) local_unnamed_addr45 46declare void @llvm.dbg.value(metadata, metadata, metadata)47 48!llvm.dbg.cu = !{!0}49!llvm.module.flags = !{!3, !4, !5}50!llvm.ident = !{!6}51 52!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 8.0.0 (trunk 348209)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)53!1 = !DIFile(filename: "test.cpp", directory: "/home/test/src")54!2 = !{}55!3 = !{i32 2, !"Dwarf Version", i32 4}56!4 = !{i32 2, !"Debug Info Version", i32 3}57!5 = !{i32 1, !"wchar_size", i32 4}58!6 = !{!"clang version 8.0.0 (trunk 348209)"}59!7 = distinct !DISubprogram(name: "test", linkageName: "_Z4testi", scope: !1, file: !1, line: 4, type: !8, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)60!8 = !DISubroutineType(types: !9)61!9 = !{null, !10}62!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)63!11 = !{!12, !13}64!12 = !DILocalVariable(name: "p", arg: 1, scope: !7, file: !1, line: 4, type: !10)65!13 = !DILocalVariable(name: "i", scope: !7, file: !1, line: 6, type: !10)66!14 = !DILocation(line: 4, column: 15, scope: !7)67!15 = !DILocation(line: 6, column: 13, scope: !7)68!16 = !DILocation(line: 6, column: 7, scope: !7)69!17 = !DILocation(line: 7, column: 13, scope: !7)70!18 = !DILocation(line: 7, column: 9, scope: !7)71!19 = !DILocation(line: 8, column: 7, scope: !20)72!20 = distinct !DILexicalBlock(scope: !7, file: !1, line: 8, column: 7)73!21 = !DILocation(line: 8, column: 7, scope: !7)74!22 = !DILocation(line: 10, column: 3, scope: !7)75!23 = !DILocation(line: 11, column: 1, scope: !7)76