212 lines · plain
1; RUN: llc -mtriple=x86_64-linux < %s | FileCheck %s2; RUN: opt -strip-debug < %s | llc -mtriple=x86_64-linux | FileCheck %s3; http://llvm.org/PR19051. Minor code-motion difference with -g.4; Presence of debug info shouldn't affect the codegen. Make sure that5; we generated the same code sequence with and without debug info. 6;7; CHECK: callq _Z3fooPcjPKc8; CHECK: callq _Z3fooPcjPKc9; CHECK: movq %rsp, %rdi10; CHECK: testl {{%[a-z]+}}, {{%[a-z]+}}11; CHECK: je .LBB0_412; CHECK: movl $4, %esi13 14; Regenerate test with this command: 15; clang++ -emit-llvm -S -O2 -g16; from this source:17;18; extern void foo(char *dst,unsigned siz,const char *src);19; extern const char * i2str(int);20;21; struct AAA3 {22; AAA3(const char *value) { foo(text,sizeof(text),value);}23; void operator=(const char *value) { foo(text,sizeof(text),value);}24; operator const char*() const { return text;}25; char text[4];26; };27;28; void bar (int param1,int param2) {29; const char * temp(0);30;31; if (param2) {32; temp = i2str(param2);33; }34; AAA3 var1("");35; AAA3 var2("");36;37; if (param1)38; var2 = "+";39; else40; var2 = "-";41; var1 = "";42; }43 44%struct.AAA3 = type { [4 x i8] }45 46@.str = private unnamed_addr constant [1 x i8] zeroinitializer, align 147@.str.1 = private unnamed_addr constant [2 x i8] c"+\00", align 148@.str.2 = private unnamed_addr constant [2 x i8] c"-\00", align 149 50; Function Attrs: uwtable51define void @_Z3barii(i32 %param1, i32 %param2) #0 !dbg !24 {52entry:53 %var1 = alloca %struct.AAA3, align 854 %var2 = alloca %struct.AAA3, align 855 tail call void @llvm.dbg.value(metadata i32 %param1, i64 0, metadata !29, metadata !46), !dbg !4756 tail call void @llvm.dbg.value(metadata i32 %param2, i64 0, metadata !30, metadata !46), !dbg !4857 tail call void @llvm.dbg.value(metadata ptr null, i64 0, metadata !31, metadata !46), !dbg !4958 %tobool = icmp eq i32 %param2, 0, !dbg !5059 br i1 %tobool, label %if.end, label %if.then, !dbg !5260 61if.then: ; preds = %entry62 %call = tail call ptr @_Z5i2stri(i32 %param2), !dbg !5363 tail call void @llvm.dbg.value(metadata ptr %call, i64 0, metadata !31, metadata !46), !dbg !4964 br label %if.end, !dbg !5565 66if.end: ; preds = %entry, %if.then67 call void @llvm.lifetime.start.p0(i64 4, ptr %var1) #4, !dbg !5668 tail call void @llvm.dbg.value(metadata ptr %var1, i64 0, metadata !32, metadata !57), !dbg !5869 tail call void @llvm.dbg.value(metadata ptr %var1, i64 0, metadata !36, metadata !46), !dbg !5970 tail call void @llvm.dbg.value(metadata ptr @.str, i64 0, metadata !38, metadata !46), !dbg !6271 call void @_Z3fooPcjPKc(ptr %var1, i32 4, ptr nonnull @.str), !dbg !6372 call void @llvm.lifetime.start.p0(i64 4, ptr %var2) #4, !dbg !6573 call void @llvm.dbg.value(metadata ptr %var2, i64 0, metadata !33, metadata !57), !dbg !6674 call void @llvm.dbg.value(metadata ptr %var2, i64 0, metadata !36, metadata !46), !dbg !6775 call void @llvm.dbg.value(metadata ptr @.str, i64 0, metadata !38, metadata !46), !dbg !6976 call void @_Z3fooPcjPKc(ptr %var2, i32 4, ptr nonnull @.str), !dbg !7077 %tobool1 = icmp eq i32 %param1, 0, !dbg !7178 call void @llvm.dbg.value(metadata ptr %var2, i64 0, metadata !33, metadata !57), !dbg !6679 call void @llvm.dbg.value(metadata ptr %var2, i64 0, metadata !41, metadata !46), !dbg !7380 br i1 %tobool1, label %if.else, label %if.then2, !dbg !7581 82if.then2: ; preds = %if.end83 call void @llvm.dbg.value(metadata ptr @.str.1, i64 0, metadata !42, metadata !46), !dbg !7684 call void @_Z3fooPcjPKc(ptr %var2, i32 4, ptr nonnull @.str.1), !dbg !7885 br label %if.end3, !dbg !7986 87if.else: ; preds = %if.end88 call void @llvm.dbg.value(metadata ptr @.str.2, i64 0, metadata !42, metadata !46), !dbg !8089 call void @_Z3fooPcjPKc(ptr %var2, i32 4, ptr nonnull @.str.2), !dbg !8190 br label %if.end391 92if.end3: ; preds = %if.else, %if.then293 call void @llvm.dbg.value(metadata ptr %var1, i64 0, metadata !32, metadata !57), !dbg !5894 call void @llvm.dbg.value(metadata ptr %var1, i64 0, metadata !41, metadata !46), !dbg !8295 call void @llvm.dbg.value(metadata ptr @.str, i64 0, metadata !42, metadata !46), !dbg !8496 call void @_Z3fooPcjPKc(ptr %var1, i32 4, ptr nonnull @.str), !dbg !8597 call void @llvm.lifetime.end.p0(i64 4, ptr %var2) #4, !dbg !8698 call void @llvm.lifetime.end.p0(i64 4, ptr %var1) #4, !dbg !8799 ret void, !dbg !86100}101 102; Function Attrs: argmemonly nounwind103declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #1104 105declare ptr @_Z5i2stri(i32) #2106 107; Function Attrs: argmemonly nounwind108declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #1109 110declare void @_Z3fooPcjPKc(ptr, i32, ptr) #2111 112; Function Attrs: nounwind readnone113declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #3114 115attributes #0 = { uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "use-soft-float"="false" }116attributes #1 = { argmemonly nounwind }117attributes #2 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "use-soft-float"="false" }118attributes #3 = { nounwind readnone }119attributes #4 = { nounwind }120 121!llvm.dbg.cu = !{!0}122!llvm.module.flags = !{!43, !44}123!llvm.ident = !{!45}124 125!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 255993) (llvm/trunk 256074)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3)126!1 = !DIFile(filename: "test.cpp", directory: "/mnt/extra")127!2 = !{}128!3 = !{!4}129!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "AAA3", file: !1, line: 4, size: 32, align: 8, elements: !5, identifier: "_ZTS4AAA3")130!5 = !{!6, !11, !17, !18}131!6 = !DIDerivedType(tag: DW_TAG_member, name: "text", scope: !4, file: !1, line: 8, baseType: !7, size: 32, align: 8)132!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, align: 8, elements: !9)133!8 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)134!9 = !{!10}135!10 = !DISubrange(count: 4)136!11 = !DISubprogram(name: "AAA3", scope: !4, file: !1, line: 5, type: !12, isLocal: false, isDefinition: false, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true)137!12 = !DISubroutineType(types: !13)138!13 = !{null, !14, !15}139!14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)140!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64, align: 64)141!16 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)142!17 = !DISubprogram(name: "operator=", linkageName: "_ZN4AAA3aSEPKc", scope: !4, file: !1, line: 6, type: !12, isLocal: false, isDefinition: false, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: true)143!18 = !DISubprogram(name: "operator const char *", linkageName: "_ZNK4AAA3cvPKcEv", scope: !4, file: !1, line: 7, type: !19, isLocal: false, isDefinition: false, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: true)144!19 = !DISubroutineType(types: !20)145!20 = !{!15, !21}146!21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)147!22 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !4)148!24 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barii", scope: !1, file: !1, line: 11, type: !25, isLocal: false, isDefinition: true, scopeLine: 11, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !28)149!25 = !DISubroutineType(types: !26)150!26 = !{null, !27, !27}151!27 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)152!28 = !{!29, !30, !31, !32, !33}153!29 = !DILocalVariable(name: "param1", arg: 1, scope: !24, file: !1, line: 11, type: !27)154!30 = !DILocalVariable(name: "param2", arg: 2, scope: !24, file: !1, line: 11, type: !27)155!31 = !DILocalVariable(name: "temp", scope: !24, file: !1, line: 12, type: !15)156!32 = !DILocalVariable(name: "var1", scope: !24, file: !1, line: 17, type: !4)157!33 = !DILocalVariable(name: "var2", scope: !24, file: !1, line: 18, type: !4)158!34 = distinct !DISubprogram(name: "AAA3", linkageName: "_ZN4AAA3C2EPKc", scope: !4, file: !1, line: 5, type: !12, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !11, retainedNodes: !35)159!35 = !{!36, !38}160!36 = !DILocalVariable(name: "this", arg: 1, scope: !34, type: !37, flags: DIFlagArtificial | DIFlagObjectPointer)161!37 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 64, align: 64)162!38 = !DILocalVariable(name: "value", arg: 2, scope: !34, file: !1, line: 5, type: !15)163!39 = distinct !DISubprogram(name: "operator=", linkageName: "_ZN4AAA3aSEPKc", scope: !4, file: !1, line: 6, type: !12, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !17, retainedNodes: !40)164!40 = !{!41, !42}165!41 = !DILocalVariable(name: "this", arg: 1, scope: !39, type: !37, flags: DIFlagArtificial | DIFlagObjectPointer)166!42 = !DILocalVariable(name: "value", arg: 2, scope: !39, file: !1, line: 6, type: !15)167!43 = !{i32 2, !"Dwarf Version", i32 4}168!44 = !{i32 2, !"Debug Info Version", i32 3}169!45 = !{!"clang version 3.8.0 (trunk 255993) (llvm/trunk 256074)"}170!46 = !DIExpression()171!47 = !DILocation(line: 11, column: 15, scope: !24)172!48 = !DILocation(line: 11, column: 26, scope: !24)173!49 = !DILocation(line: 12, column: 16, scope: !24)174!50 = !DILocation(line: 14, column: 7, scope: !51)175!51 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 7)176!52 = !DILocation(line: 14, column: 7, scope: !24)177!53 = !DILocation(line: 15, column: 12, scope: !54)178!54 = distinct !DILexicalBlock(scope: !51, file: !1, line: 14, column: 15)179!55 = !DILocation(line: 16, column: 3, scope: !54)180!56 = !DILocation(line: 17, column: 3, scope: !24)181!57 = !DIExpression(DW_OP_deref)182!58 = !DILocation(line: 17, column: 8, scope: !24)183!59 = !DILocation(line: 0, scope: !34, inlinedAt: !60)184!60 = distinct !DILocation(line: 17, column: 8, scope: !61)185!61 = !DILexicalBlockFile(scope: !24, file: !1, discriminator: 1)186!62 = !DILocation(line: 5, column: 19, scope: !34, inlinedAt: !60)187!63 = !DILocation(line: 5, column: 28, scope: !64, inlinedAt: !60)188!64 = distinct !DILexicalBlock(scope: !34, file: !1, line: 5, column: 26)189!65 = !DILocation(line: 18, column: 3, scope: !24)190!66 = !DILocation(line: 18, column: 8, scope: !24)191!67 = !DILocation(line: 0, scope: !34, inlinedAt: !68)192!68 = distinct !DILocation(line: 18, column: 8, scope: !61)193!69 = !DILocation(line: 5, column: 19, scope: !34, inlinedAt: !68)194!70 = !DILocation(line: 5, column: 28, scope: !64, inlinedAt: !68)195!71 = !DILocation(line: 20, column: 7, scope: !72)196!72 = distinct !DILexicalBlock(scope: !24, file: !1, line: 20, column: 7)197!73 = !DILocation(line: 0, scope: !39, inlinedAt: !74)198!74 = distinct !DILocation(line: 23, column: 10, scope: !72)199!75 = !DILocation(line: 20, column: 7, scope: !24)200!76 = !DILocation(line: 6, column: 29, scope: !39, inlinedAt: !77)201!77 = distinct !DILocation(line: 21, column: 10, scope: !72)202!78 = !DILocation(line: 6, column: 38, scope: !39, inlinedAt: !77)203!79 = !DILocation(line: 21, column: 5, scope: !72)204!80 = !DILocation(line: 6, column: 29, scope: !39, inlinedAt: !74)205!81 = !DILocation(line: 6, column: 38, scope: !39, inlinedAt: !74)206!82 = !DILocation(line: 0, scope: !39, inlinedAt: !83)207!83 = distinct !DILocation(line: 24, column: 8, scope: !24)208!84 = !DILocation(line: 6, column: 29, scope: !39, inlinedAt: !83)209!85 = !DILocation(line: 6, column: 38, scope: !39, inlinedAt: !83)210!86 = !DILocation(line: 25, column: 1, scope: !24)211!87 = !DILocation(line: 25, column: 1, scope: !61)212