Files
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
compiler-rt
libcxx
libcxxabi
libunwind
lld
lldb
llvm
bindings
cmake
docs
examples
include
lib
projects
resources
runtimes
scripts
test
Analysis
AliasSet
AssumptionCache
BasicAA
BlockFrequencyInfo
BranchProbabilityInfo
CFLAliasAnalysis
CallGraph
ConstantFolding
CostModel
Delinearization
DemandedBits
DependenceAnalysis
DivergenceAnalysis
DominanceFrontier
Dominators
GlobalsModRef
IVUsers
LazyCallGraph
LazyValueAnalysis
Lint
LoopAccessAnalysis
backward-dep-different-types.ll
forward-loop-carried.ll
forward-loop-independent.ll
independent-interleaved.ll
interleave-innermost.ll
memcheck-for-loop-invariant.ll
memcheck-off-by-one-error.ll
memcheck-wrapping-pointers.ll
multiple-strides-rt-memory-checks.ll
non-wrapping-pointer.ll
nullptr.ll
number-of-memchecks.ll
pointer-with-unknown-bounds.ll
pr31098.ll
resort-to-memchecks-only.ll
reverse-memcheck-bounds.ll
safe-no-checks.ll
safe-with-dep-distance.ll
store-to-invariant-check1.ll
store-to-invariant-check2.ll
store-to-invariant-check3.ll
stride-access-dependence.ll
underlying-objects-1.ll
underlying-objects-2.ll
unsafe-and-rt-checks.ll
wrapping-pointer-versioning.ll
LoopInfo
MemoryDependenceAnalysis
MemorySSA
PostDominators
ProfileSummary
RegionInfo
ScalarEvolution
ScopedNoAliasAA
TypeBasedAliasAnalysis
ValueTracking
alias-analysis-uses.ll
Assembler
Bindings
Bitcode
BugPoint
CodeGen
DebugInfo
Examples
ExecutionEngine
Feature
FileCheck
Instrumentation
Integer
JitListener
LTO
Linker
MC
Object
ObjectYAML
Other
SafepointIRVerifier
SymbolRewriter
TableGen
ThinLTO
Transforms
Unit
Verifier
YAMLParser
tools
.clang-format
CMakeLists.txt
TestRunner.sh
lit.cfg.py
lit.site.cfg.py.in
tools
unittests
utils
.arcconfig
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
LLVMBuild.txt
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in
openmp
polly
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mk
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
linux-packaging-mono/external/llvm-project/llvm/test/Analysis/LoopAccessAnalysis/underlying-objects-2.ll

92 lines
2.7 KiB
LLVM
Raw Normal View History

; RUN: opt -basicaa -loop-accesses -analyze < %s | FileCheck %s
; RUN: opt -passes='require<scalar-evolution>,require<aa>,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s
; This loop:
;
; int **A;
; for (i)
; for (j) {
; A[i][j] = A[i-1][j] * B[j]
; B[j+1] = 2 // backward dep between this and the previous
; }
;
; is transformed by Load-PRE to stash away A[i] for the next iteration of the
; outer loop:
;
; Curr = A[0]; // Prev_0
; for (i: 1..N) {
; Prev = Curr; // Prev = PHI (Prev_0, Curr)
; Curr = A[i];
; for (j: 0..N) {
; Curr[j] = Prev[j] * B[j]
; B[j+1] = 2 // backward dep between this and the previous
; }
; }
;
; Since A[i] and A[i-1] are likely to be independent, getUnderlyingObjects
; should not assume that Curr and Prev share the same underlying object.
;
; If it did we would try to dependence-analyze Curr and Prev and the analysis
; would fail with non-constant distance.
;
; To illustrate one of the negative consequences of this, if the loop has a
; backward dependence we won't detect this but instead fully fall back on
; memchecks (that is what LAA does after encountering a case of non-constant
; distance).
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.10.0"
; CHECK: for_j.body:
; CHECK-NEXT: Report: unsafe dependent memory operations in loop
; CHECK-NEXT: Dependences:
; CHECK-NEXT: Backward:
; CHECK-NEXT: %loadB = load i8, i8* %gepB, align 1 ->
; CHECK-NEXT: store i8 2, i8* %gepB_plus_one, align 1
define void @f(i8** noalias %A, i8* noalias %B, i64 %N) {
for_i.preheader:
%prev_0 = load i8*, i8** %A, align 8
br label %for_i.body
for_i.body:
%i = phi i64 [1, %for_i.preheader], [%i.1, %for_j.end]
%prev = phi i8* [%prev_0, %for_i.preheader], [%curr, %for_j.end]
%gep = getelementptr inbounds i8*, i8** %A, i64 %i
%curr = load i8*, i8** %gep, align 8
br label %for_j.preheader
for_j.preheader:
br label %for_j.body
for_j.body:
%j = phi i64 [0, %for_j.preheader], [%j.1, %for_j.body]
%gepPrev = getelementptr inbounds i8, i8* %prev, i64 %j
%gepCurr = getelementptr inbounds i8, i8* %curr, i64 %j
%gepB = getelementptr inbounds i8, i8* %B, i64 %j
%loadPrev = load i8, i8* %gepPrev, align 1
%loadB = load i8, i8* %gepB, align 1
%mul = mul i8 %loadPrev, %loadB
store i8 %mul, i8* %gepCurr, align 1
%gepB_plus_one = getelementptr inbounds i8, i8* %gepB, i64 1
store i8 2, i8* %gepB_plus_one, align 1
%j.1 = add nuw i64 %j, 1
%exitcondj = icmp eq i64 %j.1, %N
br i1 %exitcondj, label %for_j.end, label %for_j.body
for_j.end:
%i.1 = add nuw i64 %i, 1
%exitcond = icmp eq i64 %i.1, %N
br i1 %exitcond, label %for_i.end, label %for_i.body
for_i.end:
ret void
}