llvm / clangir

A new (MLIR based) high-level IR for clang.
https://clangir.org
Other
383 stars 100 forks source link

[CIR] Introduce a flattening pass #516

Closed gitoleg closed 7 months ago

gitoleg commented 7 months ago

We start our journey towards goto support and this is a first step on this way.

There are some discussion in #508 and according to the plan we do the following here: 1) a new pass called StructuredCFG that is a stub now but later will be responsible for the regions inlining. The pass works only if emit-cir is not passed in cmd line. Thus, the clang behavior is not changed here from the user's point of view. 2) The pass will be accomplished with goto solver later, so we talk about several passes that are mandatory for the lowering into llvm dialect. There are at least two clients of this pass that will be affected: clang itself and cir-opt, so we need a common point for them: and populateCIRFlatteningPasses and populateCIRToLLVMPasses guarantee that CIR will be in the correct state for all the clients, whatever new passes we will add later. 3) new option -emit-flat-cir to dump CIR after all the flattening and structuring and goto-solving.

github-actions[bot] commented 7 months ago

:white_check_mark: With the latest revision this PR passed the C/C++ code formatter.

gitoleg commented 7 months ago

@bcardosolopes done!