diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-07-19 07:02:10 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-07-19 07:02:10 +0000 |
commit | 93c91e39b29142dec1d03a30df9f6e757f56c193 (patch) | |
tree | 33a9b014a327e64450b3c9ed46d8c5bdb78ad345 /test/Other | |
parent | ca089b24d48ef6fa8da2d0bb8c25bb802c4a95c0 (diff) | |
download | src-93c91e39b29142dec1d03a30df9f6e757f56c193.tar.gz src-93c91e39b29142dec1d03a30df9f6e757f56c193.zip |
Vendor import of llvm trunk r308421:vendor/llvm/llvm-trunk-r308421
Notes
Notes:
svn path=/vendor/llvm/dist/; revision=321184
svn path=/vendor/llvm/llvm-trunk-r308421/; revision=321185; tag=vendor/llvm/llvm-trunk-r308421
Diffstat (limited to 'test/Other')
-rw-r--r-- | test/Other/cgscc-libcall-update.ll | 61 | ||||
-rw-r--r-- | test/Other/new-pass-manager.ll | 2 |
2 files changed, 63 insertions, 0 deletions
diff --git a/test/Other/cgscc-libcall-update.ll b/test/Other/cgscc-libcall-update.ll new file mode 100644 index 000000000000..e0833ca09266 --- /dev/null +++ b/test/Other/cgscc-libcall-update.ll @@ -0,0 +1,61 @@ +; Make sure that the CGSCC pass manager can handle when instcombine simplifies +; one libcall into an unrelated libcall and update the call graph accordingly. +; +; Also check that it can handle inlining *removing* a libcall entirely. +; +; RUN: opt -passes='cgscc(inline,function(instcombine))' -S < %s | FileCheck %s + +define i8* @wibble(i8* %arg1, i8* %arg2) { +; CHECK-LABEL: define i8* @wibble( +bb: + %tmp = alloca [1024 x i8], align 16 + %tmp2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %tmp, i64 0, i64 0 + call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp2, i8* %arg1, i64 1024, i32 0, i1 false) +; CHECK: call void @llvm.memcpy + %tmp3 = call i64 @llvm.objectsize.i64.p0i8(i8* %tmp2, i1 false, i1 true) + %tmp4 = call i8* @__strncpy_chk(i8* %arg2, i8* %tmp2, i64 1023, i64 %tmp3) +; CHECK-NOT: call +; CHECK: call i8* @strncpy(i8* %arg2, i8* %tmp2, i64 1023) +; CHECK-NOT: call + + ret i8* %tmp4 +; CHECK: ret +} + +define i8* @strncpy(i8* %arg1, i8* %arg2, i64 %size) noinline { +bb: + %result = call i8* @my_special_strncpy(i8* %arg1, i8* %arg2, i64 %size) + ret i8* %result +} + +declare i8* @my_special_strncpy(i8* %arg1, i8* %arg2, i64 %size) + +declare i64 @llvm.objectsize.i64.p0i8(i8*, i1, i1) + +declare i8* @__strncpy_chk(i8*, i8*, i64, i64) + +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) + +; Check that even when we completely remove a libcall we don't get the call +; graph wrong once we handle libcalls in the call graph specially to address +; the above case. +define i32 @hoge(i32* %arg1) { +; CHECK-LABEL: define i32 @hoge( +bb: + %tmp41 = load i32*, i32** null + %tmp6 = load i32, i32* %arg1 + %tmp7 = call i32 @ntohl(i32 %tmp6) +; CHECK-NOT: call i32 @ntohl + ret i32 %tmp7 +; CHECK: ret i32 +} + +; Even though this function is not used, it should be retained as it may be +; used when doing further libcall transformations. +define internal i32 @ntohl(i32 %x) { +; CHECK-LABEL: define internal i32 @ntohl( +entry: + %and2 = lshr i32 %x, 8 + %shr = and i32 %and2, 65280 + ret i32 %shr +} diff --git a/test/Other/new-pass-manager.ll b/test/Other/new-pass-manager.ll index bf8e596d118b..35f596e77988 100644 --- a/test/Other/new-pass-manager.ll +++ b/test/Other/new-pass-manager.ll @@ -23,6 +23,7 @@ ; CHECK-CGSCC-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*(CGSCCAnalysisManager|AnalysisManager<.*LazyCallGraph::SCC.*>).*}},{{.*}}Module> ; CHECK-CGSCC-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*(FunctionAnalysisManager|AnalysisManager<.*Function.*>).*}},{{.*}}Module> ; CHECK-CGSCC-PASS-NEXT: Running analysis: LazyCallGraphAnalysis +; CHECK-CGSCC-PASS-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-CGSCC-PASS-NEXT: Running an SCC pass across the RefSCC: [(foo)] ; CHECK-CGSCC-PASS-NEXT: Starting CGSCC pass manager run ; CHECK-CGSCC-PASS-NEXT: Running pass: NoOpCGSCCPass @@ -407,6 +408,7 @@ ; CHECK-REPEAT-CGSCC-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*(CGSCCAnalysisManager|AnalysisManager<.*LazyCallGraph::SCC.*>).*}},{{.*}}Module> ; CHECK-REPEAT-CGSCC-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*(FunctionAnalysisManager|AnalysisManager<.*Function.*>).*}},{{.*}}Module> ; CHECK-REPEAT-CGSCC-PASS-NEXT: Running analysis: LazyCallGraphAnalysis +; CHECK-REPEAT-CGSCC-PASS-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-REPEAT-CGSCC-PASS-NEXT: Running an SCC pass across the RefSCC: [(foo)] ; CHECK-REPEAT-CGSCC-PASS-NEXT: Starting CGSCC pass manager run ; CHECK-REPEAT-CGSCC-PASS-NEXT: Running pass: RepeatedPass |