This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
xur marked an inline comment as done.
Closed by commit rG6cee5393371f: [Clang] Change AnonStructIds in MangleContext 
to per-function based (authored by xur).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D136397?vs=469415&id=470052#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136397

Files:
  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

Index: clang/test/CodeGenObjCXX/property-lvalue-lambda.mm
===================================================================
--- clang/test/CodeGenObjCXX/property-lvalue-lambda.mm
+++ clang/test/CodeGenObjCXX/property-lvalue-lambda.mm
@@ -36,12 +36,12 @@
   // [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 += [] {};
 }
Index: clang/test/CodeGenObjCXX/lambda-expressions.mm
===================================================================
--- clang/test/CodeGenObjCXX/lambda-expressions.mm
+++ 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 @@
 // 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 @@
 // 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 @@
 // 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
Index: clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
===================================================================
--- clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
+++ clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
@@ -36,7 +36,7 @@
 // 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 @@
 // 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 @@
 
 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 @@
   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
Index: clang/test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
===================================================================
--- clang/test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
+++ clang/test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
@@ -14,10 +14,10 @@
 // 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 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]]
Index: clang/test/CodeGenCXX/nrvo.cpp
===================================================================
--- clang/test/CodeGenCXX/nrvo.cpp
+++ clang/test/CodeGenCXX/nrvo.cpp
@@ -2531,7 +2531,7 @@
 // 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
Index: clang/test/CodeGenCXX/mangle-lambdas.cpp
===================================================================
--- clang/test/CodeGenCXX/mangle-lambdas.cpp
+++ clang/test/CodeGenCXX/mangle-lambdas.cpp
@@ -176,7 +176,7 @@
 
 // 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 @@
                  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 @@
   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() {
Index: clang/test/CodeGenCXX/lambda-expressions.cpp
===================================================================
--- clang/test/CodeGenCXX/lambda-expressions.cpp
+++ clang/test/CodeGenCXX/lambda-expressions.cpp
@@ -29,8 +29,8 @@
 
 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 @@
 // 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 @@
 // 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 @@
 // 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 @@
 // 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 @@
 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 @@
   }();
 }
 
-// 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 @@
   }
 }
 
-// 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() {
Index: clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
===================================================================
--- clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
+++ clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
@@ -61,7 +61,7 @@
 }
 
 #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) {
Index: clang/test/CodeGenCXX/cxx1y-init-captures.cpp
===================================================================
--- clang/test/CodeGenCXX/cxx1y-init-captures.cpp
+++ clang/test/CodeGenCXX/cxx1y-init-captures.cpp
@@ -28,9 +28,9 @@
 // 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 @@
   // 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 @@
     // 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]]
Index: clang/test/CodeGenCXX/cxx1y-init-captures-eh.cpp
===================================================================
--- clang/test/CodeGenCXX/cxx1y-init-captures-eh.cpp
+++ clang/test/CodeGenCXX/cxx1y-init-captures-eh.cpp
@@ -73,19 +73,19 @@
 
   // 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
Index: clang/test/CodeGenCXX/catch-undef-behavior.cpp
===================================================================
--- clang/test/CodeGenCXX/catch-undef-behavior.cpp
+++ clang/test/CodeGenCXX/catch-undef-behavior.cpp
@@ -735,7 +735,7 @@
 }
 
 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]],
Index: clang/test/CodeGen/attr-function-return.cpp
===================================================================
--- clang/test/CodeGen/attr-function-return.cpp
+++ clang/test/CodeGen/attr-function-return.cpp
@@ -15,14 +15,14 @@
   }();
 }
 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;
   }
Index: clang/lib/AST/ItaniumMangle.cpp
===================================================================
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -1588,7 +1588,9 @@
 
     // 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>
Index: clang/include/clang/AST/Mangle.h
===================================================================
--- clang/include/clang/AST/Mangle.h
+++ clang/include/clang/AST/Mangle.h
@@ -61,6 +61,7 @@
   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 @@
     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;
   }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to