From 2db11161a8b3e53e4bfdacc6f969cad1abaf1747 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Wed, 3 Jul 2013 04:00:54 +0000 Subject: Added support in FunctionAttrs for adding relevant function/argument attributes for the posix call gettimeofday. This implies annotating it as nounwind and its arguments as nocapture. To be conservative, we do not annotate the arguments with noalias since some platforms do not have restrict on the declaration for gettimeofday. llvm-svn: 185502 --- llvm/lib/Transforms/IPO/FunctionAttrs.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'llvm/lib/Transforms/IPO/FunctionAttrs.cpp') diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp index 79ce3c33057..7df556ebffa 100644 --- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp @@ -1310,6 +1310,16 @@ bool FunctionAttrs::inferPrototypeAttributes(Function &F) { // May throw; "open" is a valid pthread cancellation point. setDoesNotCapture(F, 1); break; + case LibFunc::gettimeofday: + if (FTy->getNumParams() != 2 || !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) + return false; + // Currently some platforms have the restrict keyword on the arguments to + // gettimeofday. To be conservative, do not add noalias to gettimeofday's + // arguments. + setDoesNotThrow(F); + setDoesNotCapture(F, 1); + setDoesNotCapture(F, 2); default: // Didn't mark any attributes. return false; -- cgit v1.2.3