Temporarily revert "Don't try to construct debug LexicalScopes hierarchy for function...
[oota-llvm.git] / test / CodeGen / X86 / dbg-changes-codegen-branch-folding.ll
1 ; RUN: llc -march=x86-64 -mtriple=x86_64-linux < %s | FileCheck %s
2 ; RUN: opt -strip-debug < %s | llc -march=x86-64 -mtriple=x86_64-linux | FileCheck %s
3 ; http://llvm.org/PR19051. Minor code-motion difference with -g.
4 ; Presence of debug info shouldn't affect the codegen. Make sure that
5 ; we generated the same code sequence with and without debug info. 
6 ;
7 ; CHECK:      callq   _Z3fooPcjPKc
8 ; CHECK:      callq   _Z3fooPcjPKc
9 ; CHECK:      leaq    (%rsp), %rdi
10 ; CHECK:      movl    $4, %esi
11 ; CHECK:      testl   {{%[a-z]+}}, {{%[a-z]+}}
12 ; CHECK:      je     .LBB0_4
13
14 ; Regenerate test with this command: 
15 ;   clang -emit-llvm -S -O2 -g
16 ; 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 ;   else
40 ;     var2 = "-";
41 ;   var1 = "";
42 ; }
43
44 %struct.AAA3 = type { [4 x i8] }
45
46 @.str = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
47 @.str1 = private unnamed_addr constant [2 x i8] c"+\00", align 1
48 @.str2 = private unnamed_addr constant [2 x i8] c"-\00", align 1
49
50 ; Function Attrs: uwtable
51 define void @_Z3barii(i32 %param1, i32 %param2) #0 {
52 entry:
53   %var1 = alloca %struct.AAA3, align 1
54   %var2 = alloca %struct.AAA3, align 1
55   %tobool = icmp eq i32 %param2, 0
56   br i1 %tobool, label %if.end, label %if.then
57
58 if.then:                                          ; preds = %entry
59   %call = call i8* @_Z5i2stri(i32 %param2)
60   br label %if.end
61
62 if.end:                                           ; preds = %entry, %if.then
63   call void @llvm.dbg.value(metadata !{%struct.AAA3* %var1}, i64 0, metadata !60)
64   call void @llvm.dbg.value(metadata !62, i64 0, metadata !63)
65   %arraydecay.i = getelementptr inbounds %struct.AAA3* %var1, i64 0, i32 0, i64 0
66   call void @_Z3fooPcjPKc(i8* %arraydecay.i, i32 4, i8* getelementptr inbounds ([1 x i8]* @.str, i64 0, i64 0))
67   call void @llvm.dbg.declare(metadata !{%struct.AAA3* %var2}, metadata !38)
68   %arraydecay.i5 = getelementptr inbounds %struct.AAA3* %var2, i64 0, i32 0, i64 0
69   call void @_Z3fooPcjPKc(i8* %arraydecay.i5, i32 4, i8* getelementptr inbounds ([1 x i8]* @.str, i64 0, i64 0))
70   %tobool1 = icmp eq i32 %param1, 0
71   br i1 %tobool1, label %if.else, label %if.then2
72
73 if.then2:                                         ; preds = %if.end
74   call void @_Z3fooPcjPKc(i8* %arraydecay.i5, i32 4, i8* getelementptr inbounds ([2 x i8]* @.str1, i64 0, i64 0))
75   br label %if.end3
76
77 if.else:                                          ; preds = %if.end
78   call void @_Z3fooPcjPKc(i8* %arraydecay.i5, i32 4, i8* getelementptr inbounds ([2 x i8]* @.str2, i64 0, i64 0))
79   br label %if.end3
80
81 if.end3:                                          ; preds = %if.else, %if.then2
82   call void @_Z3fooPcjPKc(i8* %arraydecay.i, i32 4, i8* getelementptr inbounds ([1 x i8]* @.str, i64 0, i64 0))
83   ret void
84 }
85
86 ; Function Attrs: nounwind readnone
87 declare void @llvm.dbg.declare(metadata, metadata) #1
88
89 declare i8* @_Z5i2stri(i32) #2
90
91 declare void @_Z3fooPcjPKc(i8*, i32, i8*) #2
92
93 ; Function Attrs: nounwind readnone
94 declare void @llvm.dbg.value(metadata, i64, metadata) #1
95
96 attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
97 attributes #1 = { nounwind readnone }
98 attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
99
100 !llvm.module.flags = !{!48, !49}
101 !llvm.ident = !{!50}
102
103 !38 = metadata !{i32 786688, null, metadata !"var2", null, i32 20, null, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [var2] [line 20]
104 !48 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}
105 !49 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
106 !50 = metadata !{metadata !"clang version 3.5 (202418)"}
107 !60 = metadata !{i32 786689, null, metadata !"this", null, i32 16777216, null, i32 1088, null} ; [ DW_TAG_arg_variable ] [this] [line 0]
108 !62 = metadata !{i8* getelementptr inbounds ([1 x i8]* @.str, i64 0, i64 0)}
109 !63 = metadata !{i32 786689, null, metadata !"value", null, i32 33554439, null, i32 0, null} ; [ DW_TAG_arg_variable ] [value] [line 7]