summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorSriraman Tallam <tmsriram@google.com>2018-04-10 23:32:36 +0000
committerSriraman Tallam <tmsriram@google.com>2018-04-10 23:32:36 +0000
commit182f2df7c5f691ef0f65adf6643411714fe33138 (patch)
treeb651d79295d0ceaf623695e4f39656cd692e928f /llvm/test
parenteb820c3aaca964ca016c539d5d918e17bc8b04ad (diff)
downloadbcm5719-llvm-182f2df7c5f691ef0f65adf6643411714fe33138.tar.gz
bcm5719-llvm-182f2df7c5f691ef0f65adf6643411714fe33138.zip
Simplification of libcall like printf->puts must check for RtLibUseGOT metadata.
With -fno-plt, for example, calls to printf when getting converted to puts still use the PLT. This patch checks for the metadata "RtLibUseGOT" and annotates the declaration with the right attributes. Differential Revision: https://reviews.llvm.org/D45180 llvm-svn: 329768
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/X86/no-plt-libcalls.ll19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/no-plt-libcalls.ll b/llvm/test/CodeGen/X86/no-plt-libcalls.ll
new file mode 100644
index 00000000000..795ad57f9a5
--- /dev/null
+++ b/llvm/test/CodeGen/X86/no-plt-libcalls.ll
@@ -0,0 +1,19 @@
+; Check if "RtLibUseGOT" works correctly when lib calls are simplified.
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+@percent_s = constant [4 x i8] c"%s\0A\00"
+@hello_world = constant [13 x i8] c"hello world\0A\00"
+declare i32 @printf(i8*, ...)
+define void @printf_call() {
+ %fmt = getelementptr [4 x i8], [4 x i8]* @percent_s, i32 0, i32 0
+ %str = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0
+ call i32 (i8*, ...) @printf(i8* %fmt, i8* %str)
+; CHECK: call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @hello_world, i64 0, i64 0))
+ ret void
+}
+
+; CHECK: Function Attrs: nounwind nonlazybind
+; CHECK-NEXT: declare i32 @puts(i8* nocapture readonly)
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 7, !"RtLibUseGOT", i32 1}
OpenPOWER on IntegriCloud