diff options
author | Xin Tong <trent.xin.tong@gmail.com> | 2017-05-20 22:40:25 +0000 |
---|---|---|
committer | Xin Tong <trent.xin.tong@gmail.com> | 2017-05-20 22:40:25 +0000 |
commit | 75af3af95780e1c379409bf56c516a272c4fa961 (patch) | |
tree | df81d93ee10bd76a5be14744ff2ef967f0ddfeb8 /llvm/lib/Transforms/Utils/BuildLibCalls.cpp | |
parent | 36af8f4d42a0d4c5191450f5b729749b56bcc0e7 (diff) | |
download | bcm5719-llvm-75af3af95780e1c379409bf56c516a272c4fa961.tar.gz bcm5719-llvm-75af3af95780e1c379409bf56c516a272c4fa961.zip |
Add pthread_self function prototype and make it speculatable.
Summary: This allows pthread_self to be pulled out of a loop by LICM.
Reviewers: hfinkel, arsenm, davide
Reviewed By: davide
Subscribers: davide, wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D32782
llvm-svn: 303495
Diffstat (limited to 'llvm/lib/Transforms/Utils/BuildLibCalls.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/BuildLibCalls.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp index ebde1f9a17d..cf345325254 100644 --- a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp @@ -38,6 +38,7 @@ STATISTIC(NumNoCapture, "Number of arguments inferred as nocapture"); STATISTIC(NumReadOnlyArg, "Number of arguments inferred as readonly"); STATISTIC(NumNoAlias, "Number of function returns inferred as noalias"); STATISTIC(NumNonNull, "Number of function returns inferred as nonnull returns"); +STATISTIC(NumSpeculatable, "Number of functions inferred as speculatable"); static bool setDoesNotAccessMemory(Function &F) { if (F.doesNotAccessMemory()) @@ -71,6 +72,14 @@ static bool setDoesNotThrow(Function &F) { return true; } +static bool setSpeculatable(Function &F) { + if (F.isSpeculatable()) + return false; + F.setSpeculatable(); + ++NumSpeculatable; + return true; +} + static bool setRetDoesNotAlias(Function &F) { if (F.hasAttribute(AttributeList::ReturnIndex, Attribute::NoAlias)) return false; @@ -530,6 +539,9 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) { Changed |= setOnlyReadsMemory(F, 0); Changed |= setOnlyReadsMemory(F, 1); return Changed; + case LibFunc_pthread_self: + Changed |= setSpeculatable(F); + return Changed; case LibFunc_vfscanf: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 0); |