2013-07-24 18:56:43 +00:00
; RUN: llc %s -mtriple=i386-apple-macosx10.6.7 -o /dev/null
2011-06-17 14:16:17 +00:00
; This used to crash because early dup was not ignoring debug instructions.
%struct.cpp_dir = type { %struct.cpp_dir * , i8 * , i32 , i8 , i8 * * , i8 * , i8 * ( i8 * , %struct.cpp_dir * ) * , i64 , i32 , i8 }
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
declare void @llvm.dbg.value ( metadata , i64 , metadata , metadata ) nounwind readnone
2011-06-17 14:16:17 +00:00
define internal i8 * @framework_construct_pathname ( i8 * %fname , %struct.cpp_dir * %dir ) nounwind ssp {
entry:
br i1 undef , label %bb33 , label %bb
bb: ; preds = %entry
%tmp = icmp eq i32 undef , 0
%tmp1 = add i32 0 , 11
2015-04-29 16:38:44 +00:00
call void @llvm.dbg.value ( metadata i32 %tmp1 , i64 0 , metadata !0 , metadata !DIExpression ( ) ) , !dbg !DILocation ( scope: !1 )
2011-06-17 14:16:17 +00:00
br i1 undef , label %bb18 , label %bb31.preheader
bb31.preheader: ; preds = %bb19, %bb
[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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
%tmp2 = getelementptr inbounds i8 , i8 * %fname , i32 0
2011-06-17 14:16:17 +00:00
br label %bb31
bb18: ; preds = %bb
%tmp3 = icmp eq i32 undef , 0
br i1 %tmp3 , label %bb19 , label %bb33
bb19: ; preds = %bb18
call void @foobar ( i32 0 )
br label %bb31.preheader
bb22: ; preds = %bb31
%tmp4 = add i32 0 , %tmp1
call void @foobar ( i32 %tmp4 )
br i1 undef , label %bb33 , label %bb31
bb31: ; preds = %bb22, %bb31.preheader
br i1 false , label %bb33 , label %bb22
bb33: ; preds = %bb31, %bb22, %bb18, %entry
ret i8 * undef
}
declare void @foobar ( i32 )
2013-07-29 18:12:58 +00:00
!llvm.dbg.cu = ! { !4 }
2013-11-22 21:49:45 +00:00
!llvm.module.flags = ! { !47 }
2015-04-29 16:38:44 +00:00
!0 = !DILocalVariable ( tag: D W _ T A G _ a u t o _ v a r i a b l e , name: "frname_len" , line: 517 , scope: !1 , file: !3 , type: !38 )
!1 = distinct !DILexicalBlock ( line: 515 , column: 0 , file: !44 , scope: !2 )
!2 = !DISubprogram ( name: "framework_construct_pathname" , line: 515 , isLocal: true , isDefinition: true , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , file: !44 , scope: null , type: !5 , function: i8 * ( i8 * , %struct.cpp_dir * ) * @framework_construct_pathname )
!3 = !DIFile ( filename: "darwin-c.c" , directory: "/Users/espindola/llvm/build-llvm-gcc/gcc/../../llvm-gcc-4.2/gcc/config" )
!4 = !DICompileUnit ( language: D W _ L A N G _ C 89 , producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)" , isOptimized: true , emissionKind: 0 , file: !44 , enums: !46 , retainedTypes: !46 , subprograms: !45 )
!5 = !DISubroutineType ( types: !6 )
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 19:07:53 +00:00
!6 = ! { !7 , !9 , !11 }
2015-04-29 16:38:44 +00:00
!7 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , size: 32 , align: 32 , file: !44 , scope: !3 , baseType: !8 )
!8 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "char" , size: 8 , align: 8 , encoding: D W _ A T E _ s i g n e d _ c h a r )
!9 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , size: 32 , align: 32 , file: !44 , scope: !3 , baseType: !10 )
!10 = !DIDerivedType ( tag: D W _ T A G _ c o n s t _ type , size: 8 , align: 8 , file: !44 , scope: !3 , baseType: !8 )
!11 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , size: 32 , align: 32 , file: !44 , scope: !3 , baseType: !12 )
!12 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "cpp_dir" , line: 45 , file: !41 , scope: !13 , baseType: !14 )
!13 = !DIFile ( filename: "cpplib.h" , directory: "/Users/espindola/llvm/build-llvm-gcc/gcc/../../llvm-gcc-4.2/gcc/../libcpp/include" )
!14 = !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "cpp_dir" , line: 43 , size: 352 , align: 32 , file: !41 , scope: !3 , elements: !15 )
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 19:07:53 +00:00
!15 = ! { !16 , !18 , !19 , !21 , !23 , !25 , !27 , !29 , !33 , !36 }
2015-04-29 16:38:44 +00:00
!16 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "next" , line: 572 , size: 32 , align: 32 , file: !41 , scope: !14 , baseType: !17 )
!17 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , size: 32 , align: 32 , file: !44 , scope: !3 , baseType: !14 )
!18 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "name" , line: 575 , size: 32 , align: 32 , offset: 32 , file: !41 , scope: !14 , baseType: !7 )
!19 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "len" , line: 576 , size: 32 , align: 32 , offset: 64 , file: !41 , scope: !14 , baseType: !20 )
!20 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "unsigned int" , size: 32 , align: 32 , encoding: D W _ A T E _ u n s i g n e d )
!21 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "sysp" , line: 580 , size: 8 , align: 8 , offset: 96 , file: !41 , scope: !14 , baseType: !22 )
!22 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "unsigned char" , size: 8 , align: 8 , encoding: D W _ A T E _ u n s i g n e d _ c h a r )
!23 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "name_map" , line: 584 , size: 32 , align: 32 , offset: 128 , file: !41 , scope: !14 , baseType: !24 )
!24 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , size: 32 , align: 32 , file: !44 , scope: !3 , baseType: !9 )
!25 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "header_map" , line: 590 , size: 32 , align: 32 , offset: 160 , file: !41 , scope: !14 , baseType: !26 )
!26 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , size: 32 , align: 32 , file: !44 , scope: !3 , baseType: null )
!27 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "construct" , line: 597 , size: 32 , align: 32 , offset: 192 , file: !41 , scope: !14 , baseType: !28 )
!28 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , size: 32 , align: 32 , file: !44 , scope: !3 , baseType: !5 )
!29 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "ino" , line: 601 , size: 64 , align: 64 , offset: 224 , file: !41 , scope: !14 , baseType: !30 )
!30 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "ino_t" , line: 141 , file: !42 , scope: !31 , baseType: !32 )
!31 = !DIFile ( filename: "types.h" , directory: "/usr/include/sys" )
!32 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "long long unsigned int" , size: 64 , align: 64 , encoding: D W _ A T E _ u n s i g n e d )
!33 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "dev" , line: 602 , size: 32 , align: 32 , offset: 288 , file: !41 , scope: !14 , baseType: !34 )
!34 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "dev_t" , line: 107 , file: !42 , scope: !31 , baseType: !35 )
!35 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
!36 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "user_supplied_p" , line: 605 , size: 8 , align: 8 , offset: 320 , file: !41 , scope: !14 , baseType: !37 )
!37 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "_Bool" , size: 8 , align: 8 , encoding: D W _ A T E _ b o o l e a n )
!38 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "size_t" , line: 326 , file: !43 , scope: !39 , baseType: !40 )
!39 = !DIFile ( filename: "stddef.h" , directory: "/Users/espindola/llvm/build-llvm-gcc/./prev-gcc/include" )
!40 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "long unsigned int" , size: 32 , align: 32 , encoding: D W _ A T E _ u n s i g n e d )
!41 = !DIFile ( filename: "cpplib.h" , directory: "/Users/espindola/llvm/build-llvm-gcc/gcc/../../llvm-gcc-4.2/gcc/../libcpp/include" )
!42 = !DIFile ( filename: "types.h" , directory: "/usr/include/sys" )
!43 = !DIFile ( filename: "stddef.h" , directory: "/Users/espindola/llvm/build-llvm-gcc/./prev-gcc/include" )
!44 = !DIFile ( filename: "darwin-c.c" , directory: "/Users/espindola/llvm/build-llvm-gcc/gcc/../../llvm-gcc-4.2/gcc/config" )
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 19:07:53 +00:00
!45 = ! { !2 }
2015-03-27 20:46:33 +00:00
!46 = ! { }
2015-03-03 17:24:31 +00:00
!47 = ! { i32 1 , !"Debug Info Version" , i32 3 }