Files
swift-mirror/test/DebugInfo/simplify_builtin.sil
Aidan Hall 0ef2094279 [DebugInfo] Salvage more during SIL optimization passes
This reverts commit b1eb70bf45.

The original PR (#85244) was reverted (#85836) due to rdar://165667449

This version fixes the aforementioned issue, and (potentially) improves overall
debug info retention by salvaging info in erase(instructionIncludingDebugUses:),
rather than inserting many explicit salvageDebugInfo calls throughout the code
to make the test cases pass.

Bridging: Make salvageDebugInfo a method of MutatingContext

This feels more consistent than making it a method of Instruction.

DebugInfo: Salvage from trivially dead instructions

This handles the case we were checking in constantFoldBuiltin, so we do not need to salvage debug info there any more.
2026-01-06 12:01:20 +00:00

44 lines
1.8 KiB
Plaintext

// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -simplification -simplify-instruction=builtin -sil-print-debuginfo | %FileCheck %s
// REQUIRES: swift_in_compiler
import Swift
import Builtin
// This verifies that debug information attached to the arguments of builtin
// instructions is preserved when those instructions are constant-folded.
//
// CHECK-LABEL: sil @preserve_bitwise_operands : $@convention(thin) () -> Builtin.Int32 {
// CHECK: bb0:
// CHECK-NEXT: debug_value undef : $Builtin.Int32, let, name "x", expr op_constu:1
// CHECK-NEXT: debug_value undef : $Builtin.Int32, let, name "y", expr op_constu:2
// CHECK-NEXT: [[THREE:%[0-9]+]] = integer_literal $Builtin.Int32, 3
// CHECK-NEXT: return [[THREE]] : $Builtin.Int32
// CHECK-LABEL: } // end sil function 'preserve_bitwise_operands'
sil @preserve_bitwise_operands : $@convention(thin) () -> Builtin.Int32 {
bb0:
%0 = integer_literal $Builtin.Int32, 1
debug_value %0, let, name "x"
%1 = integer_literal $Builtin.Int32, 2
debug_value %1, let, name "y"
%2 = builtin "or_Int32"(%0, %1) : $Builtin.Int32
return %2
}
// CHECK-LABEL: sil @preserve_add_operands : $@convention(thin) () -> Builtin.Int32 {
// CHECK: bb0:
// CHECK-NEXT: debug_value undef : $Builtin.Int32, let, name "x", expr op_consts:4294967295
// CHECK-NEXT: debug_value undef : $Builtin.Int32, let, name "y", expr op_constu:2
// CHECK-NEXT: [[ONE:%[0-9]+]] = integer_literal $Builtin.Int32, 1
// CHECK-NEXT: return [[ONE]] : $Builtin.Int32
// CHECK-LABEL: } // end sil function 'preserve_add_operands'
sil @preserve_add_operands : $@convention(thin) () -> Builtin.Int32 {
bb0:
%0 = integer_literal $Builtin.Int32, -1
debug_value %0, let, name "x"
%1 = integer_literal $Builtin.Int32, 2
debug_value %1, let, name "y"
%2 = builtin "add_Int32"(%0, %1) : $Builtin.Int32
return %2
}