summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-01-27 18:12:58 +0000
committerDuncan Sands <baldrick@free.fr>2008-01-27 18:12:58 +0000
commit053c9871cdcb716edbcf223ba1f438da0df2d8a8 (patch)
tree0bd5e72445cd069407b98f9c763df5123fb39581 /llvm
parent888560d62cce384f0fe90f00f93b4c44851666db (diff)
downloadbcm5719-llvm-053c9871cdcb716edbcf223ba1f438da0df2d8a8.tar.gz
bcm5719-llvm-053c9871cdcb716edbcf223ba1f438da0df2d8a8.zip
Revert r46393: readonly/readnone functions are no
longer allowed to write through byval arguments. llvm-svn: 46416
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp15
-rw-r--r--llvm/test/Transforms/Inline/byval2.ll6
2 files changed, 9 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index acd2b108cea..552583042a7 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -240,15 +240,12 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
E = CalledFunc->arg_end(); I != E; ++I, ++AI, ++ArgNo) {
Value *ActualArg = *AI;
- // When byval arguments are inlined, we need to make the copy implied
- // by them explicit. It is tempting to think that this is not needed if
- // the callee is readonly, because the callee doesn't modify the struct.
- // However this would be wrong: readonly means that any writes the callee
- // performs are not visible to the caller. But writes by the callee to
- // an argument passed byval are by definition not visible to the caller!
- // Since we allow this kind of readonly function, there needs to be an
- // explicit copy in order to keep the writes invisible after inlining.
- if (CalledFunc->paramHasAttr(ArgNo+1, ParamAttr::ByVal)) {
+ // When byval arguments actually inlined, we need to make the copy implied
+ // by them explicit. However, we don't do this if the callee is readonly
+ // or readnone, because the copy would be unneeded: the callee doesn't
+ // modify the struct.
+ if (CalledFunc->paramHasAttr(ArgNo+1, ParamAttr::ByVal) &&
+ !CalledFunc->onlyReadsMemory()) {
const Type *AggTy = cast<PointerType>(I->getType())->getElementType();
const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);
diff --git a/llvm/test/Transforms/Inline/byval2.ll b/llvm/test/Transforms/Inline/byval2.ll
index ab8c45d3767..e949d01856d 100644
--- a/llvm/test/Transforms/Inline/byval2.ll
+++ b/llvm/test/Transforms/Inline/byval2.ll
@@ -1,7 +1,7 @@
-; RUN: llvm-as < %s | opt -inline | llvm-dis | grep {llvm.memcpy}
+; RUN: llvm-as < %s | opt -inline | llvm-dis | not grep {llvm.memcpy}
-; Inlining a byval struct should cause an explicit copy
-; into an alloca even if the function is readonly
+; Inlining a byval struct should NOT cause an explicit copy
+; into an alloca if the function is readonly
%struct.ss = type { i32, i64 }
@.str = internal constant [10 x i8] c"%d, %lld\0A\00" ; <[10 x i8]*> [#uses=1]
OpenPOWER on IntegriCloud