[flang-commits] [flang] [llvm] [flang] Enhance show_descriptor intrinsic to avoid extra copies and extra descriptor creation (PR #173461)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Mon Dec 29 22:09:10 PST 2025


================
@@ -7893,9 +7893,24 @@ void IntrinsicLibrary::genShowDescriptor(
   assert(args.size() == 1 && "expected single argument for show_descriptor");
   const mlir::Value descriptor = fir::getBase(args[0]);
 
-  assert(fir::isa_box_type(descriptor.getType()) &&
-         "argument must have been lowered to box type");
-  fir::runtime::genShowDescriptor(builder, loc, descriptor);
+  // If it's already a reference to a box, pass it directly.
+  if (fir::isa_ref_type(descriptor.getType()) &&
----------------
eugeneepshteyn wrote:

I added this test and there was no extra copy.

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


More information about the flang-commits mailing list