summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/GlobalOpt
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2016-03-02 20:02:25 +0000
committerBob Wilson <bob.wilson@apple.com>2016-03-02 20:02:25 +0000
commit9ab86aabbafe424de527bb5ddd07d2cdbd71c9cf (patch)
tree9f7ab410ec9d384010c9f77b6f619535921003ed /llvm/test/Transforms/GlobalOpt
parent721f61a00ec3cdb3ebb5b0dbe61ca8d2b047b4e0 (diff)
downloadbcm5719-llvm-9ab86aabbafe424de527bb5ddd07d2cdbd71c9cf.tar.gz
bcm5719-llvm-9ab86aabbafe424de527bb5ddd07d2cdbd71c9cf.zip
Add another test for the GlobalOpt change in r212079.
This is a test that Akira Hatanaka wrote to test GlobalOpt's handling of aliases with GEP operands. David Majnemer independently made the same change to GlobalOpt in r212079. Akira's test is a useful addition, so I'm pulling it over from the llvm repo for Swift on GitHub. llvm-svn: 262510
Diffstat (limited to 'llvm/test/Transforms/GlobalOpt')
-rw-r--r--llvm/test/Transforms/GlobalOpt/alias-used.ll19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/test/Transforms/GlobalOpt/alias-used.ll b/llvm/test/Transforms/GlobalOpt/alias-used.ll
index 9ced3974ee8..02136a06447 100644
--- a/llvm/test/Transforms/GlobalOpt/alias-used.ll
+++ b/llvm/test/Transforms/GlobalOpt/alias-used.ll
@@ -45,3 +45,22 @@ define i8* @g2() {
define i8* @h() {
ret i8* @ca
}
+
+; Check that GlobalOpt doesn't try to resolve aliases with GEP operands.
+
+%struct.S = type { i32, i32, i32 }
+@s = global %struct.S { i32 1, i32 2, i32 3 }, align 4
+
+@alias1 = alias i32, i32* getelementptr inbounds (%struct.S, %struct.S* @s, i64 0, i32 1)
+@alias2 = alias i32, i32* getelementptr inbounds (%struct.S, %struct.S* @s, i64 0, i32 2)
+
+; CHECK: load i32, i32* @alias1, align 4
+; CHECK: load i32, i32* @alias2, align 4
+
+define i32 @foo1() {
+entry:
+ %0 = load i32, i32* @alias1, align 4
+ %1 = load i32, i32* @alias2, align 4
+ %add = add nsw i32 %1, %0
+ ret i32 %add
+}
OpenPOWER on IntegriCloud