aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2012-03-16 16:36:47 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2012-03-16 16:36:47 +0000
commit3ec2abc5fb2e42241ec454bc24c80b9e34767b05 (patch)
tree423b1bdd411649da5fbfae490c50eb6314273c33
parent8e5af375dbfa3e3f073a7e402fd02a65f11c928a (diff)
downloadllvm-3ec2abc5fb2e42241ec454bc24c80b9e34767b05.zip
llvm-3ec2abc5fb2e42241ec454bc24c80b9e34767b05.tar.gz
llvm-3ec2abc5fb2e42241ec454bc24c80b9e34767b05.tar.bz2
Don't allow pointer types in affine expressions
We currently do not support pointer types in affine expressions. Hence, we disallow in the SCoP detection. Later we may decide to add support for them. This fixes PR12277 Reported-By: Sebastian Pop <sebpop@gmail.com> llvm-svn: 152928
-rw-r--r--polly/lib/Support/SCEVValidator.cpp10
-rw-r--r--polly/test/CodeGen/20120316-InvalidCast.ll20
2 files changed, 30 insertions, 0 deletions
diff --git a/polly/lib/Support/SCEVValidator.cpp b/polly/lib/Support/SCEVValidator.cpp
index eb26424..a70cf1a 100644
--- a/polly/lib/Support/SCEVValidator.cpp
+++ b/polly/lib/Support/SCEVValidator.cpp
@@ -279,6 +279,16 @@ public:
ValidatorResult visitUnknown(const SCEVUnknown *Expr) {
Value *V = Expr->getValue();
+ // We currently only support integer types. It may be useful to support
+ // pointer types, e.g. to support code like:
+ //
+ // if (A)
+ // A[i] = 1;
+ //
+ // See test/CodeGen/20120316-InvalidCast.ll
+ if (!Expr->getType()->isIntegerTy())
+ return ValidatorResult(SCEVType::INVALID);
+
if (isa<UndefValue>(V))
return ValidatorResult(SCEVType::INVALID);
diff --git a/polly/test/CodeGen/20120316-InvalidCast.ll b/polly/test/CodeGen/20120316-InvalidCast.ll
new file mode 100644
index 0000000..9628877
--- /dev/null
+++ b/polly/test/CodeGen/20120316-InvalidCast.ll
@@ -0,0 +1,20 @@
+; RUN: opt %loadPolly %defaultOpts -polly-codegen %s
+
+target datalayout = "e-p:32:32:32-i64:64:64-i32:32:32-i16:16:16-i1:32:32f64:64:64-f32:32:32-a0:0-n32"
+target triple = "hexagon-unknown-linux-gnu"
+
+define void @fixup_gotos(i32* %A, i32* %data) nounwind {
+entry:
+ br label %if
+
+if:
+ %cond = icmp eq i32* %A, null
+ br i1 %cond, label %last, label %then
+
+then:
+ store i32 1, i32* %data, align 4
+ br label %last
+
+last:
+ ret void
+}