diff options
author | Michael Kruse <llvm@meinersbur.de> | 2017-06-01 21:46:27 +0000 |
---|---|---|
committer | Michael Kruse <llvm@meinersbur.de> | 2017-06-01 21:46:27 +0000 |
commit | 678aa336fa8d0cfac176d3bd95ddb96f545bbe68 (patch) | |
tree | fd8837a3522899da163ebfcfdcc3edbec54d2bf4 | |
parent | a618acf92379b8eaed5526bf6aff262708b3e9fc (diff) | |
download | bcm5719-llvm-678aa336fa8d0cfac176d3bd95ddb96f545bbe68.tar.gz bcm5719-llvm-678aa336fa8d0cfac176d3bd95ddb96f545bbe68.zip |
[ScopBuilder] Exclude ignored intrinsics from explicit instruction list.
Ignored intrinsics are ignored at code generation, therefore do not
need to be part of the instruction list.
Specifically, llvm.lifetime.* intrinisics are removed before code
generation, referencing them would cause a use-after-free error.
Contributed-by: Nandini Singhal <cs15mtech01004@iith.ac.in>
Differential Revision: https://reviews.llvm.org/D33768
llvm-svn: 304483
-rw-r--r-- | polly/lib/Analysis/ScopBuilder.cpp | 3 | ||||
-rw-r--r-- | polly/test/ScopInfo/intrinsics.ll | 46 |
2 files changed, 48 insertions, 1 deletions
diff --git a/polly/lib/Analysis/ScopBuilder.cpp b/polly/lib/Analysis/ScopBuilder.cpp index b6d2ba2e40f..bf61d0770ae 100644 --- a/polly/lib/Analysis/ScopBuilder.cpp +++ b/polly/lib/Analysis/ScopBuilder.cpp @@ -642,7 +642,8 @@ void ScopBuilder::buildStmts(Region &SR) { std::vector<Instruction *> Instructions; for (Instruction &Inst : *I->getNodeAs<BasicBlock>()) { Loop *L = LI.getLoopFor(Inst.getParent()); - if (!isa<TerminatorInst>(&Inst) && !canSynthesize(&Inst, *scop, &SE, L)) + if (!isa<TerminatorInst>(&Inst) && !isIgnoredIntrinsic(&Inst) && + !canSynthesize(&Inst, *scop, &SE, L)) Instructions.push_back(&Inst); } Loop *SurroundingLoop = LI.getLoopFor(I->getNodeAs<BasicBlock>()); diff --git a/polly/test/ScopInfo/intrinsics.ll b/polly/test/ScopInfo/intrinsics.ll new file mode 100644 index 00000000000..dbd8285f8be --- /dev/null +++ b/polly/test/ScopInfo/intrinsics.ll @@ -0,0 +1,46 @@ +; RUN: opt %loadPolly -polly-scops -analyze -polly-print-instructions < %s | FileCheck %s +; +; Verify that we remove the ignored intrinsics from the instruction list. +; +; CHECK: Instructions { +; CHECK-NEXT: store i32 %i.0, i32* %arrayidx, align 4 +; CHECK-NEXT: } +; +; int A[1024]; +; void func() { +; for (int i = 0; i < 1024; i++) +; A[i] = i; +; } +; +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +define void @fun() #0 { +entry: + %A = alloca [1024 x i32], align 16 + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ] + %cmp = icmp slt i32 %i.0, 1024 + br i1 %cmp, label %for.body, label %for.end + +for.body: ; preds = %for.cond + %idxprom = sext i32 %i.0 to i64 + %arrayidx = getelementptr inbounds [1024 x i32], [1024 x i32]* %A, i64 0, i64 %idxprom + call void @llvm.donothing() + store i32 %i.0, i32* %arrayidx, align 4 + br label %for.inc + +for.inc: ; preds = %for.body + %inc = add nsw i32 %i.0, 1 + br label %for.cond + +for.end: ; preds = %for.cond + ret void +} + +; Function Attrs: nounwind readnone +declare void @llvm.donothing() #1 + +attributes #0 = { noinline nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } |