2020-04-14 17:55:56 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
|
|
; This testcase tests for various features the basicaa test should be able to
|
2002-09-09 02:08:36 +08:00
|
|
|
; determine, as noted in the comments.
|
|
|
|
|
2020-06-27 05:58:01 +08:00
|
|
|
; RUN: opt < %s -basic-aa -gvn -instcombine -dce -S | FileCheck %s --check-prefixes=CHECK,NO_ASSUME
|
|
|
|
; RUN: opt < %s -basic-aa -gvn -instcombine -dce --enable-knowledge-retention -S | FileCheck %s --check-prefixes=CHECK,USE_ASSUME
|
2009-11-03 23:29:06 +08:00
|
|
|
target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
|
2003-06-17 23:16:35 +08:00
|
|
|
|
2008-02-14 14:56:27 +08:00
|
|
|
@Global = external global { i32 }
|
2002-09-09 02:08:36 +08:00
|
|
|
|
2010-08-18 12:25:43 +08:00
|
|
|
declare void @external(i32*)
|
2020-04-14 17:55:56 +08:00
|
|
|
declare void @llvm.assume(i1)
|
2010-08-18 12:25:43 +08:00
|
|
|
|
2020-04-14 17:55:56 +08:00
|
|
|
; Array test: Test that operations on one local array do not invalidate
|
2002-09-09 02:08:36 +08:00
|
|
|
; operations on another array. Important for scientific codes.
|
|
|
|
;
|
2008-02-14 14:56:27 +08:00
|
|
|
define i32 @different_array_test(i64 %A, i64 %B) {
|
2020-06-19 16:32:09 +08:00
|
|
|
; CHECK-LABEL: @different_array_test(
|
|
|
|
; CHECK-NEXT: [[ARRAY11:%.*]] = alloca [100 x i32], align 4
|
|
|
|
; CHECK-NEXT: [[ARRAY22:%.*]] = alloca [200 x i32], align 4
|
|
|
|
; CHECK-NEXT: [[ARRAY22_SUB:%.*]] = getelementptr inbounds [200 x i32], [200 x i32]* [[ARRAY22]], i64 0, i64 0
|
|
|
|
; CHECK-NEXT: [[ARRAY11_SUB:%.*]] = getelementptr inbounds [100 x i32], [100 x i32]* [[ARRAY11]], i64 0, i64 0
|
|
|
|
; CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(i32* [[ARRAY11_SUB]], i32 4) ]
|
|
|
|
; CHECK-NEXT: call void @external(i32* nonnull [[ARRAY11_SUB]])
|
|
|
|
; CHECK-NEXT: call void @external(i32* nonnull [[ARRAY22_SUB]])
|
|
|
|
; CHECK-NEXT: [[POINTER2:%.*]] = getelementptr [200 x i32], [200 x i32]* [[ARRAY22]], i64 0, i64 [[B:%.*]]
|
|
|
|
; CHECK-NEXT: store i32 7, i32* [[POINTER2]], align 4
|
|
|
|
; CHECK-NEXT: ret i32 0
|
2020-04-14 17:55:56 +08:00
|
|
|
;
|
|
|
|
%Array1 = alloca i32, i32 100
|
|
|
|
%Array2 = alloca i32, i32 200
|
|
|
|
call void @llvm.assume(i1 true) ["align"(i32* %Array1, i32 4)]
|
|
|
|
|
|
|
|
call void @external(i32* %Array1)
|
|
|
|
call void @external(i32* %Array2)
|
|
|
|
|
|
|
|
%pointer = getelementptr i32, i32* %Array1, i64 %A
|
|
|
|
%val = load i32, i32* %pointer
|
|
|
|
|
|
|
|
%pointer2 = getelementptr i32, i32* %Array2, i64 %B
|
|
|
|
store i32 7, i32* %pointer2
|
|
|
|
|
|
|
|
%REMOVE = load i32, i32* %pointer ; redundant with above load
|
|
|
|
%retval = sub i32 %REMOVE, %val
|
|
|
|
ret i32 %retval
|
2002-09-09 02:08:36 +08:00
|
|
|
}
|
|
|
|
|
2020-04-14 17:55:56 +08:00
|
|
|
; Constant index test: Constant indexes into the same array should not
|
2002-09-09 02:08:36 +08:00
|
|
|
; interfere with each other. Again, important for scientific codes.
|
|
|
|
;
|
2008-02-14 14:56:27 +08:00
|
|
|
define i32 @constant_array_index_test() {
|
2020-06-19 16:32:09 +08:00
|
|
|
; CHECK-LABEL: @constant_array_index_test(
|
|
|
|
; CHECK-NEXT: [[ARRAY1:%.*]] = alloca [100 x i32], align 4
|
|
|
|
; CHECK-NEXT: [[ARRAY1_SUB:%.*]] = getelementptr inbounds [100 x i32], [100 x i32]* [[ARRAY1]], i64 0, i64 0
|
|
|
|
; CHECK-NEXT: call void @external(i32* nonnull [[ARRAY1_SUB]])
|
|
|
|
; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds [100 x i32], [100 x i32]* [[ARRAY1]], i64 0, i64 6
|
|
|
|
; CHECK-NEXT: store i32 1, i32* [[P2]], align 4
|
|
|
|
; CHECK-NEXT: ret i32 0
|
2020-04-14 17:55:56 +08:00
|
|
|
;
|
|
|
|
%Array = alloca i32, i32 100
|
|
|
|
call void @external(i32* %Array)
|
|
|
|
|
|
|
|
%P1 = getelementptr i32, i32* %Array, i64 7
|
|
|
|
%P2 = getelementptr i32, i32* %Array, i64 6
|
|
|
|
|
|
|
|
%A = load i32, i32* %P1
|
|
|
|
store i32 1, i32* %P2 ; Should not invalidate load
|
|
|
|
%BREMOVE = load i32, i32* %P1
|
|
|
|
%Val = sub i32 %A, %BREMOVE
|
|
|
|
ret i32 %Val
|
2002-09-09 02:08:36 +08:00
|
|
|
}
|
|
|
|
|
2020-04-14 17:55:56 +08:00
|
|
|
; Test that if two pointers are spaced out by a constant getelementptr, that
|
2003-02-10 03:01:00 +08:00
|
|
|
; they cannot alias.
|
2008-02-14 14:56:27 +08:00
|
|
|
define i32 @gep_distance_test(i32* %A) {
|
2020-04-14 17:55:56 +08:00
|
|
|
; NO_ASSUME-LABEL: @gep_distance_test(
|
|
|
|
; NO_ASSUME-NEXT: [[B:%.*]] = getelementptr i32, i32* [[A:%.*]], i64 2
|
|
|
|
; NO_ASSUME-NEXT: store i32 7, i32* [[B]], align 4
|
|
|
|
; NO_ASSUME-NEXT: ret i32 0
|
|
|
|
;
|
|
|
|
; USE_ASSUME-LABEL: @gep_distance_test(
|
2020-05-11 00:20:34 +08:00
|
|
|
; USE_ASSUME-NEXT: [[B:%.*]] = getelementptr i32, i32* [[A:%.*]], i64 2
|
2020-04-14 17:55:56 +08:00
|
|
|
; USE_ASSUME-NEXT: store i32 7, i32* [[B]], align 4
|
Infer alignment of unmarked loads in IR/bitcode parsing.
For IR generated by a compiler, this is really simple: you just take the
datalayout from the beginning of the file, and apply it to all the IR
later in the file. For optimization testcases that don't care about the
datalayout, this is also really simple: we just use the default
datalayout.
The complexity here comes from the fact that some LLVM tools allow
overriding the datalayout: some tools have an explicit flag for this,
some tools will infer a datalayout based on the code generation target.
Supporting this properly required plumbing through a bunch of new
machinery: we want to allow overriding the datalayout after the
datalayout is parsed from the file, but before we use any information
from it. Therefore, IR/bitcode parsing now has a callback to allow tools
to compute the datalayout at the appropriate time.
Not sure if I covered all the LLVM tools that want to use the callback.
(clang? lli? Misc IR manipulation tools like llvm-link?). But this is at
least enough for all the LLVM regression tests, and IR without a
datalayout is not something frontends should generate.
This change had some sort of weird effects for certain CodeGen
regression tests: if the datalayout is overridden with a datalayout with
a different program or stack address space, we now parse IR based on the
overridden datalayout, instead of the one written in the file (or the
default one, if none is specified). This broke a few AVR tests, and one
AMDGPU test.
Outside the CodeGen tests I mentioned, the test changes are all just
fixing CHECK lines and moving around datalayout lines in weird places.
Differential Revision: https://reviews.llvm.org/D78403
2020-05-15 03:59:45 +08:00
|
|
|
; USE_ASSUME-NEXT: call void @llvm.assume(i1 true) [ "dereferenceable"(i32* [[A]], i64 4), "nonnull"(i32* [[A]]), "align"(i32* [[A]], i64 4) ]
|
2020-04-14 17:55:56 +08:00
|
|
|
; USE_ASSUME-NEXT: ret i32 0
|
|
|
|
;
|
|
|
|
%REMOVEu = load i32, i32* %A
|
|
|
|
%B = getelementptr i32, i32* %A, i64 2 ; Cannot alias A
|
|
|
|
store i32 7, i32* %B
|
|
|
|
%REMOVEv = load i32, i32* %A
|
|
|
|
%r = sub i32 %REMOVEu, %REMOVEv
|
|
|
|
ret i32 %r
|
2003-02-10 03:01:00 +08:00
|
|
|
}
|
|
|
|
|
2003-02-26 05:43:37 +08:00
|
|
|
; Test that if two pointers are spaced out by a constant offset, that they
|
|
|
|
; cannot alias, even if there is a variable offset between them...
|
2008-02-14 14:56:27 +08:00
|
|
|
define i32 @gep_distance_test2({i32,i32}* %A, i64 %distance) {
|
2020-04-14 17:55:56 +08:00
|
|
|
; NO_ASSUME-LABEL: @gep_distance_test2(
|
|
|
|
; NO_ASSUME-NEXT: [[B:%.*]] = getelementptr { i32, i32 }, { i32, i32 }* [[A:%.*]], i64 [[DISTANCE:%.*]], i32 1
|
|
|
|
; NO_ASSUME-NEXT: store i32 7, i32* [[B]], align 4
|
|
|
|
; NO_ASSUME-NEXT: ret i32 0
|
|
|
|
;
|
|
|
|
; USE_ASSUME-LABEL: @gep_distance_test2(
|
|
|
|
; USE_ASSUME-NEXT: [[A1:%.*]] = getelementptr { i32, i32 }, { i32, i32 }* [[A:%.*]], i64 0, i32 0
|
|
|
|
; USE_ASSUME-NEXT: [[B:%.*]] = getelementptr { i32, i32 }, { i32, i32 }* [[A]], i64 [[DISTANCE:%.*]], i32 1
|
|
|
|
; USE_ASSUME-NEXT: store i32 7, i32* [[B]], align 4
|
2020-06-19 16:32:09 +08:00
|
|
|
; USE_ASSUME-NEXT: call void @llvm.assume(i1 true) [ "dereferenceable"(i32* [[A1]], i64 4), "nonnull"({ i32, i32 }* [[A]]), "align"(i32* [[A1]], i64 4) ]
|
2020-04-14 17:55:56 +08:00
|
|
|
; USE_ASSUME-NEXT: ret i32 0
|
|
|
|
;
|
|
|
|
%A1 = getelementptr {i32,i32}, {i32,i32}* %A, i64 0, i32 0
|
|
|
|
%REMOVEu = load i32, i32* %A1
|
|
|
|
%B = getelementptr {i32,i32}, {i32,i32}* %A, i64 %distance, i32 1
|
|
|
|
store i32 7, i32* %B ; B cannot alias A, it's at least 4 bytes away
|
|
|
|
%REMOVEv = load i32, i32* %A1
|
|
|
|
%r = sub i32 %REMOVEu, %REMOVEv
|
|
|
|
ret i32 %r
|
2003-02-26 05:43:37 +08:00
|
|
|
}
|
2003-02-27 05:39:52 +08:00
|
|
|
|
2020-04-14 17:55:56 +08:00
|
|
|
; Test that we can do funny pointer things and that distance calc will still
|
2003-02-27 06:01:58 +08:00
|
|
|
; work.
|
2008-02-14 14:56:27 +08:00
|
|
|
define i32 @gep_distance_test3(i32 * %A) {
|
2020-04-14 17:55:56 +08:00
|
|
|
; NO_ASSUME-LABEL: @gep_distance_test3(
|
|
|
|
; NO_ASSUME-NEXT: [[C1:%.*]] = getelementptr i32, i32* [[A:%.*]], i64 1
|
|
|
|
; NO_ASSUME-NEXT: [[C:%.*]] = bitcast i32* [[C1]] to i8*
|
|
|
|
; NO_ASSUME-NEXT: store i8 42, i8* [[C]], align 1
|
|
|
|
; NO_ASSUME-NEXT: ret i32 0
|
|
|
|
;
|
|
|
|
; USE_ASSUME-LABEL: @gep_distance_test3(
|
2020-05-11 00:20:34 +08:00
|
|
|
; USE_ASSUME-NEXT: [[C1:%.*]] = getelementptr i32, i32* [[A:%.*]], i64 1
|
2020-04-14 17:55:56 +08:00
|
|
|
; USE_ASSUME-NEXT: [[C:%.*]] = bitcast i32* [[C1]] to i8*
|
2020-10-27 17:49:41 +08:00
|
|
|
; USE_ASSUME-NEXT: store i8 42, i8* [[C]], align 4
|
Infer alignment of unmarked loads in IR/bitcode parsing.
For IR generated by a compiler, this is really simple: you just take the
datalayout from the beginning of the file, and apply it to all the IR
later in the file. For optimization testcases that don't care about the
datalayout, this is also really simple: we just use the default
datalayout.
The complexity here comes from the fact that some LLVM tools allow
overriding the datalayout: some tools have an explicit flag for this,
some tools will infer a datalayout based on the code generation target.
Supporting this properly required plumbing through a bunch of new
machinery: we want to allow overriding the datalayout after the
datalayout is parsed from the file, but before we use any information
from it. Therefore, IR/bitcode parsing now has a callback to allow tools
to compute the datalayout at the appropriate time.
Not sure if I covered all the LLVM tools that want to use the callback.
(clang? lli? Misc IR manipulation tools like llvm-link?). But this is at
least enough for all the LLVM regression tests, and IR without a
datalayout is not something frontends should generate.
This change had some sort of weird effects for certain CodeGen
regression tests: if the datalayout is overridden with a datalayout with
a different program or stack address space, we now parse IR based on the
overridden datalayout, instead of the one written in the file (or the
default one, if none is specified). This broke a few AVR tests, and one
AMDGPU test.
Outside the CodeGen tests I mentioned, the test changes are all just
fixing CHECK lines and moving around datalayout lines in weird places.
Differential Revision: https://reviews.llvm.org/D78403
2020-05-15 03:59:45 +08:00
|
|
|
; USE_ASSUME-NEXT: call void @llvm.assume(i1 true) [ "dereferenceable"(i32* [[A]], i64 4), "nonnull"(i32* [[A]]), "align"(i32* [[A]], i64 4) ]
|
2020-04-14 17:55:56 +08:00
|
|
|
; USE_ASSUME-NEXT: ret i32 0
|
|
|
|
;
|
|
|
|
%X = load i32, i32* %A
|
|
|
|
%B = bitcast i32* %A to i8*
|
|
|
|
%C = getelementptr i8, i8* %B, i64 4
|
|
|
|
store i8 42, i8* %C
|
|
|
|
%Y = load i32, i32* %A
|
|
|
|
%R = sub i32 %X, %Y
|
|
|
|
ret i32 %R
|
2003-02-27 05:39:52 +08:00
|
|
|
}
|
2003-06-17 23:16:35 +08:00
|
|
|
|
|
|
|
; Test that we can disambiguate globals reached through constantexpr geps
|
2008-02-14 14:56:27 +08:00
|
|
|
define i32 @constexpr_test() {
|
2020-06-19 16:32:09 +08:00
|
|
|
; CHECK-LABEL: @constexpr_test(
|
|
|
|
; CHECK-NEXT: [[X:%.*]] = alloca i32, align 4
|
|
|
|
; CHECK-NEXT: call void @external(i32* nonnull [[X]])
|
|
|
|
; CHECK-NEXT: store i32 5, i32* getelementptr inbounds ({ i32 }, { i32 }* @Global, i64 0, i32 0), align 4
|
|
|
|
; CHECK-NEXT: ret i32 0
|
2020-04-14 17:55:56 +08:00
|
|
|
;
|
|
|
|
%X = alloca i32
|
|
|
|
call void @external(i32* %X)
|
|
|
|
|
|
|
|
%Y = load i32, i32* %X
|
|
|
|
store i32 5, i32* getelementptr ({ i32 }, { i32 }* @Global, i64 0, i32 0)
|
|
|
|
%REMOVE = load i32, i32* %X
|
|
|
|
%retval = sub i32 %Y, %REMOVE
|
|
|
|
ret i32 %retval
|
2003-06-17 23:16:35 +08:00
|
|
|
}
|
2010-08-18 12:28:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; PR7589
|
|
|
|
; These two index expressions are different, this cannot be CSE'd.
|
|
|
|
define i16 @zext_sext_confusion(i16* %row2col, i5 %j) nounwind{
|
2020-04-14 17:55:56 +08:00
|
|
|
; CHECK-LABEL: @zext_sext_confusion(
|
|
|
|
; CHECK-NEXT: entry:
|
|
|
|
; CHECK-NEXT: [[SUM5_CAST:%.*]] = zext i5 [[J:%.*]] to i64
|
|
|
|
; CHECK-NEXT: [[P1:%.*]] = getelementptr i16, i16* [[ROW2COL:%.*]], i64 [[SUM5_CAST]]
|
|
|
|
; CHECK-NEXT: [[ROW2COL_LOAD_1_2:%.*]] = load i16, i16* [[P1]], align 1
|
|
|
|
; CHECK-NEXT: [[SUM13_CAST31:%.*]] = sext i5 [[J]] to i6
|
|
|
|
; CHECK-NEXT: [[SUM13_CAST:%.*]] = zext i6 [[SUM13_CAST31]] to i64
|
|
|
|
; CHECK-NEXT: [[P2:%.*]] = getelementptr i16, i16* [[ROW2COL]], i64 [[SUM13_CAST]]
|
|
|
|
; CHECK-NEXT: [[ROW2COL_LOAD_1_6:%.*]] = load i16, i16* [[P2]], align 1
|
|
|
|
; CHECK-NEXT: [[DOTRET:%.*]] = sub i16 [[ROW2COL_LOAD_1_6]], [[ROW2COL_LOAD_1_2]]
|
|
|
|
; CHECK-NEXT: ret i16 [[DOTRET]]
|
|
|
|
;
|
2010-08-18 12:28:19 +08:00
|
|
|
entry:
|
|
|
|
%sum5.cast = zext i5 %j to i64 ; <i64> [#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
|
|
|
%P1 = getelementptr i16, i16* %row2col, i64 %sum5.cast
|
2015-02-28 05:17:42 +08:00
|
|
|
%row2col.load.1.2 = load i16, i16* %P1, align 1 ; <i16> [#uses=1]
|
2020-04-14 17:55:56 +08:00
|
|
|
|
2010-08-18 12:28:19 +08:00
|
|
|
%sum13.cast31 = sext i5 %j to i6 ; <i6> [#uses=1]
|
|
|
|
%sum13.cast = zext i6 %sum13.cast31 to i64 ; <i64> [#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
|
|
|
%P2 = getelementptr i16, i16* %row2col, i64 %sum13.cast
|
2015-02-28 05:17:42 +08:00
|
|
|
%row2col.load.1.6 = load i16, i16* %P2, align 1 ; <i16> [#uses=1]
|
2020-04-14 17:55:56 +08:00
|
|
|
|
2010-08-18 12:28:19 +08:00
|
|
|
%.ret = sub i16 %row2col.load.1.6, %row2col.load.1.2 ; <i16> [#uses=1]
|
|
|
|
ret i16 %.ret
|
|
|
|
}
|