2012-07-02 18:37:59 +00:00
|
|
|
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
|
2014-01-02 03:31:36 +00:00
|
|
|
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
|
|
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
|
2009-10-13 22:02:20 +00:00
|
|
|
; rdar://7282591
|
|
|
|
|
2009-10-14 01:45:10 +00:00
|
|
|
@X = common global i32 0
|
|
|
|
@Y = common global i32 0
|
|
|
|
@Z = common global i32 0
|
2009-10-13 22:02:20 +00:00
|
|
|
|
2014-01-02 03:31:36 +00:00
|
|
|
; CHECK-LABEL: foo
|
2012-04-24 09:15:38 +00:00
|
|
|
; CHECK: NoAlias: i32* %P, i32* @Z
|
|
|
|
|
2010-11-11 21:08:46 +00:00
|
|
|
define void @foo(i32 %cond) nounwind {
|
2009-10-13 22:02:20 +00:00
|
|
|
entry:
|
2009-10-14 01:45:10 +00:00
|
|
|
%"alloca point" = bitcast i32 0 to i32
|
|
|
|
%tmp = icmp ne i32 %cond, 0
|
|
|
|
br i1 %tmp, label %bb, label %bb1
|
2009-10-13 22:02:20 +00:00
|
|
|
|
2009-10-14 01:45:10 +00:00
|
|
|
bb:
|
|
|
|
br label %bb2
|
2009-10-13 22:02:20 +00:00
|
|
|
|
2009-10-14 01:45:10 +00:00
|
|
|
bb1:
|
|
|
|
br label %bb2
|
2009-10-13 22:02:20 +00:00
|
|
|
|
2009-10-14 01:45:10 +00:00
|
|
|
bb2:
|
|
|
|
%P = phi i32* [ @X, %bb ], [ @Y, %bb1 ]
|
2015-02-27 21:17:42 +00:00
|
|
|
%tmp1 = load i32, i32* @Z, align 4
|
2009-10-14 01:45:10 +00:00
|
|
|
store i32 123, i32* %P, align 4
|
2015-02-27 21:17:42 +00:00
|
|
|
%tmp2 = load i32, i32* @Z, align 4
|
2009-10-14 01:45:10 +00:00
|
|
|
br label %return
|
2009-10-13 22:02:20 +00:00
|
|
|
|
2009-10-14 01:45:10 +00:00
|
|
|
return:
|
2009-10-13 22:02:20 +00:00
|
|
|
ret void
|
|
|
|
}
|
2014-01-02 03:31:36 +00:00
|
|
|
|
|
|
|
; Pointers can vary in between iterations of loops.
|
|
|
|
; PR18068
|
|
|
|
|
|
|
|
; CHECK-LABEL: pr18068
|
|
|
|
; CHECK: MayAlias: i32* %0, i32* %arrayidx5
|
Revert r219432 - "Revert "[BasicAA] Revert "Revert r218714 - Make better use of zext and sign information."""
Let's try this again...
This reverts r219432, plus a bug fix.
Description of the bug in r219432 (by Nick):
The bug was using AllPositive to break out of the loop; if the loop break
condition i != e is changed to i != e && AllPositive then the
test_modulo_analysis_with_global test I've added will fail as the Modulo will
be calculated incorrectly (as the last loop iteration is skipped, so Modulo
isn't updated with its Scale).
Nick also adds this comment:
ComputeSignBit is safe to use in loops as it takes into account phi nodes, and
the == EK_ZeroEx check is safe in loops as, no matter how the variable changes
between iterations, zero-extensions will always guarantee a zero sign bit. The
isValueEqualInPotentialCycles check is therefore definitely not needed as all
the variable analysis holds no matter how the variables change between loop
iterations.
And this patch also adds another enhancement to GetLinearExpression - basically
to convert ConstantInts to Offsets (see test_const_eval and
test_const_eval_scaled for the situations this improves).
Original commit message:
This reverts r218944, which reverted r218714, plus a bug fix.
Description of the bug in r218714 (by Nick):
The original patch forgot to check if the Scale in VariableGEPIndex flipped the
sign of the variable. The BasicAA pass iterates over the instructions in the
order they appear in the function, and so BasicAliasAnalysis::aliasGEP is
called with the variable it first comes across as parameter GEP1. Adding a
%reorder label puts the definition of %a after %b so aliasGEP is called with %b
as the first parameter and %a as the second. aliasGEP later calculates that %a
== %b + 1 - %idxprom where %idxprom >= 0 (if %a was passed as the first
parameter it would calculate %b == %a - 1 + %idxprom where %idxprom >= 0) -
ignoring that %idxprom is scaled by -1 here lead the patch to incorrectly
conclude that %a > %b.
Revised patch by Nick White, thanks! Thanks to Lang to isolating the bug.
Slightly modified by me to add an early exit from the loop and avoid
unnecessary, but expensive, function calls.
Original commit message:
Two related things:
1. Fixes a bug when calculating the offset in GetLinearExpression. The code
previously used zext to extend the offset, so negative offsets were converted
to large positive ones.
2. Enhance aliasGEP to deduce that, if the difference between two GEP
allocations is positive and all the variables that govern the offset are also
positive (i.e. the offset is strictly after the higher base pointer), then
locations that fit in the gap between the two base pointers are NoAlias.
Patch by Nick White!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221876 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 09:16:54 +00:00
|
|
|
; CHECK: NoAlias: i32* %arrayidx13, i32* %arrayidx5
|
2014-01-02 03:31:36 +00:00
|
|
|
|
|
|
|
define i32 @pr18068(i32* %jj7, i32* %j) {
|
|
|
|
entry:
|
|
|
|
%oa5 = alloca [100 x i32], align 16
|
|
|
|
br label %codeRepl
|
|
|
|
|
|
|
|
codeRepl:
|
|
|
|
%0 = phi i32* [ %arrayidx13, %for.body ], [ %j, %entry ]
|
|
|
|
%targetBlock = call i1 @cond(i32* %jj7)
|
|
|
|
br i1 %targetBlock, label %for.body, label %bye
|
|
|
|
|
|
|
|
for.body:
|
2015-02-27 21:17:42 +00:00
|
|
|
%1 = load i32, i32* %jj7, align 4
|
2014-01-02 03:31:36 +00:00
|
|
|
%idxprom4 = zext i32 %1 to i64
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%arrayidx5 = getelementptr inbounds [100 x i32], [100 x i32]* %oa5, i64 0, i64 %idxprom4
|
2015-02-27 21:17:42 +00:00
|
|
|
%2 = load i32, i32* %arrayidx5, align 4
|
2014-01-02 03:31:36 +00:00
|
|
|
%sub6 = sub i32 %2, 6
|
|
|
|
store i32 %sub6, i32* %arrayidx5, align 4
|
|
|
|
; %0 and %arrayidx5 can alias! It is not safe to DSE the above store.
|
2015-02-27 21:17:42 +00:00
|
|
|
%3 = load i32, i32* %0, align 4
|
2014-01-02 03:31:36 +00:00
|
|
|
store i32 %3, i32* %arrayidx5, align 4
|
|
|
|
%sub11 = add i32 %1, -1
|
|
|
|
%idxprom12 = zext i32 %sub11 to i64
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%arrayidx13 = getelementptr inbounds [100 x i32], [100 x i32]* %oa5, i64 0, i64 %idxprom12
|
2014-01-02 03:31:36 +00:00
|
|
|
call void @inc(i32* %jj7)
|
|
|
|
br label %codeRepl
|
|
|
|
|
|
|
|
bye:
|
2015-02-27 21:17:42 +00:00
|
|
|
%.reload = load i32, i32* %jj7, align 4
|
2014-01-02 03:31:36 +00:00
|
|
|
ret i32 %.reload
|
|
|
|
}
|
|
|
|
|
|
|
|
declare i1 @cond(i32*)
|
|
|
|
|
|
|
|
declare void @inc(i32*)
|
|
|
|
|
|
|
|
|