2015-08-21 01:59:39 +02:00
|
|
|
; RUN: opt < %s -gvn -S | FileCheck %s
|
2015-08-20 20:23:56 +02:00
|
|
|
;
|
|
|
|
; Produced at -O2 from:
|
2015-08-21 01:59:39 +02:00
|
|
|
; int a, b;
|
|
|
|
; void f1(int *p1) {
|
|
|
|
; if (b)
|
|
|
|
; a = 1;
|
|
|
|
; if (a && *p1)
|
|
|
|
; f4();
|
2015-08-20 20:23:56 +02:00
|
|
|
; }
|
2015-08-21 01:59:39 +02:00
|
|
|
; int f2(int);
|
|
|
|
; void f3(void) {
|
|
|
|
; a = f2(1);
|
|
|
|
; f1(&a);
|
2015-08-20 20:23:56 +02:00
|
|
|
; }
|
2016-12-22 01:45:21 +01:00
|
|
|
source_filename = "test/DebugInfo/Generic/gvn.ll"
|
2015-08-20 20:23:56 +02:00
|
|
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
|
|
|
target triple = "arm64-apple-ios"
|
|
|
|
|
2016-12-22 01:45:21 +01:00
|
|
|
@a = common global i32 0, align 4, !dbg !0
|
|
|
|
@b = common global i32 0, align 4, !dbg !6
|
2015-08-20 20:23:56 +02:00
|
|
|
|
|
|
|
; Function Attrs: nounwind
|
2015-11-05 23:03:56 +01:00
|
|
|
define void @f3() #0 !dbg !12 {
|
2015-08-20 20:23:56 +02:00
|
|
|
entry:
|
|
|
|
; Verify that the call still has a debug location after GVN.
|
2015-08-21 01:59:39 +02:00
|
|
|
; CHECK: %call = tail call i32 @f2(i32 1) #{{[0-9]}}, !dbg
|
2016-12-22 01:45:21 +01:00
|
|
|
%call = tail call i32 @f2(i32 1) #0, !dbg !15
|
|
|
|
store i32 %call, i32* @a, align 4, !dbg !15, !tbaa !24
|
2017-07-28 22:21:02 +02:00
|
|
|
tail call void @llvm.dbg.value(metadata i32* @a, metadata !22, metadata !28) #0, !dbg !29
|
2016-12-22 01:45:21 +01:00
|
|
|
%0 = load i32, i32* @b, align 4, !dbg !29, !tbaa !24
|
|
|
|
%tobool.i = icmp eq i32 %0, 0, !dbg !29
|
|
|
|
br i1 %tobool.i, label %if.end.i, label %land.lhs.true.i.thread, !dbg !30
|
2015-08-21 01:59:39 +02:00
|
|
|
|
|
|
|
land.lhs.true.i.thread: ; preds = %entry
|
2016-12-22 01:45:21 +01:00
|
|
|
store i32 1, i32* @a, align 4, !dbg !32, !tbaa !24
|
|
|
|
br label %if.then.3.i, !dbg !33
|
2015-08-21 01:59:39 +02:00
|
|
|
|
2015-08-20 20:23:56 +02:00
|
|
|
; This instruction has no debug location -- in this
|
|
|
|
; particular case it was removed by a bug in SimplifyCFG.
|
2016-12-22 01:45:21 +01:00
|
|
|
if.end.i: ; preds = %entry
|
2015-08-21 01:59:39 +02:00
|
|
|
%.pr = load i32, i32* @a, align 4
|
|
|
|
; GVN is supposed to replace the load of %.pr with a direct reference to %call.
|
2015-08-20 20:23:56 +02:00
|
|
|
; CHECK: %tobool2.i = icmp eq i32 %call, 0, !dbg
|
2016-12-22 01:45:21 +01:00
|
|
|
%tobool2.i = icmp eq i32 %.pr, 0, !dbg !34
|
|
|
|
br i1 %tobool2.i, label %f1.exit, label %if.then.3.i, !dbg !34
|
2015-08-20 20:23:56 +02:00
|
|
|
|
2015-08-21 01:59:39 +02:00
|
|
|
if.then.3.i: ; preds = %if.end.i, %land.lhs.true.i.thread
|
2016-12-22 01:45:21 +01:00
|
|
|
%call.i = tail call i32 bitcast (i32 (...)* @f4 to i32 ()*)() #0, !dbg !35
|
|
|
|
br label %f1.exit, !dbg !35
|
2015-08-20 20:23:56 +02:00
|
|
|
|
2016-12-22 01:45:21 +01:00
|
|
|
f1.exit: ; preds = %if.then.3.i, %if.end.i
|
|
|
|
ret void, !dbg !36
|
2015-08-20 20:23:56 +02:00
|
|
|
}
|
|
|
|
|
2015-08-21 01:59:39 +02:00
|
|
|
declare i32 @f2(i32)
|
2016-12-22 01:45:21 +01:00
|
|
|
|
2015-08-21 01:59:39 +02:00
|
|
|
declare i32 @f4(...)
|
2015-08-20 20:23:56 +02:00
|
|
|
|
|
|
|
; Function Attrs: nounwind readnone
|
2017-07-28 22:21:02 +02:00
|
|
|
declare void @llvm.dbg.value(metadata, metadata, metadata) #1
|
2015-08-20 20:23:56 +02:00
|
|
|
|
|
|
|
attributes #0 = { nounwind }
|
2016-12-22 01:45:21 +01:00
|
|
|
attributes #1 = { nounwind readnone }
|
2015-08-20 20:23:56 +02:00
|
|
|
|
2016-12-22 01:45:21 +01:00
|
|
|
!llvm.dbg.cu = !{!2}
|
|
|
|
!llvm.module.flags = !{!9, !10}
|
|
|
|
!llvm.ident = !{!11}
|
2015-08-20 20:23:56 +02:00
|
|
|
|
2017-08-30 20:06:51 +02:00
|
|
|
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
|
2016-12-22 01:45:21 +01:00
|
|
|
!1 = !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 1, type: !8, isLocal: false, isDefinition: true)
|
|
|
|
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 3.8.0 (trunk 245562) (llvm/trunk 245569)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
|
|
|
|
!3 = !DIFile(filename: "test.c", directory: "/")
|
|
|
|
!4 = !{}
|
|
|
|
!5 = !{!0, !6}
|
2017-08-30 20:06:51 +02:00
|
|
|
!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
|
2016-12-22 01:45:21 +01:00
|
|
|
!7 = !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 1, type: !8, isLocal: false, isDefinition: true)
|
|
|
|
!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
|
|
|
!9 = !{i32 2, !"Dwarf Version", i32 2}
|
|
|
|
!10 = !{i32 2, !"Debug Info Version", i32 3}
|
|
|
|
!11 = !{!"clang version 3.8.0 (trunk 245562) (llvm/trunk 245569)"}
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 04:40:45 +02:00
|
|
|
!12 = distinct !DISubprogram(name: "f3", scope: !3, file: !3, line: 9, type: !13, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !4)
|
2015-08-21 01:59:39 +02:00
|
|
|
!13 = !DISubroutineType(types: !14)
|
|
|
|
!14 = !{null}
|
2016-12-22 01:45:21 +01:00
|
|
|
!15 = !DILocation(line: 5, scope: !16, inlinedAt: !23)
|
|
|
|
!16 = distinct !DILexicalBlock(scope: !17, file: !3, line: 5)
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 04:40:45 +02:00
|
|
|
!17 = distinct !DISubprogram(name: "f1", scope: !3, file: !3, line: 2, type: !18, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !21)
|
2016-12-22 01:45:21 +01:00
|
|
|
!18 = !DISubroutineType(types: !19)
|
|
|
|
!19 = !{null, !20}
|
|
|
|
!20 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, align: 64)
|
|
|
|
!21 = !{!22}
|
|
|
|
!22 = !DILocalVariable(name: "p1", arg: 1, scope: !17, file: !3, line: 2, type: !20)
|
|
|
|
!23 = distinct !DILocation(line: 11, scope: !12)
|
|
|
|
!24 = !{!25, !25, i64 0}
|
|
|
|
!25 = !{!"int", !26, i64 0}
|
|
|
|
!26 = !{!"omnipotent char", !27, i64 0}
|
|
|
|
!27 = !{!"Simple C/C++ TBAA"}
|
|
|
|
!28 = !DIExpression()
|
|
|
|
!29 = !DILocation(line: 2, scope: !17, inlinedAt: !23)
|
|
|
|
!30 = !DILocation(line: 3, scope: !31, inlinedAt: !23)
|
|
|
|
!31 = distinct !DILexicalBlock(scope: !17, file: !3, line: 3)
|
|
|
|
!32 = !DILocation(line: 3, scope: !17, inlinedAt: !23)
|
|
|
|
!33 = !DILocation(line: 4, scope: !31, inlinedAt: !23)
|
|
|
|
!34 = !DILocation(line: 5, scope: !17, inlinedAt: !23)
|
|
|
|
!35 = !DILocation(line: 6, scope: !16, inlinedAt: !23)
|
|
|
|
!36 = !DILocation(line: 12, scope: !12)
|
|
|
|
|