2010-08-16 04:42:56 +08:00
; RUN: llc -march=x86 -O0 < %s | FileCheck %s
2010-01-26 08:09:58 +08:00
; Currently, dbg.declare generates a DEBUG_VALUE comment. Eventually it will
; generate DWARF and this test will need to be modified or removed.
2010-04-29 04:27:48 +08:00
%struct.Pt = type { double , double }
%struct.Rect = type { %struct.Pt , %struct.Pt }
2015-11-06 06:03:56 +08:00
define double @foo ( %struct.Rect * byval %my_r0 ) nounwind ssp !dbg !1 {
2010-01-26 08:09:58 +08:00
entry:
2010-04-29 04:27:48 +08:00
;CHECK: DEBUG_VALUE
%retval = alloca double ; <double*> [#uses=2]
%0 = alloca double ; <double*> [#uses=2]
2010-01-26 08:09:58 +08:00
%"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
2015-04-30 00:38:44 +08:00
call void @llvm.dbg.declare ( metadata %struct.Rect * %my_r0 , metadata !0 , metadata !DIExpression ( ) ) , !dbg !15
[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
%1 = getelementptr inbounds %struct.Rect , %struct.Rect * %my_r0 , i32 0 , i32 0 , !dbg !16 ; <%struct.Pt*> [#uses=1]
%2 = getelementptr inbounds %struct.Pt , %struct.Pt * %1 , i32 0 , i32 0 , !dbg !16 ; <double*> [#uses=1]
2015-02-28 05:17:42 +08:00
%3 = load double , double * %2 , align 8 , !dbg !16 ; <double> [#uses=1]
2010-04-29 04:27:48 +08:00
store double %3 , double * %0 , align 8 , !dbg !16
2015-02-28 05:17:42 +08:00
%4 = load double , double * %0 , align 8 , !dbg !16 ; <double> [#uses=1]
2010-04-29 04:27:48 +08:00
store double %4 , double * %retval , align 8 , !dbg !16
br label %return , !dbg !16
2010-01-26 08:09:58 +08:00
return: ; preds = %entry
2015-02-28 05:17:42 +08:00
%retval1 = load double , double * %retval , !dbg !16 ; <double> [#uses=1]
2010-04-29 04:27:48 +08:00
ret double %retval1 , !dbg !16
2010-01-26 08:09:58 +08:00
}
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
llvm-svn: 218787
2014-10-02 02:55:02 +08:00
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) nounwind readnone
2010-01-26 08:09:58 +08:00
2013-03-08 08:23:31 +08:00
!llvm.dbg.cu = ! { !3 }
2013-11-23 05:49:45 +08:00
!llvm.module.flags = ! { !21 }
2013-03-08 08:23:31 +08:00
2015-08-01 02:58:39 +08:00
!0 = !DILocalVariable ( name: "my_r0" , line: 11 , arg: 1 , scope: !1 , file: !2 , type: !7 )
2016-04-15 23:57:41 +08:00
!1 = distinct !DISubprogram ( name: "foo" , linkageName: "foo" , line: 11 , isLocal: false , isDefinition: true , virtualIndex: 6 , isOptimized: false , unit: !3 , scopeLine: 11 , file: !19 , scope: !2 , type: !4 )
2015-04-30 00:38:44 +08:00
!2 = !DIFile ( filename: "b2.c" , directory: "/tmp/" )
2016-04-15 23:57:41 +08:00
!3 = distinct !DICompileUnit ( language: D W _ L A N G _ C 89 , producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)" , isOptimized: false , emissionKind: F u l l D e b u g , file: !19 , enums: !20 , retainedTypes: !20 )
2015-04-30 00:38:44 +08:00
!4 = !DISubroutineType ( types: !5 )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
!5 = ! { !6 , !7 }
2015-04-30 00:38:44 +08:00
!6 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "double" , size: 64 , align: 64 , encoding: D W _ A T E _ float )
!7 = !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "Rect" , line: 6 , size: 256 , align: 64 , file: !19 , scope: !2 , elements: !8 )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
!8 = ! { !9 , !14 }
2015-04-30 00:38:44 +08:00
!9 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "P1" , line: 7 , size: 128 , align: 64 , file: !19 , scope: !7 , baseType: !10 )
!10 = !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "Pt" , line: 1 , size: 128 , align: 64 , file: !19 , scope: !2 , elements: !11 )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
!11 = ! { !12 , !13 }
2015-04-30 00:38:44 +08:00
!12 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "x" , line: 2 , size: 64 , align: 64 , file: !19 , scope: !10 , baseType: !6 )
!13 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "y" , line: 3 , size: 64 , align: 64 , offset: 64 , file: !19 , scope: !10 , baseType: !6 )
!14 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "P2" , line: 8 , size: 128 , align: 64 , offset: 128 , file: !19 , scope: !7 , baseType: !10 )
!15 = !DILocation ( line: 11 , scope: !1 )
!16 = !DILocation ( line: 12 , scope: !17 )
!17 = distinct !DILexicalBlock ( line: 11 , column: 0 , file: !19 , scope: !1 )
!19 = !DIFile ( filename: "b2.c" , directory: "/tmp/" )
2015-03-28 04:46:33 +08:00
!20 = ! { }
2015-03-04 01:24:31 +08:00
!21 = ! { i32 1 , !"Debug Info Version" , i32 3 }