[clang] [CIR] Unreacheable blocks should be target lowered (PR #224609)

Steffen Larsen via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 18 05:19:25 PDT 2026


================
@@ -320,7 +321,11 @@ void TargetLoweringPass::runOnOperation() {
   mlir::ConversionTarget target(*mod.getContext());
   populateTargetLoweringConversionTarget(target, typeConverter);
 
-  if (failed(mlir::applyPartialConversion(mod, target, std::move(patterns))))
+  llvm::SmallVector<mlir::Operation *> ops;
+  ops.push_back(mod);
+  cir::collectUnreachable(mod, ops);
----------------
steffenlarsen wrote:

Unrelated to your changes, but I wonder whether `collectUnreachable` should do more of an effort to reserve space it the passed vector. I.e. https://github.com/llvm/llvm-project/blob/main/clang/lib/CIR/Dialect/Transforms/CIRTransformUtils.cpp#L42 could reserve based on the size of `blk` (or use insertion). We can't do a full pre-reservation without doing two passes over, but at least that would avoid repeat allocations in the loop.

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


More information about the cfe-commits mailing list