r338656 - Serialize DoesNotEscape.
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 1 16:51:54 PDT 2018
Author: ahatanak
Date: Wed Aug 1 16:51:53 2018
New Revision: 338656
URL: http://llvm.org/viewvc/llvm-project?rev=338656&view=rev
Log:
Serialize DoesNotEscape.
I forgot to commit this in r326530.
Added:
cfe/trunk/test/PCH/no-escaping-block-tail-calls.cpp
cfe/trunk/test/PCH/no-escaping-block-tail-calls.h
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=338656&r1=338655&r2=338656&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Aug 1 16:51:53 2018
@@ -1472,6 +1472,7 @@ void ASTDeclReader::VisitBlockDecl(Block
BD->setIsVariadic(Record.readInt());
BD->setBlockMissingReturnType(Record.readInt());
BD->setIsConversionFromLambda(Record.readInt());
+ BD->setDoesNotEscape(Record.readInt());
bool capturesCXXThis = Record.readInt();
unsigned numCaptures = Record.readInt();
Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=338656&r1=338655&r2=338656&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Wed Aug 1 16:51:53 2018
@@ -1097,6 +1097,7 @@ void ASTDeclWriter::VisitBlockDecl(Block
Record.push_back(D->isVariadic());
Record.push_back(D->blockMissingReturnType());
Record.push_back(D->isConversionFromLambda());
+ Record.push_back(D->doesNotEscape());
Record.push_back(D->capturesCXXThis());
Record.push_back(D->getNumCaptures());
for (const auto &capture : D->captures()) {
Added: cfe/trunk/test/PCH/no-escaping-block-tail-calls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/no-escaping-block-tail-calls.cpp?rev=338656&view=auto
==============================================================================
--- cfe/trunk/test/PCH/no-escaping-block-tail-calls.cpp (added)
+++ cfe/trunk/test/PCH/no-escaping-block-tail-calls.cpp Wed Aug 1 16:51:53 2018
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c++-header -emit-pch -O1 -fblocks -fno-escaping-block-tail-calls -o %t %S/no-escaping-block-tail-calls.h
+// RUN: %clang_cc1 -include-pch %t -emit-llvm -O1 -fblocks -fno-escaping-block-tail-calls -o - %s | FileCheck %s
+
+// Check that -fno-escaping-block-tail-calls doesn't disable tail-call
+// optimization if the block is non-escaping.
+
+// CHECK-LABEL: define internal i32 @___ZN1S1mEv_block_invoke(
+// CHECK: %[[CALL:.*]] = tail call i32 @_ZN1S3fooER2S0(
+// CHECK-NEXT: ret i32 %[[CALL]]
+
+void test() {
+ S s;
+ s.m();
+}
Added: cfe/trunk/test/PCH/no-escaping-block-tail-calls.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/no-escaping-block-tail-calls.h?rev=338656&view=auto
==============================================================================
--- cfe/trunk/test/PCH/no-escaping-block-tail-calls.h (added)
+++ cfe/trunk/test/PCH/no-escaping-block-tail-calls.h Wed Aug 1 16:51:53 2018
@@ -0,0 +1,16 @@
+typedef int (^BlockTy)(void);
+
+struct S0 {
+ int a;
+};
+
+struct S {
+ int i;
+ void func(BlockTy __attribute__((noescape)));
+ int foo(S0 &);
+
+ void m() {
+ __block S0 x;
+ func(^{ return foo(x); });
+ }
+};
More information about the cfe-commits
mailing list