diff options
| author | Duncan Sands <baldrick@free.fr> | 2008-01-26 06:41:49 +0000 |
|---|---|---|
| committer | Duncan Sands <baldrick@free.fr> | 2008-01-26 06:41:49 +0000 |
| commit | c4dc3dc3a2b00c138484ce941914a77b429ae48a (patch) | |
| tree | a9f24e6251f6c3164658d42f26a25e750cfb69b1 /llvm/lib/Transforms/Utils | |
| parent | 8a88c3815a95f1f9de79efc4378f2e0f0b3fd900 (diff) | |
| download | bcm5719-llvm-c4dc3dc3a2b00c138484ce941914a77b429ae48a.tar.gz bcm5719-llvm-c4dc3dc3a2b00c138484ce941914a77b429ae48a.zip | |
Create an explicit copy for byval parameters even
when inlining a readonly function.
llvm-svn: 46393
Diffstat (limited to 'llvm/lib/Transforms/Utils')
| -rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 552583042a7..acd2b108cea 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -240,12 +240,15 @@ 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 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()) { + // 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)) { const Type *AggTy = cast<PointerType>(I->getType())->getElementType(); const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty); |

