[llvm] [LLVM][TableGen] Change DAGISel code to use const RecordKeeper (PR #109038)

Tomas Matheson via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 18 02:23:02 PDT 2024


================
@@ -132,7 +132,8 @@ struct PatternSortingPredicate {
 } // End anonymous namespace
 
 void DAGISelEmitter::run(raw_ostream &OS) {
-  Records.startTimer("Parse patterns");
+  RecordKeeper &MutableRC = const_cast<RecordKeeper &>(Records);
----------------
tmatheson-arm wrote:

I can see that you are making it `const` in the class and then removing it with `const_cast` so that `startTimer()` works. However I think `const_cast` is hacky and should be avoided unless necessary, and here it's only introduced because of the change you are making.
- Can the timing functionality be separated from `RecordKeeper`?
- Can `startTimer` be made `const` and somehow hide the `const_cast` inside `RecordKeeper`?
- What do we actually gain by making `RecordKeeper &Records` `const`?

https://github.com/llvm/llvm-project/pull/109038


More information about the llvm-commits mailing list