diff options
author | Duncan Sands <baldrick@free.fr> | 2008-01-27 18:12:58 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2008-01-27 18:12:58 +0000 |
commit | d82375c1c43db7f823dd4660d3495e76566699e3 (patch) | |
tree | 9ec329e29706c0b886f14a16dec1e225e7decd53 /lib/Transforms/Utils/InlineFunction.cpp | |
parent | 3bd39d4ca89804e97c93b039f6c2933f514c165c (diff) |
Revert r46393: readonly/readnone functions are no
longer allowed to write through byval arguments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46416 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | lib/Transforms/Utils/InlineFunction.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index acd2b108ce..552583042a 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/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); |