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

Constant combine the output of identical function calls #130

Open
dcbaker opened this issue Oct 16, 2024 · 0 comments
Open

Constant combine the output of identical function calls #130

dcbaker opened this issue Oct 16, 2024 · 0 comments
Labels
difficulty:moderate MIR Issues related to the MIR (Mid level IR) performance Issues relating to performance

Comments

@dcbaker
Copy link
Owner

dcbaker commented Oct 16, 2024

It happens often that we get identical calls to the same function, especially find_program. If we note that there are two calls to the same thing, we should make them references, consider this:

a = custom_target(
   command : ['myscript.py', '@INPUT@', '@OUTPUT@'],
   input : ['a.h.in'],
   output : '@BASENAME@,
)
b = custom_target(
  command : ['myscript.py', '--code', '@INPUT@', '@OUTPUT@'],
  input : ['a.c.in'],
  output : ['@BASENAME@'],
)

This could be rewritten as:

myscript = find_program('myscript.ph')
a = custom_target(
   command : [myscript, '@INPUT@', '@OUTPUT@'],
   input : ['a.h.in'],
   output : '@BASENAME@,
)
b = custom_target(
  command : [myscript, '--code', '@INPUT@', '@OUTPUT@'],
  input : ['a.c.in'],
  output : ['@BASENAME@'],
)

Which would simplify the threaded lookup process.

This is related to #42, but that has more to do with putting the IR into a shape easy to consume in the backends. This needs to run earlier, and probably only targets find_program, dependency, and compiler.find_library(), while that is really targeted at calls to build_targets

@dcbaker dcbaker added MIR Issues related to the MIR (Mid level IR) performance Issues relating to performance labels Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty:moderate MIR Issues related to the MIR (Mid level IR) performance Issues relating to performance
Projects
None yet
Development

No branches or pull requests

1 participant