[PATCH] D123319: Change how we handle auto return types for lambda operator() to be consistent with gcc

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 25 18:50:52 PDT 2022


shafik added inline comments.


================
Comment at: clang/test/CodeGenCXX/no_auto_return_lambda.cpp:1
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
+
----------------
erichkeane wrote:
> erichkeane wrote:
> > So this CodeGen test without a triple is a bit troublesome.  The one we've noticed that this fails on the 32 bit windows build:
> > 
> > ```
> > FAIL: Clang :: CodeGenCXX/no_auto_return_lambda.cpp (41841 of 57667)
> > ******************** TEST 'Clang :: CodeGenCXX/no_auto_return_lambda.cpp' FAILED ********************
> > Script:
> > --
> > : 'RUN: at line 1';   d:\netbatch\build_comp02320_00\ics_top\builds\xmainoclx86win_prod\llvm\bin\clang.exe -cc1 -internal-isystem d:\netbatch\build_comp02320_00\ics_top\builds\xmainoclx86win_prod\llvm\lib\clang\15.0.0\include -nostdsysteminc -emit-llvm -debug-info-kind=limited D:\netbatch\build_comp02320_00\ics_top\llvm\clang\test\CodeGenCXX\no_auto_return_lambda.cpp -o - | d:\netbatch\build_comp02320_00\ics_top\builds\xmainoclx86win_prod\llvm\bin\filecheck.exe D:\netbatch\build_comp02320_00\ics_top\llvm\clang\test\CodeGenCXX\no_auto_return_lambda.cpp
> > --
> > Exit Code: 1Command Output (stdout):
> > --
> > $ ":" "RUN: at line 1"
> > $ "d:\netbatch\build_comp02320_00\ics_top\builds\xmainoclx86win_prod\llvm\bin\clang.exe" "-cc1" "-internal-isystem" "d:\netbatch\build_comp02320_00\ics_top\builds\xmainoclx86win_prod\llvm\lib\clang\15.0.0\include" "-nostdsysteminc" "-emit-llvm" "-debug-info-kind=limited" "D:\netbatch\build_comp02320_00\ics_top\llvm\clang\test\CodeGenCXX\no_auto_return_lambda.cpp" "-o" "-"
> > $ "d:\netbatch\build_comp02320_00\ics_top\builds\xmainoclx86win_prod\llvm\bin\filecheck.exe" "D:\netbatch\build_comp02320_00\ics_top\llvm\clang\test\CodeGenCXX\no_auto_return_lambda.cpp"
> > # command stderr:
> > D:\netbatch\build_comp02320_00\ics_top\llvm\clang\test\CodeGenCXX\no_auto_return_lambda.cpp:24:11: error: CHECK: expected string not found in input
> > // CHECK: ![[FUN_TYPE_LAMBDA]] = !DISubroutineType(types: ![[TYPE_NODE_LAMBDA:[0-9]+]])
> >           ^
> > <stdin>:56:289: note: scanning from here
> > !17 = distinct !DISubprogram(name: "operator()", linkageName: "??R<lambda_0>@?0??g@@YAHXZ at QBE?A?<auto>@@XZ", scope: !13, file: !7, line: 9, type: !18, scopeLine: 9, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, declaration: !22, retainedNodes: !11)                                                                                                   ^
> > <stdin>:56:289: note: with "FUN_TYPE_LAMBDA" equal to "18"
> > !17 = distinct !DISubprogram(name: "operator()", linkageName: "??R<lambda_0>@?0??g@@YAHXZ at QBE?A?<auto>@@XZ", scope: !13, file: !7, line: 9, type: !18, scopeLine: 9, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, declaration: !22, retainedNodes: !11)                                                                                                   ^
> > <stdin>:57:1: note: possible intended match here
> > !18 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !19)
> > ^Input file: <stdin>
> > Check file: D:\netbatch\build_comp02320_00\ics_top\llvm\clang\test\CodeGenCXX\no_auto_return_lambda.cpp
> > -dump-input=help explains the following input dump.Input was:
> > <<<<<<
> >             .
> >             .
> >             .
> >            51: !12 = !DILocalVariable(name: "f", scope: !6, file: !7, line: 9, type: !13)
> >            52: !13 = distinct !DICompositeType(tag: DW_TAG_class_type, scope: !6, file: !7, line: 9, size: 8, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !11)
> >            53: !14 = !DILocation(line: 9, column: 8, scope: !6)
> >            54: !15 = !DILocation(line: 10, column: 10, scope: !6)
> >            55: !16 = !DILocation(line: 10, column: 3, scope: !6)
> >            56: !17 = distinct !DISubprogram(name: "operator()", linkageName: "??R<lambda_0>@?0??g@@YAHXZ at QBE?A?<auto>@@XZ", scope: !13, file: !7, line: 9, type: !18, scopeLine: 9, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, declaration: !22, retainedNodes: !11)
> > check:24'0                                                                                                                                                                                                                                                                                                     X error: no match found
> > check:24'1                                                                                                                                                                                                                                                                                                       with "FUN_TYPE_LAMBDA" equal to "18"
> >            57: !18 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !19)
> > check:24'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > check:24'2     ?                                                                possible intended match
> >            58: !19 = !{!10, !20}
> > check:24'0     ~~~~~~~~~~~~~~~~~~
> >            59: !20 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !21, size: 32, flags: DIFlagArtificial | DIFlagObjectPointer)
> > check:24'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >            60: !21 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !13)
> > check:24'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >            61: !22 = !DISubprogram(name: "operator()", scope: !13, file: !7, line: 9, type: !18, scopeLine: 9, flags: DIFlagPublic | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
> > check:24'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >            62: !23 = !DILocalVariable(name: "this", arg: 1, scope: !17, type: !24, flags: DIFlagArtificial | DIFlagObjectPointer)
> > check:24'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >             .
> >             .
> >             .
> > >>>>>>error: command failed with exit status: 1--********************
> > Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..1 warning(s) in tests
> > ********************
> > Failed Tests (1): 
> > Clang :: CodeGenCXX/no_auto_return_lambda.cpp
> > ```
> > 
> > See the failure on the check of line 23, which needs a calling-convention (since members are default-this-call in 32 bit windows).
> > 
> > I ALSO note that the line you match against "TYPE_NODE" ends up having 2 things on it when you are checking against '1'.
> disregard the 2nd part about `TYPE_NODE`, that passes, and I was misreading.
> 
> However, the issue with `FUN_TYPE_LAMBDA` is still there.  I repro'd it locally by adding a triple runline, and doing the following change to 'fix it'.
> 
> I just am not sure that it still properly matches the intent of your patch:
> 
> 
> ```
> diff --git a/clang/test/CodeGenCXX/no_auto_return_lambda.cpp b/clang/test/CodeGenCXX/no_auto_return_lambda.cpp
> index 76a98263f766..690dcad52826 100644
> --- a/clang/test/CodeGenCXX/no_auto_return_lambda.cpp
> +++ b/clang/test/CodeGenCXX/no_auto_return_lambda.cpp
> @@ -1,4 +1,5 @@
>  // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
> +// RUN: %clang_cc1 -triple i386-windows-pc -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
> 
>  // We emit "auto" for deduced return types for member functions but we should
>  // not emitting "auto" for deduced return types for lambdas call function which
> @@ -21,5 +22,5 @@ __attribute__((used)) int g() {
>  // operator() of the local lambda should have the same return type as g()
>  //
>  // CHECK: distinct !DISubprogram(name: "operator()",{{.*}}, type: ![[FUN_TYPE_LAMBDA:[0-9]+]],{{.*}}
> -// CHECK: ![[FUN_TYPE_LAMBDA]] = !DISubroutineType(types: ![[TYPE_NODE_LAMBDA:[0-9]+]])
> -// CHECK: ![[TYPE_NODE_LAMBDA]] = !{![[INT_TYPE:[0-9]+]], {{.*}}
> +// CHECK: ![[FUN_TYPE_LAMBDA]] = !DISubroutineType({{.*}}types: ![[TYPE_NODE_LAMBDA:[0-9]+]])
> +// CHECK: ![[TYPE_NODE_LAMBDA]] = !{![[INT_TYPE]], {{.*}}
> 
> 
> ```
> 
> Additionally, I changed the last 'match' block for `INT_TYPE`, which seems to pass in both configs as well.  However, I didn't want to commit it unless you confirmed that it is the 'right' thing.
Thank you for catching, I was trying to be too specific, your change looks good but I think you can leave off the triple. If it still causes you issues w/o the triple then use `%itanium_abi_triple`


================
Comment at: clang/test/CodeGenCXX/no_auto_return_lambda.cpp:25
+// CHECK: ![[FUN_TYPE_LAMBDA]] = !DISubroutineType(types: ![[TYPE_NODE_LAMBDA:[0-9]+]])
+// CHECK: ![[TYPE_NODE_LAMBDA]] = !{![[INT_TYPE:[0-9]+]], {{.*}}
----------------
erichkeane wrote:
> Did you mean the above?
> 
> I note that defining the `INT_TYPE` variable here results in it accepting ANYTHING for `TYPE_NODE_LAMBDA`
> 
No, that was a mistake, your fix above is correct.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123319/new/

https://reviews.llvm.org/D123319



More information about the cfe-commits mailing list