From 9d2a5b1cf7f0f233e90650adcf1e1079b14a3cda Mon Sep 17 00:00:00 2001 From: Xin Tong Date: Sun, 18 Jun 2017 03:10:26 +0000 Subject: Add argmononly attribute to strlen and wcslen, i.e. they only read memory (string) passed to them. Summary: This allows strlen to be moved out of the loop in case its argument is not modified in the loop in LICM. Reviewers: hfinkel, davide, sanjoy, dberlin Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34323 llvm-svn: 305641 --- llvm/lib/Transforms/Utils/BuildLibCalls.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'llvm/lib/Transforms/Utils') diff --git a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp index ebde1f9a17d..b60dfb4f354 100644 --- a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp @@ -116,6 +116,7 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) { case LibFunc_wcslen: Changed |= setOnlyReadsMemory(F); Changed |= setDoesNotThrow(F); + Changed |= setOnlyAccessesArgMemory(F); Changed |= setDoesNotCapture(F, 0); return Changed; case LibFunc_strchr: -- cgit v1.2.3