summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorDavid Bolvansky <david.bolvansky@gmail.com>2018-10-13 15:21:55 +0000
committerDavid Bolvansky <david.bolvansky@gmail.com>2018-10-13 15:21:55 +0000
commite8b3bba71765b6d6dbd9e8ad8911327b47c05366 (patch)
tree82cc09465f39af0c4e28712bdd8825e4b8e8afa4 /llvm/test
parent1c2051ead7fa9eaee3f7e21b5e7cf4915a7232b3 (diff)
downloadbcm5719-llvm-e8b3bba71765b6d6dbd9e8ad8911327b47c05366.tar.gz
bcm5719-llvm-e8b3bba71765b6d6dbd9e8ad8911327b47c05366.zip
[InstCombine] Fixed crash with aliased functions
Summary: Fixes PR39177 Reviewers: spatel, jbuening Reviewed By: jbuening Subscribers: jbuening, llvm-commits Differential Revision: https://reviews.llvm.org/D53129 llvm-svn: 344454
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/InstCombine/pr39177.ll66
1 files changed, 66 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/pr39177.ll b/llvm/test/Transforms/InstCombine/pr39177.ll
new file mode 100644
index 00000000000..750e17a01f1
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/pr39177.ll
@@ -0,0 +1,66 @@
+; RUN: opt < %s -instcombine -S
+
+%struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct._IO_FILE*, i32, i32, i64, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i64, i32, [20 x i8] }
+%struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, i32 }
+
+@stderr = external global %struct._IO_FILE*, align 8
+@.str = private constant [8 x i8] c"crash!\0A\00", align 1
+
+@fwrite = alias i64 (i8*, i64, i64, %struct._IO_FILE*), i64 (i8*, i64, i64, %struct._IO_FILE*)* @__fwrite_alias
+
+define i64 @__fwrite_alias(i8* %ptr, i64 %size, i64 %n, %struct._IO_FILE* %s) {
+entry:
+ %ptr.addr = alloca i8*, align 8
+ %size.addr = alloca i64, align 8
+ %n.addr = alloca i64, align 8
+ %s.addr = alloca %struct._IO_FILE*, align 8
+ store i8* %ptr, i8** %ptr.addr, align 8
+ store i64 %size, i64* %size.addr, align 8
+ store i64 %n, i64* %n.addr, align 8
+ store %struct._IO_FILE* %s, %struct._IO_FILE** %s.addr, align 8
+ ret i64 0
+}
+
+define void @foo() {
+entry:
+ %retval = alloca i32, align 4
+ store i32 0, i32* %retval, align 4
+ %0 = load %struct._IO_FILE*, %struct._IO_FILE** @stderr, align 8
+ %call = call i32 (%struct._IO_FILE*, i8*, ...) @fprintf(%struct._IO_FILE* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0))
+ ret void
+}
+
+declare i32 @fprintf(%struct._IO_FILE*, i8*, ...)
+; RUN: opt < %s -instcombine -S
+
+%struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct._IO_FILE*, i32, i32, i64, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i64, i32, [20 x i8] }
+%struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, i32 }
+
+@stderr = external global %struct._IO_FILE*, align 8
+@.str = private constant [8 x i8] c"crash!\0A\00", align 1
+
+@fwrite = alias i64 (i8*, i64, i64, %struct._IO_FILE*), i64 (i8*, i64, i64, %struct._IO_FILE*)* @__fwrite_alias
+
+define i64 @__fwrite_alias(i8* %ptr, i64 %size, i64 %n, %struct._IO_FILE* %s) {
+entry:
+ %ptr.addr = alloca i8*, align 8
+ %size.addr = alloca i64, align 8
+ %n.addr = alloca i64, align 8
+ %s.addr = alloca %struct._IO_FILE*, align 8
+ store i8* %ptr, i8** %ptr.addr, align 8
+ store i64 %size, i64* %size.addr, align 8
+ store i64 %n, i64* %n.addr, align 8
+ store %struct._IO_FILE* %s, %struct._IO_FILE** %s.addr, align 8
+ ret i64 0
+}
+
+define void @foo() {
+entry:
+ %retval = alloca i32, align 4
+ store i32 0, i32* %retval, align 4
+ %0 = load %struct._IO_FILE*, %struct._IO_FILE** @stderr, align 8
+ %call = call i32 (%struct._IO_FILE*, i8*, ...) @fprintf(%struct._IO_FILE* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0))
+ ret void
+}
+
+declare i32 @fprintf(%struct._IO_FILE*, i8*, ...)
OpenPOWER on IntegriCloud