Skip to content

Add a peephole optimization for cc.has_argument() #140

@dcbaker

Description

@dcbaker

I'm marking this as a moderate issue because there currently isn't any sort of framework for doing peephole optimizations, everything is done one instruction at at time.

In particular, there are loops that look like this:

cc = meson.get_compiler('c')
foreach a : ['-Wno-foo', '-Wbar', '-Werror=thing']
  if cc.has_argument(a)
    add_project_arguments(a, language : 'c')
  endif
endforeach

This could be optimized to:

cc = meson.get_compiler('c')
add_project_arguments(cc.get_supported_arguments(['-Wno-foo', '-Wbar', '-Werror=thing']), language : 'c'))

A couple of questions to be answered here: do we do this before loop unrolling, after loop unrolling, or at the AST level. I see some advantages to all of these approaches.

If we're unrolling, then we're looking at a basic block that has a single node, add_*_arguments, which may be more difficult to see than at the AST level.

Metadata

Metadata

Assignees

No one assigned

    Labels

    MIRIssues related to the MIR (Mid level IR)difficulty:moderatefrontendSpecific the frontend and/or ASTperformanceIssues relating to performance

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions