[llvm-commits] [llvm] r122014 - in /llvm/trunk: lib/Transforms/Scalar/SimplifyLibCalls.cpp test/Transforms/SimplifyLibCalls/2009-02-12-StrTo.ll
Dan Gohman
gohman at apple.com
Thu Dec 16 17:09:43 PST 2010
Author: djg
Date: Thu Dec 16 19:09:43 2010
New Revision: 122014
URL: http://llvm.org/viewvc/llvm-project?rev=122014&view=rev
Log:
Revert r64460. strtol and friends cannot be marked readonly, even with
a null endptr argument, because they may write to errno.
This fixes a seflhost miscompile observed on Linux targets when TBAA
was enabled.
Modified:
llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp
llvm/trunk/test/Transforms/SimplifyLibCalls/2009-02-12-StrTo.ll
Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=122014&r1=122013&r2=122014&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Thu Dec 16 19:09:43 2010
@@ -577,7 +577,8 @@
Value *EndPtr = CI->getArgOperand(1);
if (isa<ConstantPointerNull>(EndPtr)) {
- CI->setOnlyReadsMemory();
+ // With a null EndPtr, this function won't capture the main argument.
+ // It would be readonly too, except that it still may write to errno.
CI->addAttribute(1, Attribute::NoCapture);
}
Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/2009-02-12-StrTo.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/2009-02-12-StrTo.ll?rev=122014&r1=122013&r2=122014&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyLibCalls/2009-02-12-StrTo.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyLibCalls/2009-02-12-StrTo.ll Thu Dec 16 19:09:43 2010
@@ -1,7 +1,7 @@
; RUN: opt < %s -simplify-libcalls -S > %t
; RUN: grep nocapture %t | count 2
; RUN: grep null %t | grep nocapture | count 1
-; RUN: grep null %t | grep call | grep readonly | count 1
+; RUN: grep null %t | grep call | not grep readonly
; Test that we add nocapture to the declaration, and to the second call only.
More information about the llvm-commits
mailing list