2017-03-07 05:31:18 +08:00
; RUN: llc -enable-machine-outliner -mtriple=x86_64-apple-darwin < %s | FileCheck %s
@x = global i32 0 , align 4 , !dbg !0
define i32 @main ( ) #0 !dbg !11 {
; CHECK-LABEL: _main:
%1 = alloca i32 , align 4
%2 = alloca i32 , align 4
%3 = alloca i32 , align 4
%4 = alloca i32 , align 4
%5 = alloca i32 , align 4
; There is a debug value in the middle of this section, make sure debug values are ignored.
2018-04-04 05:36:00 +08:00
; CHECK: callq
; CHECK-SAME: OUTLINED_FUNCTION_0
2017-03-07 05:31:18 +08:00
store i32 1 , i32 * %2 , align 4
store i32 2 , i32 * %3 , align 4
store i32 3 , i32 * %4 , align 4
call void @llvm.dbg.value ( metadata i32 10 , i64 0 , metadata !15 , metadata !16 ) , !dbg !17
store i32 4 , i32 * %5 , align 4
store i32 0 , i32 * @x , align 4 , !dbg !24
[DAG] Improve Aliasing of operations to static alloca
Re-recommiting after landing DAG extension-crash fix.
Recommiting after adding check to avoid miscomputing alias information
on addresses of the same base but different subindices.
Memory accesses offset from frame indices may alias, e.g., we
may merge write from function arguments passed on the stack when they
are contiguous. As a result, when checking aliasing, we consider the
underlying frame index's offset from the stack pointer.
Static allocs are realized as stack objects in SelectionDAG, but its
offset is not set until post-DAG causing DAGCombiner's alias check to
consider access to static allocas to frequently alias. Modify isAlias
to consider access between static allocas and access from other frame
objects to be considered aliasing.
Many test changes are included here. Most are fixes for tests which
indirectly relied on our aliasing ability and needed to be modified to
preserve their original intent.
The remaining tests have minor improvements due to relaxed
ordering. The exception is CodeGen/X86/2011-10-19-widen_vselect.ll
which has a minor degradation dispite though the pre-legalized DAG is
improved.
Reviewers: rnk, mkuper, jonpa, hfinkel, uweigand
Reviewed By: rnk
Subscribers: sdardis, nemanjai, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D33345
llvm-svn: 308350
2017-07-19 04:06:24 +08:00
call void asm sideeffect "" , "~{memory},~{dirflag},~{fpsr},~{flags}" ( )
2017-03-07 05:31:18 +08:00
; This is the same sequence of instructions without a debug value. It should be outlined
; in the same way.
2018-04-04 05:36:00 +08:00
; CHECK: callq
; CHECK-SAME: OUTLINED_FUNCTION_0
2017-03-07 05:31:18 +08:00
store i32 1 , i32 * %2 , align 4
store i32 2 , i32 * %3 , align 4
store i32 3 , i32 * %4 , align 4
store i32 4 , i32 * %5 , align 4
store i32 1 , i32 * @x , align 4 , !dbg !14
ret i32 0 , !dbg !25
}
2018-04-04 05:36:00 +08:00
; CHECK: OUTLINED_FUNCTION_0:
2017-03-07 05:31:18 +08:00
; CHECK-NOT: .loc {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} {{^(is_stmt)}}
; CHECK-NOT: ##DEBUG_VALUE: main:{{[a-z]}} <- {{[0-9]+}}
; CHECK: movl $1, -{{[0-9]+}}(%rbp)
; CHECK-NEXT: movl $2, -{{[0-9]+}}(%rbp)
; CHECK-NEXT: movl $3, -{{[0-9]+}}(%rbp)
; CHECK-NEXT: movl $4, -{{[0-9]+}}(%rbp)
; CHECK-NEXT: retq
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) #1
declare void @llvm.dbg.value ( metadata , i64 , metadata , metadata ) #1
attributes #0 = { noredzone nounwind ssp uwtable "no-frame-pointer-elim" = "true" }
!llvm.dbg.cu = ! { !2 }
!llvm.module.flags = ! { !7 , !8 , !9 }
!llvm.ident = ! { !10 }
2017-08-31 02:06:51 +08:00
!0 = !DIGlobalVariableExpression ( var: !1 , expr: !DIExpression ( ) )
2017-03-07 05:31:18 +08:00
!1 = distinct !DIGlobalVariable ( name: "x" , scope: !2 , file: !3 , line: 2 , type: !6 , isLocal: false , isDefinition: true )
!2 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , file: !3 , producer: "clang version 5.0.0" , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !4 , globals: !5 )
!3 = !DIFile ( filename: "debug-test.c" , directory: "dir" )
!4 = ! { }
!5 = ! { !0 }
!6 = !DIBasicType ( name: "int" , size: 32 , encoding: D W _ A T E _ s i g n e d )
!7 = ! { i32 2 , !"Dwarf Version" , i32 4 }
!8 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!9 = ! { i32 1 , !"PIC Level" , i32 2 }
!10 = ! { !"clang version 5.0.0" }
[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 10:40:45 +08:00
!11 = distinct !DISubprogram ( name: "main" , scope: !3 , file: !3 , line: 4 , type: !12 , isLocal: false , isDefinition: true , scopeLine: 4 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !2 , retainedNodes: !4 )
2017-03-07 05:31:18 +08:00
!12 = !DISubroutineType ( types: !13 )
!13 = ! { !6 }
!14 = !DILocation ( line: 7 , column: 4 , scope: !11 )
!15 = !DILocalVariable ( name: "a" , scope: !11 , file: !3 , line: 5 , type: !6 )
!16 = !DIExpression ( )
!17 = !DILocation ( line: 5 , column: 6 , scope: !11 )
!18 = !DILocalVariable ( name: "b" , scope: !11 , file: !3 , line: 5 , type: !6 )
!19 = !DILocation ( line: 5 , column: 9 , scope: !11 )
!20 = !DILocalVariable ( name: "c" , scope: !11 , file: !3 , line: 5 , type: !6 )
!21 = !DILocation ( line: 5 , column: 12 , scope: !11 )
!22 = !DILocalVariable ( name: "d" , scope: !11 , file: !3 , line: 5 , type: !6 )
!23 = !DILocation ( line: 5 , column: 15 , scope: !11 )
!24 = !DILocation ( line: 14 , column: 4 , scope: !11 )
!25 = !DILocation ( line: 21 , column: 2 , scope: !11 )