Reimplement destroy as an interface (#5678)

This changes `Destroy` to use an interface for its implementation.

Note that this change includes a lot of test updates. Even when
`Destroy` is a no-op, it still causes code generation as part of
determining that.

Originally I was trying to use ranges to cut down the scope of this, and
to a degree I think they have. But a flipside here is that cases where
no destructors should be generated -- particularly globals -- would be
needed to completely remove destructor calls. Even for ranges, the range
can often include the destructor placement. So I've shifted
frame-of-thought a little: accept a bunch of destructor churn, because
destructors are needed and will be prevalent. The verbosity is a feature
of the design to make desugaring apparent in IR, not a bug.
This commit is contained in:
Jon Ross-Perkins
2025-06-27 21:57:14 +00:00
committed by GitHub
parent bba037738d
commit 0722dab0ef
171 changed files with 11900 additions and 1434 deletions
@@ -60,6 +60,10 @@ fn M() {
// CHECK:STDOUT: %F.call.loc30 = call ptr @_CF.Main.e8193710fd35b608(ptr %.loc30_5, i32 0), !dbg !16
// CHECK:STDOUT: %.loc31_5 = load ptr, ptr %ptr_f64.var, align 8, !dbg !17
// CHECK:STDOUT: %F.call.loc31 = call ptr @_CF.Main.e8193710fd35b608(ptr %.loc31_5, i32 0), !dbg !18
// CHECK:STDOUT: %.loc26_3 = load ptr, ptr %ptr_f64.var, align 8, !dbg !10
// CHECK:STDOUT: %.loc25_3 = load ptr, ptr %ptr_i32.var, align 8, !dbg !9
// CHECK:STDOUT: %.loc24_3 = load double, ptr %m.var, align 8, !dbg !8
// CHECK:STDOUT: %.loc23_3.2 = load i32, ptr %n.var, align 4, !dbg !7
// CHECK:STDOUT: ret void, !dbg !19
// CHECK:STDOUT: }
// CHECK:STDOUT: