Skip to content

Commit b970e95

Browse files
committed
[Test] Allow insts to be taken as values.
1 parent f3e061f commit b970e95

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

include/swift/SILOptimizer/Utils/ParseTestSpecification.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define SWIFT_SIL_PARSETESTSPECIFICATION
1919

2020
#include "swift/Basic/TaggedUnion.h"
21+
#include "swift/SIL/SILInstruction.h"
2122
#include "swift/SIL/SILValue.h"
2223
#include "llvm/ADT/StringRef.h"
2324

@@ -140,7 +141,13 @@ struct Arguments {
140141
return cast<UIntArgument>(takeArgument()).getValue();
141142
}
142143
SILValue takeValue() {
143-
return cast<ValueArgument>(takeArgument()).getValue();
144+
auto argument = takeArgument();
145+
if (isa<InstructionArgument>(argument)) {
146+
auto *instruction = cast<InstructionArgument>(argument).getValue();
147+
auto *svi = cast<SingleValueInstruction>(instruction);
148+
return svi;
149+
}
150+
return cast<ValueArgument>(argument).getValue();
144151
}
145152
Operand *takeOperand() {
146153
return cast<OperandArgument>(takeArgument()).getValue();

test/SILOptimizer/unit_test.sil

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ import Builtin
5454
// CHECK: value: {{%[^,]+}} = tuple ({{%[^,]+}} : $(), {{%[^,]+}} : $(_: ()), {{%[^,]+}} : $((), (_: ())))
5555
// CHECK: string: howdy
5656
// CHECK-LABEL: end running test 7 of {{[^,]+}} on test_arg_parsing: test-specification-parsing
57+
// CHECK-LABEL: begin running test 8 of {{[^,]+}} on test_arg_parsing: test-specification-parsing
58+
// CHECK: value:
59+
// CHECK: function_ref @something_remarkable
60+
// CHECK-LABEL: end running test 8 of {{[^,]+}} on test_arg_parsing: test-specification-parsing
5761
sil [ossa] @test_arg_parsing : $() -> () {
5862
entry:
5963
test_specification "test-specification-parsing FFFbb @function[test_arg_parsing_reference] @function[2] @function true false"
@@ -63,6 +67,7 @@ entry:
6367
test_specification "test-specification-parsing IIIIIIII @function.block.instruction @function[0].block.instruction @function.block[0].instruction @function.block.instruction[0] @function[0].block[0].instruction @function[0].block.instruction[0] @function.block[0].instruction[0] @function[0].block[0].instruction[0]"
6468
test_specification "test-specification-parsing OO @instruction[2].operand @function[test_arg_parsing_callee].trace.operand[1]"
6569
test_specification "test-specification-parsing Vs @function[4].trace[0] howdy"
70+
test_specification "test-specification-parsing V @instruction[0]"
6671
%something_remarkable = function_ref @something_remarkable : $@convention(thin) () -> ()
6772
%retval = tuple ()
6873
return %retval : $()

0 commit comments

Comments
 (0)