Convert all tests using TCL-style quoting to use shell-style quoting.
This was done through the aid of a terrible Perl creation. I will not
paste any of the horrors here. Suffice to say, it require multiple
staged rounds of replacements, state carried between, and a few
nested-construct-parsing hacks that I'm not proud of. It happens, by
luck, to be able to deal with all the TCL-quoting patterns in evidence
in the LLVM test suite.
If anyone is maintaining large out-of-tree test trees, feel free to poke
me and I'll send you the steps I used to convert things, as well as
answer any painful questions etc. IRC works best for this type of thing
I find.
Once converted, switch the LLVM lit config to use ShTests the same as
Clang. In addition to being able to delete large amounts of Python code
from 'lit', this will also simplify the entire test suite and some of
lit's architecture.
Finally, the test suite runs 33% faster on Linux now. ;]
For my 16-hardware-thread (2x 4-core xeon e5520): 36s -> 24s
llvm-svn: 159525
2012-07-02 20:47:22 +08:00
; RUN: llc < %s -march=ppc32 | grep "__trampoline_setup"
2008-09-17 08:30:57 +08:00
module asm "\09.lazy_reference .objc_class_name_NSImageRep"
module asm "\09.objc_class_name_NSBitmapImageRep=0"
module asm "\09.globl .objc_class_name_NSBitmapImageRep"
%struct.CGImage = type opaque
%"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" = type { %struct.NSBitmapImageRep * , void ( %struct.__block_1 * , %struct.CGImage * ) * }
%struct.NSBitmapImageRep = type { %struct.NSImageRep }
%struct.NSImageRep = type { }
%struct.NSZone = type opaque
%struct.__block_1 = type { %struct.__invoke_impl , %struct.NSZone * , %struct.NSBitmapImageRep * * }
%struct.__builtin_trampoline = type { [ 40 x i8 ] }
%struct.__invoke_impl = type { i8 * , i32 , i32 , i8 * }
%struct._objc__method_prototype_list = type opaque
%struct._objc_class = type { %struct._objc_class * , %struct._objc_class * , i8 * , i32 , i32 , i32 , %struct._objc_ivar_list * , %struct._objc_method_list * , %struct.objc_cache * , %struct._objc_protocol * * , i8 * , %struct._objc_class_ext * }
%struct._objc_class_ext = type opaque
%struct._objc_ivar_list = type opaque
%struct._objc_method = type { %struct.objc_selector * , i8 * , i8 * }
%struct._objc_method_list = type opaque
%struct._objc_module = type { i32 , i32 , i8 * , %struct._objc_symtab * }
%struct._objc_protocol = type { %struct._objc_protocol_extension * , i8 * , %struct._objc_protocol * * , %struct._objc__method_prototype_list * , %struct._objc__method_prototype_list * }
%struct._objc_protocol_extension = type opaque
%struct._objc_super = type { %struct.objc_object * , %struct._objc_class * }
%struct._objc_symtab = type { i32 , %struct.objc_selector * * , i16 , i16 , [ 1 x i8 * ] }
%struct.anon = type { %struct._objc__method_prototype_list * , i32 , [ 1 x %struct._objc_method ] }
%struct.objc_cache = type opaque
%struct.objc_object = type opaque
%struct.objc_selector = type opaque
%struct.objc_super = type opaque
@_NSConcreteStackBlock = external global i8 * ; <i8**> [#uses=1]
@"\01L_OBJC_SELECTOR_REFERENCES_1" = internal global %struct.objc_selector * bitcast ( [ 34 x i8 ] * @"\01L_OBJC_METH_VAR_NAME_1" to %struct.objc_selector * ) , section "__OBJC,__message_refs,literal_pointers,no_dead_strip" ; <%struct.objc_selector**> [#uses=2]
2015-03-14 02:20:45 +08:00
@"\01L_OBJC_CLASS_NSBitmapImageRep" = internal global %struct._objc_class { %struct._objc_class * @"\01L_OBJC_METACLASS_NSBitmapImageRep" , %struct._objc_class * bitcast ( [ 11 x i8 ] * @"\01L_OBJC_CLASS_NAME_1" to %struct._objc_class * ) , i8 * getelementptr ( [ 17 x i8 ] , [ 17 x i8 ] * @"\01L_OBJC_CLASS_NAME_0" , i32 0 , i32 0 ) , i32 0 , i32 1 , i32 0 , %struct._objc_ivar_list * null , %struct._objc_method_list * bitcast ( { i8 * , i32 , [ 1 x %struct._objc_method ] } * @"\01L_OBJC_INSTANCE_METHODS_NSBitmapImageRep" to %struct._objc_method_list * ) , %struct.objc_cache * null , %struct._objc_protocol * * null , i8 * null , %struct._objc_class_ext * null } , section "__OBJC,__class,regular,no_dead_strip" ; <%struct._objc_class*> [#uses=3]
2008-09-17 08:30:57 +08:00
@"\01L_OBJC_SELECTOR_REFERENCES_0" = internal global %struct.objc_selector * bitcast ( [ 14 x i8 ] * @"\01L_OBJC_METH_VAR_NAME_0" to %struct.objc_selector * ) , section "__OBJC,__message_refs,literal_pointers,no_dead_strip" ; <%struct.objc_selector**> [#uses=2]
@"\01L_OBJC_SYMBOLS" = internal global { i32 , %struct.objc_selector * * , i16 , i16 , [ 1 x %struct._objc_class * ] } { i32 0 , %struct.objc_selector * * null , i16 1 , i16 0 , [ 1 x %struct._objc_class * ] [ %struct._objc_class * @"\01L_OBJC_CLASS_NSBitmapImageRep" ] } , section "__OBJC,__symbols,regular,no_dead_strip" ; <{ i32, %struct.objc_selector**, i16, i16, [1 x %struct._objc_class*] }*> [#uses=2]
@"\01L_OBJC_METH_VAR_NAME_0" = internal global [ 14 x i8 ] c "copyWithZone:\00" , section "__TEXT,__cstring,cstring_literals" , align 4 ; <[14 x i8]*> [#uses=2]
@"\01L_OBJC_METH_VAR_TYPE_0" = internal global [ 20 x i8 ] c "@12@0:4^{_NSZone=}8\00" , section "__TEXT,__cstring,cstring_literals" , align 4 ; <[20 x i8]*> [#uses=1]
2015-03-14 02:20:45 +08:00
@"\01L_OBJC_INSTANCE_METHODS_NSBitmapImageRep" = internal global { i8 * , i32 , [ 1 x %struct._objc_method ] } { i8 * null , i32 1 , [ 1 x %struct._objc_method ] [ %struct._objc_method { %struct.objc_selector * bitcast ( [ 14 x i8 ] * @"\01L_OBJC_METH_VAR_NAME_0" to %struct.objc_selector * ) , i8 * getelementptr ( [ 20 x i8 ] , [ 20 x i8 ] * @"\01L_OBJC_METH_VAR_TYPE_0" , i32 0 , i32 0 ) , i8 * bitcast ( %struct.objc_object * ( %struct.NSBitmapImageRep * , %struct.objc_selector * , %struct.NSZone * ) * @"-[NSBitmapImageRep copyWithZone:]" to i8 * ) } ] } , section "__OBJC,__inst_meth,regular,no_dead_strip" ; <{ i8*, i32, [1 x %struct._objc_method] }*> [#uses=2]
2008-09-17 08:30:57 +08:00
@"\01L_OBJC_CLASS_NAME_0" = internal global [ 17 x i8 ] c "NSBitmapImageRep\00" , section "__TEXT,__cstring,cstring_literals" , align 4 ; <[17 x i8]*> [#uses=1]
@"\01L_OBJC_CLASS_NAME_1" = internal global [ 11 x i8 ] c "NSImageRep\00" , section "__TEXT,__cstring,cstring_literals" , align 4 ; <[11 x i8]*> [#uses=2]
2015-03-14 02:20:45 +08:00
@"\01L_OBJC_METACLASS_NSBitmapImageRep" = internal global %struct._objc_class { %struct._objc_class * bitcast ( [ 11 x i8 ] * @"\01L_OBJC_CLASS_NAME_1" to %struct._objc_class * ) , %struct._objc_class * bitcast ( [ 11 x i8 ] * @"\01L_OBJC_CLASS_NAME_1" to %struct._objc_class * ) , i8 * getelementptr ( [ 17 x i8 ] , [ 17 x i8 ] * @"\01L_OBJC_CLASS_NAME_0" , i32 0 , i32 0 ) , i32 0 , i32 2 , i32 48 , %struct._objc_ivar_list * null , %struct._objc_method_list * null , %struct.objc_cache * null , %struct._objc_protocol * * null , i8 * null , %struct._objc_class_ext * null } , section "__OBJC,__meta_class,regular,no_dead_strip" ; <%struct._objc_class*> [#uses=2]
2008-09-17 08:30:57 +08:00
@"\01L_OBJC_METH_VAR_NAME_1" = internal global [ 34 x i8 ] c "_performBlockUsingBackingCGImage:\00" , section "__TEXT,__cstring,cstring_literals" , align 4 ; <[34 x i8]*> [#uses=2]
@"\01L_OBJC_IMAGE_INFO" = internal constant [ 2 x i32 ] zeroinitializer , section "__OBJC, __image_info,regular" ; <[2 x i32]*> [#uses=1]
@"\01L_OBJC_CLASS_NAME_2" = internal global [ 1 x i8 ] zeroinitializer , section "__TEXT,__cstring,cstring_literals" , align 4 ; <[1 x i8]*> [#uses=1]
2015-03-14 02:20:45 +08:00
@"\01L_OBJC_MODULES" = internal global %struct._objc_module { i32 7 , i32 16 , i8 * getelementptr ( [ 1 x i8 ] , [ 1 x i8 ] * @"\01L_OBJC_CLASS_NAME_2" , i32 0 , i32 0 ) , %struct._objc_symtab * bitcast ( { i32 , %struct.objc_selector * * , i16 , i16 , [ 1 x %struct._objc_class * ] } * @"\01L_OBJC_SYMBOLS" to %struct._objc_symtab * ) } , section "__OBJC,__module_info,regular,no_dead_strip" ; <%struct._objc_module*> [#uses=1]
@llvm.used = appending global [ 14 x i8 * ] [ i8 * bitcast ( %struct.objc_selector * * @"\01L_OBJC_SELECTOR_REFERENCES_1" to i8 * ) , i8 * bitcast ( %struct._objc_class * @"\01L_OBJC_CLASS_NSBitmapImageRep" to i8 * ) , i8 * bitcast ( %struct.objc_selector * * @"\01L_OBJC_SELECTOR_REFERENCES_0" to i8 * ) , i8 * bitcast ( { i32 , %struct.objc_selector * * , i16 , i16 , [ 1 x %struct._objc_class * ] } * @"\01L_OBJC_SYMBOLS" to i8 * ) , i8 * getelementptr ( [ 14 x i8 ] , [ 14 x i8 ] * @"\01L_OBJC_METH_VAR_NAME_0" , i32 0 , i32 0 ) , i8 * getelementptr ( [ 20 x i8 ] , [ 20 x i8 ] * @"\01L_OBJC_METH_VAR_TYPE_0" , i32 0 , i32 0 ) , i8 * bitcast ( { i8 * , i32 , [ 1 x %struct._objc_method ] } * @"\01L_OBJC_INSTANCE_METHODS_NSBitmapImageRep" to i8 * ) , i8 * getelementptr ( [ 17 x i8 ] , [ 17 x i8 ] * @"\01L_OBJC_CLASS_NAME_0" , i32 0 , i32 0 ) , i8 * getelementptr ( [ 11 x i8 ] , [ 11 x i8 ] * @"\01L_OBJC_CLASS_NAME_1" , i32 0 , i32 0 ) , i8 * bitcast ( %struct._objc_class * @"\01L_OBJC_METACLASS_NSBitmapImageRep" to i8 * ) , i8 * getelementptr ( [ 34 x i8 ] , [ 34 x i8 ] * @"\01L_OBJC_METH_VAR_NAME_1" , i32 0 , i32 0 ) , i8 * bitcast ( [ 2 x i32 ] * @"\01L_OBJC_IMAGE_INFO" to i8 * ) , i8 * getelementptr ( [ 1 x i8 ] , [ 1 x i8 ] * @"\01L_OBJC_CLASS_NAME_2" , i32 0 , i32 0 ) , i8 * bitcast ( %struct._objc_module * @"\01L_OBJC_MODULES" to i8 * ) ] , section "llvm.metadata" ; <[14 x i8*]*> [#uses=0]
2008-09-17 08:30:57 +08:00
define internal %struct.objc_object * @"-[NSBitmapImageRep copyWithZone:]" ( %struct.NSBitmapImageRep * %self , %struct.objc_selector * %_cmd , %struct.NSZone * %zone ) nounwind {
entry:
%self_addr = alloca %struct.NSBitmapImageRep * ; <%struct.NSBitmapImageRep**> [#uses=2]
%_cmd_addr = alloca %struct.objc_selector * ; <%struct.objc_selector**> [#uses=1]
%zone_addr = alloca %struct.NSZone * ; <%struct.NSZone**> [#uses=2]
%retval = alloca %struct.objc_object * ; <%struct.objc_object**> [#uses=1]
%__block_holder_tmp_1.0 = alloca %struct.__block_1 ; <%struct.__block_1*> [#uses=7]
%new = alloca %struct.NSBitmapImageRep * ; <%struct.NSBitmapImageRep**> [#uses=2]
%self.1 = alloca %struct.objc_object * ; <%struct.objc_object**> [#uses=2]
%0 = alloca i8 * ; <i8**> [#uses=2]
%TRAMP.9 = alloca %struct.__builtin_trampoline , align 4 ; <%struct.__builtin_trampoline*> [#uses=1]
%1 = alloca void ( %struct.__block_1 * , %struct.CGImage * ) * ; <void (%struct.__block_1*, %struct.CGImage*)**> [#uses=2]
%2 = alloca %struct.NSBitmapImageRep * ; <%struct.NSBitmapImageRep**> [#uses=2]
%FRAME.7 = alloca %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" ; <%"struct.FRAME.-[NSBitmapImageRep copyWithZone:]"*> [#uses=5]
%"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
store %struct.NSBitmapImageRep * %self , %struct.NSBitmapImageRep * * %self_addr
store %struct.objc_selector * %_cmd , %struct.objc_selector * * %_cmd_addr
store %struct.NSZone * %zone , %struct.NSZone * * %zone_addr
[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
%3 = getelementptr %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" , %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" * %FRAME.7 , i32 0 , i32 0 ; <%struct.NSBitmapImageRep**> [#uses=1]
2015-02-28 05:17:42 +08:00
%4 = load %struct.NSBitmapImageRep * , %struct.NSBitmapImageRep * * %self_addr , align 4 ; <%struct.NSBitmapImageRep*> [#uses=1]
2008-09-17 08:30:57 +08:00
store %struct.NSBitmapImageRep * %4 , %struct.NSBitmapImageRep * * %3 , align 4
%TRAMP.91 = bitcast %struct.__builtin_trampoline * %TRAMP.9 to i8 * ; <i8*> [#uses=1]
%FRAME.72 = bitcast %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" * %FRAME.7 to i8 * ; <i8*> [#uses=1]
2011-09-06 21:37:06 +08:00
call void @llvm.init.trampoline ( i8 * %TRAMP.91 , i8 * bitcast ( void ( %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" * , %struct.__block_1 * , %struct.CGImage * ) * @__helper_1.1632 to i8 * ) , i8 * %FRAME.72 ) ; <i8*> [#uses=1]
%tramp = call i8 * @llvm.adjust.trampoline ( i8 * %TRAMP.91 )
2008-09-17 08:30:57 +08:00
store i8 * %tramp , i8 * * %0 , align 4
[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
%5 = getelementptr %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" , %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" * %FRAME.7 , i32 0 , i32 1 ; <void (%struct.__block_1*, %struct.CGImage*)**> [#uses=1]
2015-02-28 05:17:42 +08:00
%6 = load i8 * , i8 * * %0 , align 4 ; <i8*> [#uses=1]
2008-09-17 08:30:57 +08:00
%7 = bitcast i8 * %6 to void ( %struct.__block_1 * , %struct.CGImage * ) * ; <void (%struct.__block_1*, %struct.CGImage*)*> [#uses=1]
store void ( %struct.__block_1 * , %struct.CGImage * ) * %7 , void ( %struct.__block_1 * , %struct.CGImage * ) * * %5 , align 4
store %struct.NSBitmapImageRep * null , %struct.NSBitmapImageRep * * %new , align 4
[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
%8 = getelementptr %struct.__block_1 , %struct.__block_1 * %__block_holder_tmp_1.0 , i32 0 , i32 0 ; <%struct.__invoke_impl*> [#uses=1]
%9 = getelementptr %struct.__invoke_impl , %struct.__invoke_impl * %8 , i32 0 , i32 0 ; <i8**> [#uses=1]
2008-09-17 08:30:57 +08:00
store i8 * bitcast ( i8 * * @_NSConcreteStackBlock to i8 * ) , i8 * * %9 , align 4
[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
%10 = getelementptr %struct.__block_1 , %struct.__block_1 * %__block_holder_tmp_1.0 , i32 0 , i32 0 ; <%struct.__invoke_impl*> [#uses=1]
%11 = getelementptr %struct.__invoke_impl , %struct.__invoke_impl * %10 , i32 0 , i32 1 ; <i32*> [#uses=1]
2008-09-17 08:30:57 +08:00
store i32 67108864 , i32 * %11 , align 4
[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
%12 = getelementptr %struct.__block_1 , %struct.__block_1 * %__block_holder_tmp_1.0 , i32 0 , i32 0 ; <%struct.__invoke_impl*> [#uses=1]
%13 = getelementptr %struct.__invoke_impl , %struct.__invoke_impl * %12 , i32 0 , i32 2 ; <i32*> [#uses=1]
2008-09-17 08:30:57 +08:00
store i32 24 , i32 * %13 , align 4
[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
%14 = getelementptr %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" , %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" * %FRAME.7 , i32 0 , i32 1 ; <void (%struct.__block_1*, %struct.CGImage*)**> [#uses=1]
2015-02-28 05:17:42 +08:00
%15 = load void ( %struct.__block_1 * , %struct.CGImage * ) * , void ( %struct.__block_1 * , %struct.CGImage * ) * * %14 , align 4 ; <void (%struct.__block_1*, %struct.CGImage*)*> [#uses=1]
2008-09-17 08:30:57 +08:00
store void ( %struct.__block_1 * , %struct.CGImage * ) * %15 , void ( %struct.__block_1 * , %struct.CGImage * ) * * %1 , align 4
[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
%16 = getelementptr %struct.__block_1 , %struct.__block_1 * %__block_holder_tmp_1.0 , i32 0 , i32 0 ; <%struct.__invoke_impl*> [#uses=1]
%17 = getelementptr %struct.__invoke_impl , %struct.__invoke_impl * %16 , i32 0 , i32 3 ; <i8**> [#uses=1]
2015-02-28 05:17:42 +08:00
%18 = load void ( %struct.__block_1 * , %struct.CGImage * ) * , void ( %struct.__block_1 * , %struct.CGImage * ) * * %1 , align 4 ; <void (%struct.__block_1*, %struct.CGImage*)*> [#uses=1]
2008-09-17 08:30:57 +08:00
%19 = bitcast void ( %struct.__block_1 * , %struct.CGImage * ) * %18 to i8 * ; <i8*> [#uses=1]
store i8 * %19 , i8 * * %17 , align 4
[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
%20 = getelementptr %struct.__block_1 , %struct.__block_1 * %__block_holder_tmp_1.0 , i32 0 , i32 1 ; <%struct.NSZone**> [#uses=1]
2015-02-28 05:17:42 +08:00
%21 = load %struct.NSZone * , %struct.NSZone * * %zone_addr , align 4 ; <%struct.NSZone*> [#uses=1]
2008-09-17 08:30:57 +08:00
store %struct.NSZone * %21 , %struct.NSZone * * %20 , align 4
[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
%22 = getelementptr %struct.__block_1 , %struct.__block_1 * %__block_holder_tmp_1.0 , i32 0 , i32 2 ; <%struct.NSBitmapImageRep***> [#uses=1]
2008-09-17 08:30:57 +08:00
store %struct.NSBitmapImageRep * * %new , %struct.NSBitmapImageRep * * * %22 , align 4
[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
%23 = getelementptr %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" , %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" * %FRAME.7 , i32 0 , i32 0 ; <%struct.NSBitmapImageRep**> [#uses=1]
2015-02-28 05:17:42 +08:00
%24 = load %struct.NSBitmapImageRep * , %struct.NSBitmapImageRep * * %23 , align 4 ; <%struct.NSBitmapImageRep*> [#uses=1]
2008-09-17 08:30:57 +08:00
store %struct.NSBitmapImageRep * %24 , %struct.NSBitmapImageRep * * %2 , align 4
2015-02-28 05:17:42 +08:00
%25 = load %struct.NSBitmapImageRep * , %struct.NSBitmapImageRep * * %2 , align 4 ; <%struct.NSBitmapImageRep*> [#uses=1]
2008-09-17 08:30:57 +08:00
%26 = bitcast %struct.NSBitmapImageRep * %25 to %struct.objc_object * ; <%struct.objc_object*> [#uses=1]
store %struct.objc_object * %26 , %struct.objc_object * * %self.1 , align 4
2015-02-28 05:17:42 +08:00
%27 = load %struct.objc_selector * , %struct.objc_selector * * @"\01L_OBJC_SELECTOR_REFERENCES_1" , align 4 ; <%struct.objc_selector*> [#uses=1]
2008-09-17 08:30:57 +08:00
%__block_holder_tmp_1.03 = bitcast %struct.__block_1 * %__block_holder_tmp_1.0 to void ( %struct.CGImage * ) * ; <void (%struct.CGImage*)*> [#uses=1]
2015-02-28 05:17:42 +08:00
%28 = load %struct.objc_object * , %struct.objc_object * * %self.1 , align 4 ; <%struct.objc_object*> [#uses=1]
[opaque pointer type] Add textual IR support for explicit type parameter to the call instruction
See r230786 and r230794 for similar changes to gep and load
respectively.
Call is a bit different because it often doesn't have a single explicit
type - usually the type is deduced from the arguments, and just the
return type is explicit. In those cases there's no need to change the
IR.
When that's not the case, the IR usually contains the pointer type of
the first operand - but since typed pointers are going away, that
representation is insufficient so I'm just stripping the "pointerness"
of the explicit type away.
This does make the IR a bit weird - it /sort of/ reads like the type of
the first operand: "call void () %x(" but %x is actually of type "void
()*" and will eventually be just of type "ptr". But this seems not too
bad and I don't think it would benefit from repeating the type
("void (), void () * %x(" and then eventually "void (), ptr %x(") as has
been done with gep and load.
This also has a side benefit: since the explicit type is no longer a
pointer, there's no ambiguity between an explicit type and a function
that returns a function pointer. Previously this case needed an explicit
type (eg: a function returning a void() function was written as
"call void () () * @x(" rather than "call void () * @x(" because of the
ambiguity between a function returning a pointer to a void() function
and a function returning void).
No ambiguity means even function pointer return types can just be
written alone, without writing the whole function's type.
This leaves /only/ the varargs case where the explicit type is required.
Given the special type syntax in call instructions, the regex-fu used
for migration was a bit more involved in its own unique way (as every
one of these is) so here it is. Use it in conjunction with the apply.sh
script and associated find/xargs commands I've provided in rr230786 to
migrate your out of tree tests. Do let me know if any of this doesn't
cover your cases & we can iterate on a more general script/regexes to
help others with out of tree tests.
About 9 test cases couldn't be automatically migrated - half of those
were functions returning function pointers, where I just had to manually
delete the function argument types now that we didn't need an explicit
function type there. The other half were typedefs of function types used
in calls - just had to manually drop the * from those.
import fileinput
import sys
import re
pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)')
addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$")
func_end = re.compile("(?:void.*|\)\s*)\*$")
def conv(match, line):
if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)):
return line
return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():]
for line in sys.stdin:
sys.stdout.write(conv(re.search(pat, line), line))
llvm-svn: 235145
2015-04-17 07:24:18 +08:00
%29 = call %struct.objc_object * ( %struct.objc_object * , %struct.objc_selector * , . . . ) inttoptr ( i64 4294901504 to %struct.objc_object * ( %struct.objc_object * , %struct.objc_selector * , . . . ) * ) ( %struct.objc_object * %28 , %struct.objc_selector * %27 , void ( %struct.CGImage * ) * %__block_holder_tmp_1.03 ) nounwind ; <%struct.objc_object*> [#uses=0]
2008-09-17 08:30:57 +08:00
br label %return
return: ; preds = %entry
2015-02-28 05:17:42 +08:00
%retval5 = load %struct.objc_object * , %struct.objc_object * * %retval ; <%struct.objc_object*> [#uses=1]
2008-09-17 08:30:57 +08:00
ret %struct.objc_object * %retval5
}
2011-09-06 21:37:06 +08:00
declare void @llvm.init.trampoline ( i8 * , i8 * , i8 * ) nounwind
declare i8 * @llvm.adjust.trampoline ( i8 * ) nounwind
2008-09-17 08:30:57 +08:00
define internal void @__helper_1.1632 ( %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" * nest %CHAIN.8 , %struct.__block_1 * %_self , %struct.CGImage * %cgImage ) nounwind {
entry:
%CHAIN.8_addr = alloca %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" * ; <%"struct.FRAME.-[NSBitmapImageRep copyWithZone:]"**> [#uses=2]
%_self_addr = alloca %struct.__block_1 * ; <%struct.__block_1**> [#uses=3]
%cgImage_addr = alloca %struct.CGImage * ; <%struct.CGImage**> [#uses=1]
%zone = alloca %struct.NSZone * ; <%struct.NSZone**> [#uses=2]
%objc_super = alloca %struct._objc_super ; <%struct._objc_super*> [#uses=3]
%new = alloca %struct.NSBitmapImageRep * * ; <%struct.NSBitmapImageRep***> [#uses=2]
%objc_super.5 = alloca %struct.objc_super * ; <%struct.objc_super**> [#uses=2]
%0 = alloca %struct.NSBitmapImageRep * ; <%struct.NSBitmapImageRep**> [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
store %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" * %CHAIN.8 , %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" * * %CHAIN.8_addr
store %struct.__block_1 * %_self , %struct.__block_1 * * %_self_addr
store %struct.CGImage * %cgImage , %struct.CGImage * * %cgImage_addr
2015-02-28 05:17:42 +08:00
%1 = load %struct.__block_1 * , %struct.__block_1 * * %_self_addr , align 4 ; <%struct.__block_1*> [#uses=1]
[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
%2 = getelementptr %struct.__block_1 , %struct.__block_1 * %1 , i32 0 , i32 2 ; <%struct.NSBitmapImageRep***> [#uses=1]
2015-02-28 05:17:42 +08:00
%3 = load %struct.NSBitmapImageRep * * , %struct.NSBitmapImageRep * * * %2 , align 4 ; <%struct.NSBitmapImageRep**> [#uses=1]
2008-09-17 08:30:57 +08:00
store %struct.NSBitmapImageRep * * %3 , %struct.NSBitmapImageRep * * * %new , align 4
2015-02-28 05:17:42 +08:00
%4 = load %struct.__block_1 * , %struct.__block_1 * * %_self_addr , align 4 ; <%struct.__block_1*> [#uses=1]
[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
%5 = getelementptr %struct.__block_1 , %struct.__block_1 * %4 , i32 0 , i32 1 ; <%struct.NSZone**> [#uses=1]
2015-02-28 05:17:42 +08:00
%6 = load %struct.NSZone * , %struct.NSZone * * %5 , align 4 ; <%struct.NSZone*> [#uses=1]
2008-09-17 08:30:57 +08:00
store %struct.NSZone * %6 , %struct.NSZone * * %zone , align 4
2015-02-28 05:17:42 +08:00
%7 = load %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" * , %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" * * %CHAIN.8_addr , align 4 ; <%"struct.FRAME.-[NSBitmapImageRep copyWithZone:]"*> [#uses=1]
[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
%8 = getelementptr %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" , %"struct.FRAME.-[NSBitmapImageRep copyWithZone:]" * %7 , i32 0 , i32 0 ; <%struct.NSBitmapImageRep**> [#uses=1]
2015-02-28 05:17:42 +08:00
%9 = load %struct.NSBitmapImageRep * , %struct.NSBitmapImageRep * * %8 , align 4 ; <%struct.NSBitmapImageRep*> [#uses=1]
2008-09-17 08:30:57 +08:00
store %struct.NSBitmapImageRep * %9 , %struct.NSBitmapImageRep * * %0 , align 4
2015-02-28 05:17:42 +08:00
%10 = load %struct.NSBitmapImageRep * , %struct.NSBitmapImageRep * * %0 , align 4 ; <%struct.NSBitmapImageRep*> [#uses=1]
2008-09-17 08:30:57 +08:00
%11 = bitcast %struct.NSBitmapImageRep * %10 to %struct.objc_object * ; <%struct.objc_object*> [#uses=1]
[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
%12 = getelementptr %struct._objc_super , %struct._objc_super * %objc_super , i32 0 , i32 0 ; <%struct.objc_object**> [#uses=1]
2008-09-17 08:30:57 +08:00
store %struct.objc_object * %11 , %struct.objc_object * * %12 , align 4
2015-03-14 02:20:45 +08:00
%13 = load %struct._objc_class * , %struct._objc_class * * getelementptr ( %struct._objc_class , %struct._objc_class * @"\01L_OBJC_CLASS_NSBitmapImageRep" , i32 0 , i32 1 ) , align 4 ; <%struct._objc_class*> [#uses=1]
[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
%14 = getelementptr %struct._objc_super , %struct._objc_super * %objc_super , i32 0 , i32 1 ; <%struct._objc_class**> [#uses=1]
2008-09-17 08:30:57 +08:00
store %struct._objc_class * %13 , %struct._objc_class * * %14 , align 4
%objc_super1 = bitcast %struct._objc_super * %objc_super to %struct.objc_super * ; <%struct.objc_super*> [#uses=1]
store %struct.objc_super * %objc_super1 , %struct.objc_super * * %objc_super.5 , align 4
2015-02-28 05:17:42 +08:00
%15 = load %struct.objc_selector * , %struct.objc_selector * * @"\01L_OBJC_SELECTOR_REFERENCES_0" , align 4 ; <%struct.objc_selector*> [#uses=1]
%16 = load %struct.objc_super * , %struct.objc_super * * %objc_super.5 , align 4 ; <%struct.objc_super*> [#uses=1]
%17 = load %struct.NSZone * , %struct.NSZone * * %zone , align 4 ; <%struct.NSZone*> [#uses=1]
[opaque pointer type] Add textual IR support for explicit type parameter to the call instruction
See r230786 and r230794 for similar changes to gep and load
respectively.
Call is a bit different because it often doesn't have a single explicit
type - usually the type is deduced from the arguments, and just the
return type is explicit. In those cases there's no need to change the
IR.
When that's not the case, the IR usually contains the pointer type of
the first operand - but since typed pointers are going away, that
representation is insufficient so I'm just stripping the "pointerness"
of the explicit type away.
This does make the IR a bit weird - it /sort of/ reads like the type of
the first operand: "call void () %x(" but %x is actually of type "void
()*" and will eventually be just of type "ptr". But this seems not too
bad and I don't think it would benefit from repeating the type
("void (), void () * %x(" and then eventually "void (), ptr %x(") as has
been done with gep and load.
This also has a side benefit: since the explicit type is no longer a
pointer, there's no ambiguity between an explicit type and a function
that returns a function pointer. Previously this case needed an explicit
type (eg: a function returning a void() function was written as
"call void () () * @x(" rather than "call void () * @x(" because of the
ambiguity between a function returning a pointer to a void() function
and a function returning void).
No ambiguity means even function pointer return types can just be
written alone, without writing the whole function's type.
This leaves /only/ the varargs case where the explicit type is required.
Given the special type syntax in call instructions, the regex-fu used
for migration was a bit more involved in its own unique way (as every
one of these is) so here it is. Use it in conjunction with the apply.sh
script and associated find/xargs commands I've provided in rr230786 to
migrate your out of tree tests. Do let me know if any of this doesn't
cover your cases & we can iterate on a more general script/regexes to
help others with out of tree tests.
About 9 test cases couldn't be automatically migrated - half of those
were functions returning function pointers, where I just had to manually
delete the function argument types now that we didn't need an explicit
function type there. The other half were typedefs of function types used
in calls - just had to manually drop the * from those.
import fileinput
import sys
import re
pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)')
addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$")
func_end = re.compile("(?:void.*|\)\s*)\*$")
def conv(match, line):
if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)):
return line
return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():]
for line in sys.stdin:
sys.stdout.write(conv(re.search(pat, line), line))
llvm-svn: 235145
2015-04-17 07:24:18 +08:00
%18 = call %struct.objc_object * ( %struct.objc_super * , %struct.objc_selector * , . . . ) @objc_msgSendSuper ( %struct.objc_super * %16 , %struct.objc_selector * %15 , %struct.NSZone * %17 ) nounwind ; <%struct.objc_object*> [#uses=1]
2008-09-17 08:30:57 +08:00
%19 = bitcast %struct.objc_object * %18 to %struct.NSBitmapImageRep * ; <%struct.NSBitmapImageRep*> [#uses=1]
2015-02-28 05:17:42 +08:00
%20 = load %struct.NSBitmapImageRep * * , %struct.NSBitmapImageRep * * * %new , align 4 ; <%struct.NSBitmapImageRep**> [#uses=1]
2008-09-17 08:30:57 +08:00
store %struct.NSBitmapImageRep * %19 , %struct.NSBitmapImageRep * * %20 , align 4
br label %return
return: ; preds = %entry
ret void
}
declare %struct.objc_object * @objc_msgSendSuper ( %struct.objc_super * , %struct.objc_selector * , . . . )