Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/19.x: [Inliner] Don't propagate access attr to byval params (#112256) #112365

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/InlineFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ static void AddParamAndFnBasicAttributes(const CallBase &CB,
if (!Arg)
continue;

if (AL.hasParamAttr(I, Attribute::ByVal))
if (NewInnerCB->paramHasAttr(I, Attribute::ByVal))
// It's unsound to propagate memory attributes to byval arguments.
// Even if CalledFunction doesn't e.g. write to the argument,
// the call to NewInnerCB may write to its by-value copy.
Expand Down
20 changes: 20 additions & 0 deletions llvm/test/Transforms/Inline/access-attributes-prop.ll
Original file line number Diff line number Diff line change
Expand Up @@ -580,3 +580,23 @@ define ptr @callee_bad_param_prop(ptr readonly %x) {
%r = tail call ptr @llvm.ptrmask(ptr %x, i64 -1)
ret ptr %r
}

define dso_local void @foo_byval_readonly2(ptr readonly %p) {
; CHECK-LABEL: define {{[^@]+}}@foo_byval_readonly2
; CHECK-SAME: (ptr readonly [[P:%.*]]) {
; CHECK-NEXT: call void @bar4(ptr [[P]])
; CHECK-NEXT: ret void
;
call void @bar4(ptr %p)
ret void
}

define void @prop_byval_readonly2(ptr %p) {
; CHECK-LABEL: define {{[^@]+}}@prop_byval_readonly2
; CHECK-SAME: (ptr [[P:%.*]]) {
; CHECK-NEXT: call void @bar4(ptr [[P]])
; CHECK-NEXT: ret void
;
call void @foo_byval_readonly2(ptr %p)
ret void
}
Loading