Skip to content

Commit a5afe54

Browse files
committed
Incorporate review feedback
1 parent e3b363d commit a5afe54

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

clang/docs/ClangIRCodeDuplication.rst

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ problem.
6464
We have discussed various ways that major classes such as CGCXXABI/CIRGenCXXABI
6565
could be refactored to allow parts of there implementation to be shared today
6666
through inheritence and templated base classes. However, this may prove to be
67-
wasted effort when the permanent solution is developed, so we have decided that
68-
it is better to accept significant amounts of code duplication now, and defer
67+
wasted effort when the permanent solution is developed. Also, deferring this
68+
kind of intertwined implementation prevents introducing cross-dependencies that
69+
would make it more difficult to remove one IR code generation implementation
70+
without degrading the quality of the other. Therefore, we have decided that it
71+
is better to accept significant amounts of code duplication now, and defer
6972
this type of refactoring until it is clear what the permanent solution will be.
7073

7174
Mitigation Through Testing
@@ -93,7 +96,8 @@ implementation when these tests fail.
9396
As the CIR implementation gets closer to the goal of IR that is semantically
9497
equivalent to the LLVM IR produced by the classic codegen, we would like to
9598
enhance the CIR tests to perform some automatic verification of the equivalence
96-
of the generated LLVM IR, perhaps using a tool such as Alive2.
99+
of the generated LLVM IR, perhaps using a combination of tools such as `opt
100+
-pass-normalize` and Alive2.
97101

98102
Eventually, we would like to be able to run all existing classic codegen tests
99103
using the CIR path as well.
@@ -113,8 +117,9 @@ and immediate benefit to doing so.
113117

114118
Over time, we expect to progressively raise the CIR representation to a higher
115119
level and remove low level details, including ABI-specific handling from the
116-
dialect. However, having a working implementation in place makes it easier to
117-
verify that the high level representation and subsequent lowering are correct.
120+
dialect. (See the "Long Term Vision" section below for more details.) Having
121+
a working implementation in place makes it easier to verify that the
122+
high-level representation and subsequent lowering are correct.
118123

119124
Mixing With Other Dialects
120125
==========================
@@ -137,8 +142,9 @@ Other Consumers of CIR and MLIR
137142

138143
We must also consider that we will not always be lowering CIR to LLVM IR. CIR,
139144
usually mixed with other dialects, will also be directed to offload targets
140-
and other code generators through interfaces that are opaque to Clang. We must
141-
still produce semantically correct CIR for these consumers.
145+
and other code generators through interfaces that are opaque to Clang, such as
146+
SPIR-V and MLIR core dialects. We must still produce semantically correct CIR
147+
for these consumers.
142148

143149
Long Term Vision
144150
================
@@ -147,7 +153,10 @@ As the CIR implementation matures, we will eliminate target-specific handling
147153
from the high-level CIR generated by Clang. The high-level CIR will then be
148154
progressively lowered to a form that is closer to LLVM IR, including a pass
149155
that inserts ABI-specific handling, potentially representing the target-specific
150-
details in another dialect.
156+
details in another dialect. More complex transformations, such as library-aware
157+
idiom recognition or advanced loop representations—may occur later in the
158+
compilation pipeline through additional passes, which can be controlled by
159+
specific compiler flags.
151160

152161
As we raise CIR to this higher level implementation, there will naturally be
153162
less code duplication, and less need to have the same logic repeated in the

0 commit comments

Comments
 (0)