summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
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/lib/Transforms/Utils/BuildLibCalls.cpp
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/lib/Transforms/Utils/BuildLibCalls.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/BuildLibCalls.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
index d4cf03c326d..24af7c463f4 100644
--- a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
@@ -105,12 +105,23 @@ static bool setRetNonNull(Function &F) {
return true;
}
+static bool setNonLazyBind(Function &F) {
+ if (F.hasFnAttribute(Attribute::NonLazyBind))
+ return false;
+ F.addFnAttr(Attribute::NonLazyBind);
+ return true;
+}
+
bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) {
LibFunc TheLibFunc;
if (!(TLI.getLibFunc(F, TheLibFunc) && TLI.has(TheLibFunc)))
return false;
bool Changed = false;
+
+ if (F.getParent() != nullptr && F.getParent()->getRtLibUseGOT())
+ Changed |= setNonLazyBind(F);
+
switch (TheLibFunc) {
case LibFunc_strlen:
case LibFunc_wcslen:
OpenPOWER on IntegriCloud