diff options
author | Nikita Popov <npopov@redhat.com> | 2025-01-14 15:18:57 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2025-01-14 15:36:01 +0100 |
commit | b6eb6a87cf04d8e8e8e323e4d77a38e92a6afc3e (patch) | |
tree | 06337a88495359aa0846a16322fdcbb233532c2e /llvm/lib/Transforms/IPO/FunctionAttrs.cpp | |
parent | 2d760a139ef11b31c58fa270878585961cb67cb7 (diff) | |
download | llvm-b6eb6a87cf04d8e8e8e323e4d77a38e92a6afc3e.zip llvm-b6eb6a87cf04d8e8e8e323e4d77a38e92a6afc3e.tar.gz llvm-b6eb6a87cf04d8e8e8e323e4d77a38e92a6afc3e.tar.bz2 |
[FunctionAttrs] Use doesNotCapture()
To be conservative, explicitly exclude byval arguments, which
doesNotCapture() would otherwise allow. Even if byval has an
initializes attribute, it would only apply to the implicit
copy.
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionAttrs.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionAttrs.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp index 06b5d79..03cb14c 100644 --- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp @@ -683,17 +683,17 @@ ArgumentAccessInfo getArgmentAccessInfo(const Instruction *I, } } } else if (auto *CB = dyn_cast<CallBase>(I)) { - if (CB->isArgOperand(ArgUse.U)) { + if (CB->isArgOperand(ArgUse.U) && + !CB->isByValArgument(CB->getArgOperandNo(ArgUse.U))) { unsigned ArgNo = CB->getArgOperandNo(ArgUse.U); bool IsInitialize = CB->paramHasAttr(ArgNo, Attribute::Initializes); - // Argument is a Write when parameter is writeonly/readnone - // and nocapture. Otherwise, it's a WriteWithSideEffect. - auto Access = CB->onlyWritesMemory(ArgNo) && - CB->paramHasAttr(ArgNo, Attribute::NoCapture) - ? ArgumentAccessInfo::AccessType::Write - : ArgumentAccessInfo::AccessType::WriteWithSideEffect; - ConstantRangeList AccessRanges; if (IsInitialize && ArgUse.Offset) { + // Argument is a Write when parameter is writeonly/readnone + // and nocapture. Otherwise, it's a WriteWithSideEffect. + auto Access = CB->onlyWritesMemory(ArgNo) && CB->doesNotCapture(ArgNo) + ? ArgumentAccessInfo::AccessType::Write + : ArgumentAccessInfo::AccessType::WriteWithSideEffect; + ConstantRangeList AccessRanges; Attribute Attr = CB->getParamAttr(ArgNo, Attribute::Initializes); ConstantRangeList CBCRL = Attr.getValueAsConstantRangeList(); for (ConstantRange &CR : CBCRL) |