How to understand what is "expected string" in Swift compiler test-case input?

Hi,

As part of my continued effort to port Swift on ppc64le, I am working on fixing error thrown by IRGen/errors.sil:

/root/latest/swift-source/swift/test/IRGen/errors.sil:66:17: error: expected string not found in input
// CHECK-NEXT: store %swift.error* null, %swift.error** [[ERRORSLOT]], align
^
:67:62: note: scanning from here
define protected swiftcc void @try_apply(%swift.refcounted*) #0 {
^
:67:62: note: uses undefined variable "ERRORSLOT"
define protected swiftcc void @try_apply(%swift.refcounted*) #0 {
^
:70:2: note: possible intended match here
store %swift.error* null, %swift.error** %swifterror, align 8
^
/root/latest/swift-source/swift/test/IRGen/errors.sil:117:11: error: expected string not found in input
// CHECK: define internal swiftcc void @_T027partial_apply_single_helperTA(%swift.refcounted* swiftself, %swift.error**{{( )?}}[[SWIFTERROR]])
^
:111:178: note: scanning from here
%2 = insertvalue { i8*, %swift.refcounted* } { i8* bitcast (void (%swift.refcounted*, %swift.error**)* @_T027partial_apply_single_helperTA to i8*), %swift.refcounted* undef }, %swift.refcounted* %1, 1
^
:111:178: note: uses undefined variable "SWIFTERROR"
%2 = insertvalue { i8*, %swift.refcounted* } { i8* bitcast (void (%swift.refcounted*, %swift.error**)* @_T027partial_apply_single_helperTA to i8*), %swift.refcounted* undef }, %swift.refcounted* %1, 1
^
:117:1: note: possible intended match here
define internal swiftcc void @_T027partial_apply_single_helperTA(%swift.refcounted* swiftself, %swift.error**) #0 {
^
The difficulty I am facing is: How do I figure out what is the expected string by this test case? On the very first line of this test file, there is a RUN command and I guess that is getting executed at the entry. Is there any way of echoing the command "as it gets executed", meaning with all parameter values? What would be the best approach to fix these types of errors?

Thanks,
Atul.

Somewhere in the output—I think right above the errors you saw—it’ll list the command it ran to perform the test. In the case of this file, that command will include a pipe to a program called FileCheck. Delete the pipe and everything after it and you’ll be able to see what FileCheck is looking at.

You’re right that the RUN: line is where this command comes from. The % tokens in that line are variables that get expanded by lit (the test runner). I believe those variables are defined in the test/lit.cfg file if you want to see what they are.

FileCheck takes the data from the pipe and matches it against strings specified in the comments of the original file. (Here, it’s the comments that start with “CHECK”.) The FileCheck documentation explains how the different kinds of CHECK lines work and how to understand the patterns in the strings.

Thanks @beccadax - that helped a lot! Also the FileCheck documentation is very useful.