aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-08-19 22:46:59 +0000
committerDan Gohman <gohman@apple.com>2009-08-19 22:46:59 +0000
commite457538ed815e5a52322618d1f114e2ae579da74 (patch)
tree9301c2cd7a3c0c64422b60f3c583de62f30c29ba /test
parentfabae3e1bc766e20e8607383a245bba4f3057a3e (diff)
downloadexternal_llvm-e457538ed815e5a52322618d1f114e2ae579da74.zip
external_llvm-e457538ed815e5a52322618d1f114e2ae579da74.tar.gz
external_llvm-e457538ed815e5a52322618d1f114e2ae579da74.tar.bz2
Fix a bug in the over-index constant folding. When over-indexing an
array member of a struct, it's possible to land in an arbitrary position inside that struct, such that attempting to find further getelementptr indices will fail. In such cases, folding cannot be done. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79485 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/InstCombine/constant-fold-gep-overindex.ll17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/constant-fold-gep-overindex.ll b/test/Transforms/InstCombine/constant-fold-gep-overindex.ll
new file mode 100644
index 0000000..15bdab4
--- /dev/null
+++ b/test/Transforms/InstCombine/constant-fold-gep-overindex.ll
@@ -0,0 +1,17 @@
+; RUN: llvm-as < %s | opt -instcombine
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
+target triple = "i386-apple-darwin10.0"
+
+%0 = type { i8*, [19 x i8] }
+%1 = type { i8*, [0 x i8] }
+
+@s = external global %0 ; <%0*> [#uses=1]
+@"\01LC8" = external constant [17 x i8] ; <[17 x i8]*> [#uses=1]
+
+define i32 @main() nounwind {
+entry:
+ %0 = call i32 (i8*, ...)* @printf(i8* getelementptr ([17 x i8]* @"\01LC8", i32 0, i32 0), i8* undef, i8* getelementptr (%1* bitcast (%0* @s to %1*), i32 0, i32 1, i32 0)) nounwind ; <i32> [#uses=0]
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...) nounwind