Files
swift-mirror/test/SILOptimizer/global_init_opt.swift
Erik Eckstein 7cceaff5f3 SIL: don't print operand types in textual SIL
Type annotations for instruction operands are omitted, e.g.

```
  %3 = struct $S(%1, %2)
```

Operand types are redundant anyway and were only used for sanity checking in the SIL parser.

But: operand types _are_ printed if the definition of the operand value was not printed yet.
This happens:

* if the block with the definition appears after the block where the operand's instruction is located

* if a block or instruction is printed in isolation, e.g. in a debugger

The old behavior can be restored with `-Xllvm -sil-print-types`.
This option is added to many existing test files which check for operand types in their check-lines.
2024-11-21 18:49:52 +01:00

39 lines
1.0 KiB
Swift

// RUN: %target-swift-frontend -parse-as-library -O -import-objc-header %S/Inputs/bitfield.h -module-name=test %s -Xllvm -sil-print-types -emit-sil | %FileCheck %s
// REQUIRES: swift_in_compiler
var gg: Int = {
print("gg init")
return 27
}()
// Test that the compiler doesn't crash with a global C bitfield.
var bitfield = S(a: 0, b: 0)
// CHECK-LABEL: sil @$s4test3cseSiyF
// CHECK: builtin "once"
// CHECK-NOT: builtin "once"
// CHECK: [[G:%[0-9]+]] = load
// CHECK-NOT: builtin "once"
// CHECK: builtin "sadd_{{.*}}"([[G]] : $Builtin.Int{{[0-9]+}}, [[G]] : $Builtin.Int{{[0-9]+}}, %{{[0-9]+}} : $Builtin.Int1)
// CHECK-NOT: builtin "once"
// CHECK: } // end sil function '$s4test3cseSiyF'
public func cse() -> Int {
return gg + gg
}
// CHECK-LABEL: sil @$s4test4licmSiyF
// CHECK: bb0:
// CHECK: builtin "once"
// CHECK: bb1{{.*}}:
// CHECK-NOT: builtin "once"
// CHECK: } // end sil function '$s4test4licmSiyF'
public func licm() -> Int {
var s = 0
for _ in 0..<100 {
s += gg
}
return s
}