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

Attributor and FunctionAttrs ignore callsite attributes when inferring norecurse #125013

Open
arsenm opened this issue Jan 30, 2025 · 1 comment
Labels
ipo Interprocedural optimizations missed-optimization

Comments

@arsenm
Copy link
Contributor

arsenm commented Jan 30, 2025

In this example, test_fake_interrupt_callsite does not get inferred as norecurse. The function is identical to test_fake_interrupt_declaration, except the norecurse information comes from the callsite and not the declaration.

; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=attributor -attributor-manifest-internal -o - %s
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=function-attrs -o - %s

; Callsite attributes are ignored when inferring

define internal void @test_interrupt() {
  call void @llvm.amdgcn.s.sendmsg(i32 1, i32 0)
  ret void
}

; This infers mustprogress norecurse willreturn
define internal void @test_fake_interrupt_declaration() {
  call void @fake_sendmsg_declared(i32 1, i32 0)
  ret void
}

; This infers mustprogress willreturn, it missed norecurse
define internal void @test_fake_interrupt_callsite() {
  call void @fake_sendmsg_callsite(i32 1, i32 0) #1
  ret void
}

define internal void @reference() {
  ret void
}

define void @user() {
  call void @reference()
  call void @test_interrupt()
  call void @test_fake_interrupt_declaration()
  call void @test_fake_interrupt_callsite()
  ret void
}

declare void @llvm.amdgcn.s.sendmsg(i32 immarg, i32) #0
declare void @fake_sendmsg_declared(i32, i32) #1

declare void @fake_sendmsg_callsite(i32, i32)

attributes #0 = { nounwind }
attributes #1 = { nocallback willreturn }
@arsenm arsenm added ipo Interprocedural optimizations missed-optimization labels Jan 30, 2025
@arsenm
Copy link
Contributor Author

arsenm commented Jan 30, 2025

Even with norecurse on the declaration, the attributor fails to infer norecurse on the caller. Works for functionattrs though (see test in #125016)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ipo Interprocedural optimizations missed-optimization
Projects
None yet
Development

No branches or pull requests

1 participant