summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Transforms/IPO/FunctionAttrs.cpp10
-rw-r--r--llvm/test/Transforms/FunctionAttrs/annotate-1.ll3
2 files changed, 13 insertions, 0 deletions
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;
diff --git a/llvm/test/Transforms/FunctionAttrs/annotate-1.ll b/llvm/test/Transforms/FunctionAttrs/annotate-1.ll
index ae77380acc4..d8e90cf1c38 100644
--- a/llvm/test/Transforms/FunctionAttrs/annotate-1.ll
+++ b/llvm/test/Transforms/FunctionAttrs/annotate-1.ll
@@ -14,5 +14,8 @@ declare i32* @realloc(i32*, i32)
declare i32 @strcpy(...)
; CHECK: declare i32 @strcpy(...)
+declare i32 @gettimeofday(i8*, i8*)
+; CHECK: declare i32 @gettimeofday(i8* nocapture, i8* nocapture) [[G0]]
+
; CHECK: attributes [[G0]] = { nounwind }
; CHECK: attributes [[G1]] = { nounwind readonly }
OpenPOWER on IntegriCloud