llvm / clangir

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

Encode C/C++ constness in CIR #866

Open Lancern opened 2 months ago

Lancern commented 2 months ago

This was originally posted in the Discord channel by OfekShilon. The original message:

Hi! I hope this is an appropriate place to ask/suggest:

Are there plans to have CIR encode C/C++ constness? LLVM-IR doesn't, and quite a few optimizations are inhibited as a result.

I'm aware of one old (2015) attempt to tackle it in LLVM-IR: https://docs.google.com/document/d/112O-Q_XrbrU1I4P-oiLCN9u86Qg_BYBdcDsmh7Pn9Nw/edit#heading=h.trjqebywdvx4 which never made it upstream.

This might be a great opportunity to demonstrate concrete added value of cir over llvm-ir.

bcardosolopes commented 2 months ago

Thanks for tracking this. It'd be cool to have, in the meantime, this is also doable by looking at AST attached to the operations