2014-03-08 06:00:49 +08:00
; RUN: llc -mtriple=x86_64-apple-darwin < %s -filetype=obj \
2017-09-12 07:05:20 +08:00
; RUN: | llvm-dwarfdump -v -debug-info - | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
2014-03-08 06:00:49 +08:00
; RUN: llc -mtriple=x86_64-linux-gnu < %s -filetype=obj \
2020-10-31 14:28:31 +08:00
; RUN: | llvm-dwarfdump -v -debug-info - | FileCheck %s
2014-03-08 06:00:49 +08:00
; RUN: llc -mtriple=x86_64-apple-darwin < %s -filetype=obj -regalloc=basic \
2017-09-12 07:05:20 +08:00
; RUN: | llvm-dwarfdump -v -debug-info - | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
2011-02-19 06:43:42 +08:00
2014-05-28 02:37:55 +08:00
; CHECK: DW_TAG_subprogram
2020-10-31 14:28:31 +08:00
; DARWIN: DW_AT_APPLE_omit_frame_ptr [DW_FORM_flag_present] (true)
2014-10-06 11:36:31 +08:00
; CHECK: DW_AT_abstract_origin {{.*}} "foo"
2014-05-28 02:37:55 +08:00
; CHECK: DW_TAG_formal_parameter
2014-06-14 05:52:33 +08:00
; CHECK-NOT: DW_TAG
2014-10-10 23:51:02 +08:00
; CHECK: DW_AT_abstract_origin {{.*}} "sp"
2014-05-28 02:37:55 +08:00
; CHECK: DW_TAG_formal_parameter
2014-06-14 05:52:33 +08:00
; CHECK-NOT: DW_TAG
2014-10-10 23:51:02 +08:00
; CHECK: DW_AT_abstract_origin {{.*}} "nums"
2014-05-28 02:37:55 +08:00
2014-10-06 11:36:31 +08:00
; CHECK: DW_TAG_subprogram
2014-06-14 05:52:33 +08:00
; CHECK-NOT: DW_TAG
DebugInfo: Lazily attach definition attributes to definitions.
This is a precursor to fixing inlined debug info where the concrete,
out-of-line definition may preceed any inlined usage. To cope with this,
the attributes that may appear on the concrete definition or the
abstract definition are delayed until the end of the module. Then, if an
abstract definition was created, it is referenced (and no other
attributes are added to the out-of-line definition), otherwise the
attributes are added directly to the out-of-line definition.
In a couple of cases this causes not just reordering of attributes, but
reordering of types. When the creation of the attribute is delayed, if
that creation would create a type (such as for a DW_AT_type attribute)
then other top level DIEs may've been constructed during the delay,
causing the referenced type to be created and added after those
intervening DIEs. In the extreme case, in cross-cu-inlining.ll, this
actually causes the DW_TAG_basic_type for "int" to move from one CU to
another.
llvm-svn: 209674
2014-05-28 02:37:43 +08:00
; CHECK: DW_AT_name {{.*}} "foo"
2014-10-10 23:51:02 +08:00
; CHECK: DW_TAG_formal_parameter
2014-06-14 05:52:33 +08:00
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "sp"
2014-10-10 23:51:02 +08:00
; CHECK: DW_TAG_formal_parameter
2014-06-14 05:52:33 +08:00
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "nums"
2014-05-28 01:57:14 +08:00
2013-06-20 08:25:24 +08:00
;CHECK: DW_TAG_inlined_subroutine
2014-10-06 11:36:31 +08:00
;CHECK-NEXT: DW_AT_abstract_origin {{.*}} "foo"
2014-03-08 06:00:56 +08:00
;CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
2014-03-08 07:07:21 +08:00
;CHECK-NEXT: DW_AT_high_pc [DW_FORM_data4]
2011-02-19 06:43:42 +08:00
;CHECK-NEXT: DW_AT_call_file
;CHECK-NEXT: DW_AT_call_line
2019-07-13 03:25:45 +08:00
;CHECK-NEXT: DW_AT_call_column
2012-12-27 10:13:58 +08:00
2013-06-20 08:25:24 +08:00
;CHECK: DW_TAG_formal_parameter
2014-06-14 05:52:33 +08:00
;CHECK-NOT: DW_TAG
2018-12-10 19:20:47 +08:00
;CHECK: DW_AT_abstract_origin {{.*}} "sp"
;CHECK: DW_TAG_formal_parameter
;CHECK-NOT: DW_TAG
2014-10-10 23:51:02 +08:00
;CHECK: DW_AT_abstract_origin {{.*}} "nums"
2014-05-28 01:57:14 +08:00
;CHECK-NOT: DW_TAG_formal_parameter
2011-02-19 06:43:42 +08:00
2016-12-22 08:45:21 +08:00
source_filename = "test/DebugInfo/X86/dbg-value-inlined-parameter.ll"
2011-02-19 06:43:42 +08:00
%struct.S1 = type { float * , i32 }
2016-12-22 08:45:21 +08:00
@p = common global %struct.S1 zeroinitializer , align 8 , !dbg !0
2011-02-19 06:43:42 +08:00
2016-12-22 08:45:21 +08:00
; Function Attrs: nounwind optsize ssp
define i32 @foo ( %struct.S1 * nocapture %sp , i32 %nums ) #0 !dbg !15 {
2011-02-19 06:43:42 +08:00
entry:
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata %struct.S1 * %sp , metadata !19 , metadata !22 ) , !dbg !23
tail call void @llvm.dbg.value ( metadata i32 %nums , metadata !21 , metadata !22 ) , !dbg !24
2016-12-22 08:45:21 +08:00
%tmp2 = getelementptr inbounds %struct.S1 , %struct.S1 * %sp , i64 0 , i32 1 , !dbg !25
store i32 %nums , i32 * %tmp2 , align 4 , !dbg !25
%call = tail call float * @bar ( i32 %nums ) #3 , !dbg !27
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
llvm-svn: 230786
2015-02-28 03:29:02 +08:00
%tmp5 = getelementptr inbounds %struct.S1 , %struct.S1 * %sp , i64 0 , i32 0 , !dbg !27
2013-05-03 02:11:35 +08:00
store float * %call , float * * %tmp5 , align 8 , !dbg !27
2016-12-22 08:45:21 +08:00
%cmp = icmp ne float * %call , null , !dbg !28
%cond = zext i1 %cmp to i32 , !dbg !28
ret i32 %cond , !dbg !28
2011-02-19 06:43:42 +08:00
}
2016-12-22 08:45:21 +08:00
; Function Attrs: optsize
declare float * @bar ( i32 ) #1
2011-02-19 06:43:42 +08:00
2016-12-22 08:45:21 +08:00
; Function Attrs: nounwind optsize ssp
define void @foobar ( ) #0 !dbg !29 {
2011-02-19 06:43:42 +08:00
entry:
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata %struct.S1 * @p , metadata !19 , metadata !22 ) #4 , !dbg !32
tail call void @llvm.dbg.value ( metadata i32 1 , metadata !21 , metadata !22 ) #4 , !dbg !35
2015-03-14 02:20:45 +08:00
store i32 1 , i32 * getelementptr inbounds ( %struct.S1 , %struct.S1 * @p , i64 0 , i32 1 ) , align 8 , !dbg !36
2016-12-22 08:45:21 +08:00
%call.i = tail call float * @bar ( i32 1 ) #3 , !dbg !37
2015-03-14 02:20:45 +08:00
store float * %call.i , float * * getelementptr inbounds ( %struct.S1 , %struct.S1 * @p , i64 0 , i32 0 ) , align 8 , !dbg !37
2011-02-19 06:43:42 +08:00
ret void , !dbg !38
}
2016-12-22 08:45:21 +08:00
; Function Attrs: nounwind readnone
2017-07-29 04:21:02 +08:00
declare void @llvm.dbg.value ( metadata , metadata , metadata ) #2
2016-12-22 08:45:21 +08:00
attributes #0 = { nounwind optsize ssp }
attributes #1 = { optsize }
attributes #2 = { nounwind readnone }
attributes #3 = { nounwind optsize }
attributes #4 = { nounwind }
2011-02-19 06:43:42 +08:00
2013-03-08 08:23:31 +08:00
!llvm.dbg.cu = ! { !2 }
2016-12-22 08:45:21 +08:00
!llvm.module.flags = ! { !14 }
2017-08-31 02:06:51 +08:00
!0 = !DIGlobalVariableExpression ( var: !1 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!1 = !DIGlobalVariable ( name: "p" , scope: !2 , file: !3 , line: 14 , type: !6 , isLocal: false , isDefinition: true )
!2 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , file: !3 , producer: "clang version 2.9 (trunk 125693)" , isOptimized: true , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !4 , retainedTypes: !4 , globals: !5 , imports: !4 )
!3 = !DIFile ( filename: "nm2.c" , directory: "/private/tmp" )
!4 = ! { }
!5 = ! { !0 }
!6 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "S1" , scope: !2 , file: !3 , line: 4 , baseType: !7 )
!7 = !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "S1" , scope: !2 , file: !3 , line: 1 , size: 128 , align: 64 , elements: !8 )
!8 = ! { !9 , !12 }
!9 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "m" , scope: !3 , file: !3 , line: 2 , baseType: !10 , size: 64 , align: 64 )
!10 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , scope: !2 , baseType: !11 , size: 64 , align: 64 )
!11 = !DIBasicType ( name: "float" , size: 32 , align: 32 , encoding: D W _ A T E _ float )
!12 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "nums" , scope: !3 , file: !3 , line: 3 , baseType: !13 , size: 32 , align: 32 , offset: 64 )
!13 = !DIBasicType ( name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
!14 = ! { i32 1 , !"Debug Info Version" , i32 3 }
[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
!15 = distinct !DISubprogram ( name: "foo" , scope: !3 , file: !3 , line: 8 , type: !16 , isLocal: false , isDefinition: true , scopeLine: 8 , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !2 , retainedNodes: !18 )
2016-12-22 08:45:21 +08:00
!16 = !DISubroutineType ( types: !17 )
!17 = ! { !13 }
!18 = ! { !19 , !21 }
!19 = !DILocalVariable ( name: "sp" , arg: 1 , scope: !15 , file: !3 , line: 7 , type: !20 )
!20 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , scope: !2 , baseType: !6 , size: 64 , align: 64 )
!21 = !DILocalVariable ( name: "nums" , arg: 2 , scope: !15 , file: !3 , line: 7 , type: !13 )
!22 = !DIExpression ( )
!23 = !DILocation ( line: 7 , column: 13 , scope: !15 )
!24 = !DILocation ( line: 7 , column: 21 , scope: !15 )
!25 = !DILocation ( line: 9 , column: 3 , scope: !26 )
!26 = distinct !DILexicalBlock ( scope: !15 , file: !3 , line: 8 , column: 1 )
!27 = !DILocation ( line: 10 , column: 3 , scope: !26 )
!28 = !DILocation ( line: 11 , column: 3 , scope: !26 )
!29 = distinct !DISubprogram ( name: "foobar" , scope: !3 , file: !3 , line: 15 , type: !30 , isLocal: false , isDefinition: true , virtualIndex: 6 , isOptimized: true , unit: !2 )
!30 = !DISubroutineType ( types: !31 )
!31 = ! { null }
!32 = !DILocation ( line: 7 , column: 13 , scope: !15 , inlinedAt: !33 )
!33 = !DILocation ( line: 16 , column: 3 , scope: !34 )
!34 = distinct !DILexicalBlock ( scope: !29 , file: !3 , line: 15 , column: 15 )
!35 = !DILocation ( line: 7 , column: 21 , scope: !15 , inlinedAt: !33 )
!36 = !DILocation ( line: 9 , column: 3 , scope: !26 , inlinedAt: !33 )
!37 = !DILocation ( line: 10 , column: 3 , scope: !26 , inlinedAt: !33 )
!38 = !DILocation ( line: 17 , column: 1 , scope: !34 )