Skip to content

Commit b6eb6a8

Browse files
committed
[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.
1 parent 2d760a1 commit b6eb6a8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

llvm/lib/Transforms/IPO/FunctionAttrs.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -683,17 +683,17 @@ ArgumentAccessInfo getArgmentAccessInfo(const Instruction *I,
683683
}
684684
}
685685
} else if (auto *CB = dyn_cast<CallBase>(I)) {
686-
if (CB->isArgOperand(ArgUse.U)) {
686+
if (CB->isArgOperand(ArgUse.U) &&
687+
!CB->isByValArgument(CB->getArgOperandNo(ArgUse.U))) {
687688
unsigned ArgNo = CB->getArgOperandNo(ArgUse.U);
688689
bool IsInitialize = CB->paramHasAttr(ArgNo, Attribute::Initializes);
689-
// Argument is a Write when parameter is writeonly/readnone
690-
// and nocapture. Otherwise, it's a WriteWithSideEffect.
691-
auto Access = CB->onlyWritesMemory(ArgNo) &&
692-
CB->paramHasAttr(ArgNo, Attribute::NoCapture)
693-
? ArgumentAccessInfo::AccessType::Write
694-
: ArgumentAccessInfo::AccessType::WriteWithSideEffect;
695-
ConstantRangeList AccessRanges;
696690
if (IsInitialize && ArgUse.Offset) {
691+
// Argument is a Write when parameter is writeonly/readnone
692+
// and nocapture. Otherwise, it's a WriteWithSideEffect.
693+
auto Access = CB->onlyWritesMemory(ArgNo) && CB->doesNotCapture(ArgNo)
694+
? ArgumentAccessInfo::AccessType::Write
695+
: ArgumentAccessInfo::AccessType::WriteWithSideEffect;
696+
ConstantRangeList AccessRanges;
697697
Attribute Attr = CB->getParamAttr(ArgNo, Attribute::Initializes);
698698
ConstantRangeList CBCRL = Attr.getValueAsConstantRangeList();
699699
for (ConstantRange &CR : CBCRL)

0 commit comments

Comments
 (0)