[clang] 6cee539 - [Clang] Change AnonStructIds in MangleContext to per-function based

Rong Xu via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 23 22:43:33 PDT 2022


Author: Rong Xu
Date: 2022-10-23T22:33:52-07:00
New Revision: 6cee5393371fdde798605c88bad0ebceb3626257

URL: https://github.com/llvm/llvm-project/commit/6cee5393371fdde798605c88bad0ebceb3626257
DIFF: https://github.com/llvm/llvm-project/commit/6cee5393371fdde798605c88bad0ebceb3626257.diff

LOG: [Clang] Change AnonStructIds in MangleContext to per-function based

Clang is generating different mangled names for the same lambda
function in slightly changed builds (like with non-related
source/Macro change). This is due to the fact that clang uses a
cross-translation-unit sequential string "$_<n>" in lambda's
mangled name. Here, "n" is the AnonStructIds field in MangleContext.

Different mangled names for a unchanged function is undesirable:
it makes perf comparison harder, and can cause some unnecessary
profile mismatch in SampleFDO.

This patch makes mangled name for lambda functions more stable
by changing AnonStructIds to a per-function based seq number if the
DeclContext is a function.

Differential Revision: https://reviews.llvm.org/D136397

Added: 
    

Modified: 
    clang/include/clang/AST/Mangle.h
    clang/lib/AST/ItaniumMangle.cpp
    clang/test/CodeGen/attr-function-return.cpp
    clang/test/CodeGenCXX/catch-undef-behavior.cpp
    clang/test/CodeGenCXX/cxx1y-init-captures-eh.cpp
    clang/test/CodeGenCXX/cxx1y-init-captures.cpp
    clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
    clang/test/CodeGenCXX/lambda-expressions.cpp
    clang/test/CodeGenCXX/mangle-lambdas.cpp
    clang/test/CodeGenCXX/nrvo.cpp
    clang/test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
    clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
    clang/test/CodeGenObjCXX/lambda-expressions.mm
    clang/test/CodeGenObjCXX/property-lvalue-lambda.mm

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/Mangle.h b/clang/include/clang/AST/Mangle.h
index 96cc8c90a8e83..a22ed5ab72405 100644
--- a/clang/include/clang/AST/Mangle.h
+++ b/clang/include/clang/AST/Mangle.h
@@ -61,6 +61,7 @@ class MangleContext {
   llvm::DenseMap<const BlockDecl*, unsigned> GlobalBlockIds;
   llvm::DenseMap<const BlockDecl*, unsigned> LocalBlockIds;
   llvm::DenseMap<const NamedDecl*, uint64_t> AnonStructIds;
+  llvm::DenseMap<const FunctionDecl*, unsigned> FuncAnonStructSize;
 
 public:
   ManglerKind getKind() const { return Kind; }
@@ -87,9 +88,17 @@ class MangleContext {
     return Result.first->second;
   }
 
-  uint64_t getAnonymousStructId(const NamedDecl *D) {
+  uint64_t getAnonymousStructId(const NamedDecl *D,
+                                const FunctionDecl *FD = nullptr) {
+    auto FindResult = AnonStructIds.find(D);
+    if (FindResult != AnonStructIds.end())
+      return FindResult->second;
+
+    // If FunctionDecl is passed in, the anonymous structID will be per-function
+    // based.
+    unsigned Id = FD ? FuncAnonStructSize[FD]++ : AnonStructIds.size();
     std::pair<llvm::DenseMap<const NamedDecl *, uint64_t>::iterator, bool>
-        Result = AnonStructIds.insert(std::make_pair(D, AnonStructIds.size()));
+        Result = AnonStructIds.insert(std::make_pair(D, Id));
     return Result.first->second;
   }
 

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 46229a0843ef1..dbd9bb518d8b9 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -1588,7 +1588,9 @@ void CXXNameMangler::mangleUnqualifiedName(
 
     // Get a unique id for the anonymous struct. If it is not a real output
     // ID doesn't matter so use fake one.
-    unsigned AnonStructId = NullOut ? 0 : Context.getAnonymousStructId(TD);
+    unsigned AnonStructId =
+        NullOut ? 0
+                : Context.getAnonymousStructId(TD, dyn_cast<FunctionDecl>(DC));
 
     // Mangle it as a source name in the form
     // [n] $_<id>

diff  --git a/clang/test/CodeGen/attr-function-return.cpp b/clang/test/CodeGen/attr-function-return.cpp
index 47ef1a74cbb69..75cecc99ad490 100644
--- a/clang/test/CodeGen/attr-function-return.cpp
+++ b/clang/test/CodeGen/attr-function-return.cpp
@@ -15,14 +15,14 @@ int foo(void) {
   }();
 }
 int bar(void) {
-  // CHECK: @"_ZZ3barvENK3$_1clEv"({{.*}}) [[EXTERN:#[0-9]+]]
+  // CHECK: @"_ZZ3barvENK3$_0clEv"({{.*}}) [[EXTERN:#[0-9]+]]
   return []() __attribute__((function_return("thunk-extern"))) {
     return 42;
   }
   ();
 }
 int baz(void) {
-  // CHECK: @"_ZZ3bazvENK3$_2clEv"({{.*}}) [[KEEP:#[0-9]+]]
+  // CHECK: @"_ZZ3bazvENK3$_0clEv"({{.*}}) [[KEEP:#[0-9]+]]
   return []() __attribute__((function_return("keep"))) {
     return 42;
   }

diff  --git a/clang/test/CodeGenCXX/catch-undef-behavior.cpp b/clang/test/CodeGenCXX/catch-undef-behavior.cpp
index 9869b1a862526..44ad39c7c8118 100644
--- a/clang/test/CodeGenCXX/catch-undef-behavior.cpp
+++ b/clang/test/CodeGenCXX/catch-undef-behavior.cpp
@@ -735,7 +735,7 @@ namespace CopyValueRepresentation {
 }
 
 void ThisAlign::this_align_lambda_2() {
-  // CHECK-LABEL: define internal void @"_ZZN9ThisAlign19this_align_lambda_2EvENK3$_1clEv"
+  // CHECK-LABEL: define internal void @"_ZZN9ThisAlign19this_align_lambda_2EvENK3$_0clEv"
   // CHECK-SAME: (%{{.*}}* {{[^,]*}} %[[this:[^)]*]])
   // CHECK: %[[this_addr:.*]] = alloca
   // CHECK: store %{{.*}}* %[[this]], %{{.*}}** %[[this_addr]],

diff  --git a/clang/test/CodeGenCXX/cxx1y-init-captures-eh.cpp b/clang/test/CodeGenCXX/cxx1y-init-captures-eh.cpp
index fa419fd5f266c..b0b938191a023 100644
--- a/clang/test/CodeGenCXX/cxx1y-init-captures-eh.cpp
+++ b/clang/test/CodeGenCXX/cxx1y-init-captures-eh.cpp
@@ -73,19 +73,19 @@ void h(bool b1, bool b2) {
 
   // end of full-expression
   // CHECK: call void @_Z1xv(
-  // CHECK: call void @"_ZZ1hbbEN3$_2D1Ev"(
+  // CHECK: call void @"_ZZ1hbbEN3$_0D1Ev"(
   // CHECK: call void @_ZN1TD1Ev(
   // CHECK: call void @_Z1yv(
   // CHECK: ret void
 
   // cleanups for throw 1
   // CHECK: landingpad
-  // CHECK-NOT: @"_ZZ1hbbEN3$_2D1Ev"(
+  // CHECK-NOT: @"_ZZ1hbbEN3$_0D1Ev"(
   // CHECK: br
 
   // cleanups for throw 2
   // CHECK: landingpad
-  // CHECK: call void @"_ZZ1hbbEN3$_2D1Ev"(
+  // CHECK: call void @"_ZZ1hbbEN3$_0D1Ev"(
   // CHECK: br
 
   // common cleanup code

diff  --git a/clang/test/CodeGenCXX/cxx1y-init-captures.cpp b/clang/test/CodeGenCXX/cxx1y-init-captures.cpp
index 358631ecb2062..674ef889776c4 100644
--- a/clang/test/CodeGenCXX/cxx1y-init-captures.cpp
+++ b/clang/test/CodeGenCXX/cxx1y-init-captures.cpp
@@ -28,9 +28,9 @@ void g() {
 // CHECK: store i32 1, ptr
 // CHECK: getelementptr inbounds {{.*}}, i32 0, i32 1
 // CHECK: store i32 2, ptr
-// CHECK: call noundef i32 @"_ZZ1gvENK3$_1clEv"(
+// CHECK: call noundef i32 @"_ZZ1gvENK3$_0clEv"(
 
-// CHECK-LABEL: define internal noundef i32 @"_ZZ1gvENK3$_1clEv"(
+// CHECK-LABEL: define internal noundef i32 @"_ZZ1gvENK3$_0clEv"(
 // CHECK: getelementptr inbounds {{.*}}, i32 0, i32 0
 // CHECK: load i32, ptr
 // CHECK: getelementptr inbounds {{.*}}, i32 0, i32 1
@@ -66,9 +66,9 @@ int h(int a) {
   // CHECK: load i32, ptr %[[A_ADDR]],
   // CHECK: store i32
   //
-  // CHECK: call noundef i32 @"_ZZ1hiENK3$_2clEv"(ptr {{[^,]*}} %[[OUTER]])
+  // CHECK: call noundef i32 @"_ZZ1hiENK3$_0clEv"(ptr {{[^,]*}} %[[OUTER]])
   return [&b(a), c(a)] {
-    // CHECK-LABEL: define internal noundef i32 @"_ZZ1hiENK3$_2clEv"(
+    // CHECK-LABEL: define internal noundef i32 @"_ZZ1hiENK3$_0clEv"(
     // CHECK: %[[OUTER_ADDR:.*]] = alloca
     // CHECK: %[[INNER:.*]] = alloca
     // CHECK: store {{.*}}, ptr %[[OUTER_ADDR]],
@@ -86,12 +86,12 @@ int h(int a) {
     // CHECK-NEXT: load i32, ptr %
     // CHECK-NEXT: store i32
     //
-    // CHECK: call noundef i32 @"_ZZZ1hiENK3$_2clEvENKUlvE_clEv"(ptr {{[^,]*}} %[[INNER]])
+    // CHECK: call noundef i32 @"_ZZZ1hiENK3$_0clEvENKUlvE_clEv"(ptr {{[^,]*}} %[[INNER]])
     return [=, &c] {
       // CHECK-LABEL: define internal void @"_ZZ1fvEN3$_0D2Ev"(
       // CHECK: call void @_ZN1SD1Ev(
 
-      // CHECK-LABEL: define internal noundef i32 @"_ZZZ1hiENK3$_2clEvENKUlvE_clEv"(
+      // CHECK-LABEL: define internal noundef i32 @"_ZZZ1hiENK3$_0clEvENKUlvE_clEv"(
       // CHECK: %[[INNER_ADDR:.*]] = alloca
       // CHECK: store {{.*}}, ptr %[[INNER_ADDR]],
       // CHECK: %[[INNER:.*]] = load ptr, ptr %[[INNER_ADDR]]

diff  --git a/clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp b/clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
index 622c073927ce4..c6b752e3e9e7c 100644
--- a/clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
+++ b/clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
@@ -61,7 +61,7 @@ int use = foo();
 }
 
 #if __cplusplus >= 201402L
-// CXX14-LABEL: define internal void @"_ZZZN32lambda_capture_in_generic_lambda3fooIiEEDavENKUlT_E_clIZNS_L1fEvE3$_1EEDaS1_ENKUlvE_clEv"
+// CXX14-LABEL: define internal void @"_ZZZN32lambda_capture_in_generic_lambda3fooIiEEDavENKUlT_E_clIZNS_L1fEvE3$_0EEDaS1_ENKUlvE_clEv"
 namespace lambda_capture_in_generic_lambda {
 template <typename T> auto foo() {
   return [](auto func) {

diff  --git a/clang/test/CodeGenCXX/lambda-expressions.cpp b/clang/test/CodeGenCXX/lambda-expressions.cpp
index 0375a95598b64..45f61b4bdb0ac 100644
--- a/clang/test/CodeGenCXX/lambda-expressions.cpp
+++ b/clang/test/CodeGenCXX/lambda-expressions.cpp
@@ -29,8 +29,8 @@ int ARBSizeOf(int n) {
 
 int a() { return []{ return 1; }(); }
 // CHECK-LABEL: define{{.*}} i32 @_Z1av
-// CHECK: call noundef i32 @"_ZZ1avENK3$_1clEv"
-// CHECK-LABEL: define internal noundef i32 @"_ZZ1avENK3$_1clEv"
+// CHECK: call noundef i32 @"_ZZ1avENK3$_0clEv"
+// CHECK-LABEL: define internal noundef i32 @"_ZZ1avENK3$_0clEv"
 // CHECK: ret i32 1
 
 int b(int x) { return [x]{return x;}(); }
@@ -38,8 +38,8 @@ int b(int x) { return [x]{return x;}(); }
 // CHECK: store i32
 // CHECK: load i32, ptr
 // CHECK: store i32
-// CHECK: call noundef i32 @"_ZZ1biENK3$_2clEv"
-// CHECK-LABEL: define internal noundef i32 @"_ZZ1biENK3$_2clEv"
+// CHECK: call noundef i32 @"_ZZ1biENK3$_0clEv"
+// CHECK-LABEL: define internal noundef i32 @"_ZZ1biENK3$_0clEv"
 // CHECK: load i32, ptr
 // CHECK: ret i32
 
@@ -47,8 +47,8 @@ int c(int x) { return [&x]{return x;}(); }
 // CHECK-LABEL: define{{.*}} i32 @_Z1ci
 // CHECK: store i32
 // CHECK: store ptr
-// CHECK: call noundef i32 @"_ZZ1ciENK3$_3clEv"
-// CHECK-LABEL: define internal noundef i32 @"_ZZ1ciENK3$_3clEv"
+// CHECK: call noundef i32 @"_ZZ1ciENK3$_0clEv"
+// CHECK-LABEL: define internal noundef i32 @"_ZZ1ciENK3$_0clEv"
 // CHECK: load ptr, ptr
 // CHECK: load i32, ptr
 // CHECK: ret i32
@@ -62,8 +62,8 @@ int d(int x) { D y[10]; return [x,y] { return y[x].x; }(); }
 // CHECK: call void @_ZN1DC1ERKS_
 // CHECK: icmp eq i64 %{{.*}}, 10
 // CHECK: br i1
-// CHECK: call noundef i32 @"_ZZ1diENK3$_4clEv"
-// CHECK-LABEL: define internal noundef i32 @"_ZZ1diENK3$_4clEv"
+// CHECK: call noundef i32 @"_ZZ1diENK3$_0clEv"
+// CHECK-LABEL: define internal noundef i32 @"_ZZ1diENK3$_0clEv"
 // CHECK: load i32, ptr
 // CHECK: load i32, ptr
 // CHECK: ret i32
@@ -73,18 +73,18 @@ int e(E a, E b, bool cond) { return [a,b,cond](){ return (cond ? a : b).x; }();
 // CHECK-LABEL: define{{.*}} i32 @_Z1e1ES_b
 // CHECK: call void @_ZN1EC1ERKS_
 // CHECK: invoke void @_ZN1EC1ERKS_
-// CHECK: invoke noundef i32 @"_ZZ1e1ES_bENK3$_5clEv"
-// CHECK: call void @"_ZZ1e1ES_bEN3$_5D1Ev"
-// CHECK: call void @"_ZZ1e1ES_bEN3$_5D1Ev"
+// CHECK: invoke noundef i32 @"_ZZ1e1ES_bENK3$_0clEv"
+// CHECK: call void @"_ZZ1e1ES_bEN3$_0D1Ev"
+// CHECK: call void @"_ZZ1e1ES_bEN3$_0D1Ev"
 
-// CHECK-LABEL: define internal noundef i32 @"_ZZ1e1ES_bENK3$_5clEv"
+// CHECK-LABEL: define internal noundef i32 @"_ZZ1e1ES_bENK3$_0clEv"
 // CHECK: trunc i8
 // CHECK: load i32, ptr
 // CHECK: ret i32
 
 void f() {
   // CHECK-LABEL: define{{.*}} void @_Z1fv()
-  // CHECK: @"_ZZ1fvENK3$_6cvPFiiiEEv"
+  // CHECK: @"_ZZ1fvENK3$_0cvPFiiiEEv"
   // CHECK-NEXT: store ptr
   // CHECK-NEXT: ret void
   int (*fp)(int, int) = [](int x, int y){ return x + y; };
@@ -93,7 +93,7 @@ void f() {
 static int k;
 int g() {
   int &r = k;
-  // CHECK-LABEL: define internal noundef i32 @"_ZZ1gvENK3$_7clEv"(
+  // CHECK-LABEL: define internal noundef i32 @"_ZZ1gvENK3$_0clEv"(
   // CHECK-NOT: }
   // CHECK: load i32, ptr @_ZL1k,
   return [] { return r; } ();
@@ -110,7 +110,7 @@ void staticarrayref(){
   }();
 }
 
-// CHECK-LABEL: define internal noundef ptr @"_ZZ11PR22071_funvENK3$_9clEv"
+// CHECK-LABEL: define internal noundef ptr @"_ZZ11PR22071_funvENK3$_0clEv"
 // CHECK: ret ptr @PR22071_var
 int PR22071_var;
 int *PR22071_fun() {
@@ -183,18 +183,18 @@ namespace pr28595 {
   }
 }
 
-// CHECK-LABEL: define internal void @"_ZZ1e1ES_bEN3$_5D2Ev"
+// CHECK-LABEL: define internal void @"_ZZ1e1ES_bEN3$_0D2Ev"
 
-// CHECK-LABEL: define internal noundef i32 @"_ZZ1fvEN3$_68__invokeEii"
+// CHECK-LABEL: define internal noundef i32 @"_ZZ1fvEN3$_08__invokeEii"
 // CHECK: store i32
 // CHECK-NEXT: store i32
 // CHECK-NEXT: load i32, ptr
 // CHECK-NEXT: load i32, ptr
-// CHECK-NEXT: call noundef i32 @"_ZZ1fvENK3$_6clEii"
+// CHECK-NEXT: call noundef i32 @"_ZZ1fvENK3$_0clEii"
 // CHECK-NEXT: ret i32
 
-// CHECK-LABEL: define internal void @"_ZZ1hvEN4$_118__invokeEv"(ptr noalias sret(%struct.A) align 1 %agg.result) {{.*}} {
-// CHECK: call void @"_ZZ1hvENK4$_11clEv"(ptr sret(%struct.A) align 1 %agg.result,
+// CHECK-LABEL: define internal void @"_ZZ1hvEN3$_08__invokeEv"(ptr noalias sret(%struct.A) align 1 %agg.result) {{.*}} {
+// CHECK: call void @"_ZZ1hvENK3$_0clEv"(ptr sret(%struct.A) align 1 %agg.result,
 // CHECK-NEXT: ret void
 struct A { ~A(); };
 void h() {

diff  --git a/clang/test/CodeGenCXX/mangle-lambdas.cpp b/clang/test/CodeGenCXX/mangle-lambdas.cpp
index b4312a0fdfe27..93362876e1742 100644
--- a/clang/test/CodeGenCXX/mangle-lambdas.cpp
+++ b/clang/test/CodeGenCXX/mangle-lambdas.cpp
@@ -176,7 +176,7 @@ void func_template(T = []{ return T(); }());
 
 // CHECK-LABEL: define{{.*}} void @_Z17use_func_templatev()
 void use_func_template() {
-  // CHECK: call noundef i32 @"_ZZ13func_templateIiEvT_ENK3$_3clEv"
+  // CHECK: call noundef i32 @"_ZZ13func_templateIiEvT_ENK3$_0clEv"
   func_template<int>();
 }
 
@@ -216,12 +216,12 @@ void ft1(int = [](int p = [] { return 42; } ()) {
                  return p;
                } ());
 void test_ft1() {
-  // CHECK: call noundef i32 @"_ZZZ3ft1IiEviENK3$_4clEiEd_NKUlvE_clEv"
-  // CHECK: call noundef i32 @"_ZZ3ft1IiEviENK3$_4clEi"
+  // CHECK: call noundef i32 @"_ZZZ3ft1IiEviENK3$_0clEiEd_NKUlvE_clEv"
+  // CHECK: call noundef i32 @"_ZZ3ft1IiEviENK3$_0clEi"
   ft1();
 }
-// CHECK-LABEL: define internal noundef i32 @"_ZZ3ft1IiEviENK3$_4clEi"
-// CHECK-LABEL: define internal noundef i32 @"_ZZZ3ft1IiEviENK3$_4clEiEd_NKUlvE_clEv"
+// CHECK-LABEL: define internal noundef i32 @"_ZZ3ft1IiEviENK3$_0clEi"
+// CHECK-LABEL: define internal noundef i32 @"_ZZZ3ft1IiEviENK3$_0clEiEd_NKUlvE_clEv"
 
 struct c1 {
   template<typename = int>
@@ -273,8 +273,8 @@ void ft3() {
   f();
 }
 template void ft3<int>();
-// CHECK: call noundef i32 @"_ZZ1fiENK3$_5clEv"
-// CHECK-LABEL: define internal noundef i32 @"_ZZ1fiENK3$_5clEv"
+// CHECK: call noundef i32 @"_ZZ1fiENK3$_0clEv"
+// CHECK-LABEL: define internal noundef i32 @"_ZZ1fiENK3$_0clEv"
 
 template<typename>
 void ft4() {

diff  --git a/clang/test/CodeGenCXX/nrvo.cpp b/clang/test/CodeGenCXX/nrvo.cpp
index ac89946fdab00..c092ff21ef52b 100644
--- a/clang/test/CodeGenCXX/nrvo.cpp
+++ b/clang/test/CodeGenCXX/nrvo.cpp
@@ -2531,7 +2531,7 @@ X test18(int i) { // http://wg21.link/p2025r2#ex-11
 // CHECK-EH-11-NEXT:    call void @_ZN1XC1Ev(ptr noundef nonnull align 1 dereferenceable(1) [[AGG_RESULT]])
 // CHECK-EH-11-NEXT:    [[TMP1:%.*]] = getelementptr inbounds [[CLASS_ANON_0]], ptr [[REF_TMP]], i32 0, i32 0
 // CHECK-EH-11-NEXT:    store ptr [[AGG_RESULT]], ptr [[TMP1]], align 4
-// CHECK-EH-11-NEXT:    invoke void @"_ZZ6test19vENK3$_1clEv"(ptr sret([[CLASS_X]]) align 1 [[L]], ptr noundef nonnull align 4 dereferenceable(4) [[REF_TMP]])
+// CHECK-EH-11-NEXT:    invoke void @"_ZZ6test19vENK3$_0clEv"(ptr sret([[CLASS_X]]) align 1 [[L]], ptr noundef nonnull align 4 dereferenceable(4) [[REF_TMP]])
 // CHECK-EH-11-NEXT:    to label [[INVOKE_CONT:%.*]] unwind label [[LPAD:%.*]]
 // CHECK-EH-11:       invoke.cont:
 // CHECK-EH-11-NEXT:    store i1 true, ptr [[NRVO]], align 1

diff  --git a/clang/test/CodeGenObjCXX/arc-forwarded-lambda-call.mm b/clang/test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
index bc7946b2030ec..5f85b9617294d 100644
--- a/clang/test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
+++ b/clang/test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
@@ -14,10 +14,10 @@ void test0(id x) {
 // object that is passed.
 
 // CHECK-LABEL: define internal void @___Z8testWeakv_block_invoke(
-// CHECK: call void @"_ZZ8testWeakvENK3$_2clE4Weak"(
+// CHECK: call void @"_ZZ8testWeakvENK3$_0clE4Weak"(
 // CHECK-NEXT: ret void
 
-// CHECK-LABEL: define internal void @"_ZZ8testWeakvENK3$_2clE4Weak"(
+// CHECK-LABEL: define internal void @"_ZZ8testWeakvENK3$_0clE4Weak"(
 // CHECK: call void @_ZN4WeakD1Ev(
 // CHECK-NEXT: ret void
 
@@ -26,8 +26,8 @@ void test0(id x) {
 void test1() {
   extern void test1_helper(id (*)(void));
   test1_helper([](){ return test1_rv; });
-  // CHECK-LABEL: define internal noundef i8* @"_ZZ5test1vEN3$_18__invokeEv"
-  // CHECK: [[T0:%.*]] = call noundef i8* @"_ZZ5test1vENK3$_1clEv"{{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
+  // CHECK-LABEL: define internal noundef i8* @"_ZZ5test1vEN3$_08__invokeEv"
+  // CHECK: [[T0:%.*]] = call noundef i8* @"_ZZ5test1vENK3$_0clEv"{{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
   // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T0]])
   // CHECK-NEXT: [[T2:%.*]] = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* [[T0]])
   // CHECK-NEXT: ret i8* [[T2]]

diff  --git a/clang/test/CodeGenObjCXX/block-nested-in-lambda.mm b/clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
index 8a99b9f3254a3..2a45d4bd87bf6 100644
--- a/clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
+++ b/clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
@@ -36,7 +36,7 @@ void block_in_lambda(int &s1, int &s2) {
 // reference.
 
 // CHECK-LABEL: define{{.*}} void @_ZN18CaptureByReference5test0Ev(
-// CHECK-LABEL: define internal void @"_ZZN18CaptureByReference5test0EvENK3$_3clEv"(
+// CHECK-LABEL: define internal void @"_ZZN18CaptureByReference5test0EvENK3$_0clEv"(
 // CHECK: %[[BLOCK_DESCRIPTOR:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8** }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8** }>* %{{.*}}, i32 0, i32 4
 // CHECK: store %[[STRUCT_BLOCK_DESCRIPTOR]]* bitcast ({ i64, i64, i8*, i64 }* @"__block_descriptor_40_e5_v8\01?0ls32l8" to %[[STRUCT_BLOCK_DESCRIPTOR]]*), %[[STRUCT_BLOCK_DESCRIPTOR]]** %[[BLOCK_DESCRIPTOR]], align 8
 
@@ -49,7 +49,7 @@ void test0() {
 // is captured by reference.
 
 // CHECK-LABEL: define{{.*}} void @_ZN18CaptureByReference5test1Ev(
-// CHECK-LABEL: define internal void @"_ZZN18CaptureByReference5test1EvENK3$_4clEv"(
+// CHECK-LABEL: define internal void @"_ZZN18CaptureByReference5test1EvENK3$_0clEv"(
 // CHECK: %[[BLOCK_DESCRIPTOR:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8** }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8** }>* %{{.*}}, i32 0, i32 4
 // CHECK: store %[[STRUCT_BLOCK_DESCRIPTOR]]* bitcast ({ i64, i64, i8*, i8*, i8*, i64 }* @"__block_descriptor_56_8_32s40s_e5_v8\01?0l" to %[[STRUCT_BLOCK_DESCRIPTOR]]*), %[[STRUCT_BLOCK_DESCRIPTOR]]** %[[BLOCK_DESCRIPTOR]], align 8
 
@@ -70,7 +70,7 @@ void test1() {
 
 S getS();
 
-// CHECK: define internal noundef i32 @"_ZZN18CaptureByReference5test2EvENK3$_1clIiEEDaT_"(%[[CLASS_ANON_2]]* {{[^,]*}} %{{.*}}, i32 noundef %{{.*}})
+// CHECK: define internal noundef i32 @"_ZZN18CaptureByReference5test2EvENK3$_0clIiEEDaT_"(%[[CLASS_ANON_2]]* {{[^,]*}} %{{.*}}, i32 noundef %{{.*}})
 // CHECK: %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, %{{.*}}, %[[S]]* }>, align 8
 // CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %{{.*}}, %[[S]]* }>, <{ i8*, i32, i32, i8*, %{{.*}}, %[[S]]* }>* %[[BLOCK]], i32 0, i32 5
 // CHECK: %[[V0:.*]] = getelementptr inbounds %[[CLASS_ANON_2]], %[[CLASS_ANON_2]]* %{{.*}}, i32 0, i32 0
@@ -87,7 +87,7 @@ int test2() {
   return fn(123);
 }
 
-// CHECK: define internal noundef i32 @"_ZZN18CaptureByReference5test3EvENK3$_2clIiEEDaT_"(%[[CLASS_ANON_3]]* {{[^,]*}} %{{.*}}, i32 noundef %{{.*}})
+// CHECK: define internal noundef i32 @"_ZZN18CaptureByReference5test3EvENK3$_0clIiEEDaT_"(%[[CLASS_ANON_3]]* {{[^,]*}} %{{.*}}, i32 noundef %{{.*}})
 // CHECK: %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, %{{.*}}*, %[[S]] }>, align 8
 // CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %{{.*}}*, %[[S]] }>, <{ i8*, i32, i32, i8*, %{{.*}}*, %[[S]] }>* %[[BLOCK]], i32 0, i32 5
 // CHECK: %[[V0:.*]] = getelementptr inbounds %[[CLASS_ANON_3]], %[[CLASS_ANON_3]]* %{{.*}}, i32 0, i32 0

diff  --git a/clang/test/CodeGenObjCXX/lambda-expressions.mm b/clang/test/CodeGenObjCXX/lambda-expressions.mm
index ba2ec098f92fb..d81603d7b9b12 100644
--- a/clang/test/CodeGenObjCXX/lambda-expressions.mm
+++ b/clang/test/CodeGenObjCXX/lambda-expressions.mm
@@ -38,7 +38,7 @@
 // ARC: call i8* @llvm.objc.retainBlock
 // ARC: call void @llvm.objc.release
 // ARC-LABEL: define internal noundef i32 @___Z2f2v_block_invoke
-// ARC: call noundef i32 @"_ZZ2f2vENK3$_1clEv
+// ARC: call noundef i32 @"_ZZ2f2vENK3$_0clEv
 
 template <class T> void take_lambda(T &&lambda) { lambda(); }
 void take_block(void (^block)()) { block(); }
@@ -66,7 +66,7 @@ - (void) test {
 // ARC:   %[[CAPTURE0:.*]] = getelementptr inbounds %[[LAMBDACLASS]], %[[LAMBDACLASS]]* %{{.*}}, i32 0, i32 0
 // ARC:   store i32 %{{.*}}, i32* %[[CAPTURE0]]
 
-// ARC: define internal void @"_ZZN13LambdaCapture4foo1ERiENK3$_3clEv"(%[[LAMBDACLASS]]* {{[^,]*}} %{{.*}})
+// ARC: define internal void @"_ZZN13LambdaCapture4foo1ERiENK3$_0clEv"(%[[LAMBDACLASS]]* {{[^,]*}} %{{.*}})
 // ARC:   %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>
 // ARC:   %[[CAPTURE1:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>* %[[BLOCK]], i32 0, i32 5
 // ARC:   store i32 %{{.*}}, i32* %[[CAPTURE1]]
@@ -75,11 +75,11 @@ - (void) test {
 // ARC-NOT: @llvm.objc.storeStrong(
 // ARC: ret void
 
-// ARC: define internal void @"___ZZN13LambdaCapture4foo1ERiENK3$_3clEv_block_invoke"
+// ARC: define internal void @"___ZZN13LambdaCapture4foo1ERiENK3$_0clEv_block_invoke"
 // ARC:   %[[CAPTURE2:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>* %{{.*}}, i32 0, i32 5
 // ARC:   store i32 %{{.*}}, i32* %[[CAPTURE2]]
 
-// ARC: define internal void @"___ZZN13LambdaCapture4foo1ERiENK3$_3clEv_block_invoke_2"(i8* noundef %{{.*}})
+// ARC: define internal void @"___ZZN13LambdaCapture4foo1ERiENK3$_0clEv_block_invoke_2"(i8* noundef %{{.*}})
 // ARC:   %[[CAPTURE3:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>* %{{.*}}, i32 0, i32 5
 // ARC:   %[[V1:.*]] = load i32, i32* %[[CAPTURE3]]
 // ARC:   store i32 %[[V1]], i32* @_ZN13LambdaCapture1iE
@@ -141,11 +141,11 @@ - (void)foo {
 // Check that the delegating invoke function doesn't destruct the Weak object
 // that is passed.
 
-// ARC-LABEL: define internal void @"_ZZN14LambdaDelegate4testEvEN3$_58__invokeENS_4WeakE"(
-// ARC: call void @"_ZZN14LambdaDelegate4testEvENK3$_5clENS_4WeakE"(
+// ARC-LABEL: define internal void @"_ZZN14LambdaDelegate4testEvEN3$_08__invokeENS_4WeakE"(
+// ARC: call void @"_ZZN14LambdaDelegate4testEvENK3$_0clENS_4WeakE"(
 // ARC-NEXT: ret void
 
-// ARC-LABEL: define internal void @"_ZZN14LambdaDelegate4testEvENK3$_5clENS_4WeakE"(
+// ARC-LABEL: define internal void @"_ZZN14LambdaDelegate4testEvENK3$_0clENS_4WeakE"(
 // ARC: call void @_ZN14LambdaDelegate4WeakD1Ev(
 
 #ifdef WEAK_SUPPORTED

diff  --git a/clang/test/CodeGenObjCXX/property-lvalue-lambda.mm b/clang/test/CodeGenObjCXX/property-lvalue-lambda.mm
index 67c9db1722a8b..1253ae6d45b04 100644
--- a/clang/test/CodeGenObjCXX/property-lvalue-lambda.mm
+++ b/clang/test/CodeGenObjCXX/property-lvalue-lambda.mm
@@ -36,12 +36,12 @@ void t2(X *x) {
   // [x setBlk: operator+([x blk], [] {})]
 
   // CHECK: call void{{.*}}@objc_msgSend{{.*}}
-  // CHECK: [[PLUS:%.*]] = call void ()* @"_ZplIZ2t2P1XE3$_2EU13block_pointerFvvES4_T_"
+  // CHECK: [[PLUS:%.*]] = call void ()* @"_ZplIZ2t2P1XE3$_0EU13block_pointerFvvES4_T_"
   // CHECK: call void{{.*}}@objc_msgSend{{.*}}({{.*}} [[PLUS]])
   x.blk += [] {};
 
   // CHECK: call void{{.*}}@objc_msgSend{{.*}}
-  // CHECK: [[PLUS:%.*]] = call void ()* @"_ZplIZ2t2P1XE3$_3EPFvvES4_T_"
+  // CHECK: [[PLUS:%.*]] = call void ()* @"_ZplIZ2t2P1XE3$_1EPFvvES4_T_"
   // CHECK: call void{{.*}}@objc_msgSend{{.*}}({{.*}} [[PLUS]])
   x.fnptr += [] {};
 }


        


More information about the cfe-commits mailing list