[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-10-21 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/107581 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-10-21 Thread Kerry McLaughlin via cfe-commits
https://github.com/kmclaughlin-arm updated https://github.com/llvm/llvm-project/pull/107581 >From 1e6f25c517d8d1adeeaf59f826141efdcad8f05a Mon Sep 17 00:00:00 2001 From: Kerry McLaughlin Date: Fri, 6 Sep 2024 10:13:33 + Subject: [PATCH 1/6] [Clang] Emit error for duplicate mangled names wit

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-10-18 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Can you add a testcase that doesn't involve lambdas? Maybe something like the following: ``` inline void f(int) asm("foo"); inline void f(int) {} inline void f() asm("foo"); inline void f(){} ``` https://github.com/llvm/llvm-project/pull/107581 ___

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-10-18 Thread Kerry McLaughlin via cfe-commits
kmclaughlin-arm wrote: > Oh, that makes sense... so the issue is generally with functions we emit > lazily? > I'd say it's reasonable to emit an error if we have two definitions for the > same symbol, even if we don't end up emitting them because they're deferred. Yes, I believe so. I've moved

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-10-18 Thread Kerry McLaughlin via cfe-commits
https://github.com/kmclaughlin-arm updated https://github.com/llvm/llvm-project/pull/107581 >From 1e6f25c517d8d1adeeaf59f826141efdcad8f05a Mon Sep 17 00:00:00 2001 From: Kerry McLaughlin Date: Fri, 6 Sep 2024 10:13:33 + Subject: [PATCH 1/5] [Clang] Emit error for duplicate mangled names wit

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-20 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Oh, that makes sense... so the issue is generally with functions we emit lazily? I'd say it's reasonable to emit an error if we have two definitions for the same symbol, even if we don't end up emitting them because they're deferred. Lazy emission is an optimization, and

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-20 Thread Kerry McLaughlin via cfe-commits
kmclaughlin-arm wrote: > For the lambda example, there are only three relevant calls to > GetOrCreateLLVMFunction; one for each function with IsInDefinition false, but > then only one with IsInDefinition true. > > It's not clear to me why the two cases are different, and I don't really want >

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-17 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: In the example in https://github.com/llvm/llvm-project/pull/107581#issuecomment-2343651051 , there are four relevant calls to GetOrCreateLLVMFunction: one for each function with IsInDefinition false, and one for each function with IsInDefinition true. The last of those c

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-17 Thread Kerry McLaughlin via cfe-commits
kmclaughlin-arm wrote: > For non-lambda methods, the way this works it that we call > GetOrCreateLLVMFunction for both methods... for the first method, the > `!Entry->isDeclaration()` would be false, but for the second one, it would be > true because we've emitted the definition of the first m

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-17 Thread Kerry McLaughlin via cfe-commits
@@ -0,0 +1,31 @@ +// REQUIRES: aarch64-registered-target + +// RUN: %clang_cc1 -triple aarch64 -emit-llvm -o - %s -verify -DTEST1 +// RUN: %clang_cc1 -triple aarch64 -target-feature +sme -target-feature +sme2 -emit-llvm -o - %s -verify -DTEST2 kmclaughlin-arm wro

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-17 Thread Kerry McLaughlin via cfe-commits
https://github.com/kmclaughlin-arm updated https://github.com/llvm/llvm-project/pull/107581 >From 1e6f25c517d8d1adeeaf59f826141efdcad8f05a Mon Sep 17 00:00:00 2001 From: Kerry McLaughlin Date: Fri, 6 Sep 2024 10:13:33 + Subject: [PATCH 1/4] [Clang] Emit error for duplicate mangled names wit

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-16 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > I see that it is set and the reason the existing error is not emitted is > because of the !Entry->isDeclaration() condition. For non-lambda methods, the way this works it that we call GetOrCreateLLVMFunction for both methods... for the first method, the `!Entry->isDecla

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-16 Thread Sander de Smalen via cfe-commits
@@ -0,0 +1,31 @@ +// REQUIRES: aarch64-registered-target + +// RUN: %clang_cc1 -triple aarch64 -emit-llvm -o - %s -verify -DTEST1 +// RUN: %clang_cc1 -triple aarch64 -target-feature +sme -target-feature +sme2 -emit-llvm -o - %s -verify -DTEST2 sdesmalen-arm wrote

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-16 Thread Kerry McLaughlin via cfe-commits
https://github.com/kmclaughlin-arm updated https://github.com/llvm/llvm-project/pull/107581 >From 1e6f25c517d8d1adeeaf59f826141efdcad8f05a Mon Sep 17 00:00:00 2001 From: Kerry McLaughlin Date: Fri, 6 Sep 2024 10:13:33 + Subject: [PATCH 1/3] [Clang] Emit error for duplicate mangled names wit

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-16 Thread Sander de Smalen via cfe-commits
@@ -4652,18 +4652,35 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction( // If there are two attempts to define the same mangled name, issue an // error. -if (IsForDefinition && !Entry->isDeclaration()) { - GlobalDecl OtherGD; - // Check that GD is

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-16 Thread Sander de Smalen via cfe-commits
@@ -0,0 +1,30 @@ +// REQUIRES: aarch64-registered-target + +// RUN: %clang_cc1 -triple aarch64 -target-feature +sme -target-feature +sme2 -emit-llvm -o - %s -verify -DTEST1 +// RUN: %clang_cc1 -triple aarch64 -target-feature +sme -target-feature +sme2 -emit-llvm -o - %s -verify

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-16 Thread Sander de Smalen via cfe-commits
@@ -0,0 +1,30 @@ +// REQUIRES: aarch64-registered-target + +// RUN: %clang_cc1 -triple aarch64 -target-feature +sme -target-feature +sme2 -emit-llvm -o - %s -verify -DTEST1 +// RUN: %clang_cc1 -triple aarch64 -target-feature +sme -target-feature +sme2 -emit-llvm -o - %s -verify

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-16 Thread Sander de Smalen via cfe-commits
@@ -4652,18 +4652,35 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction( // If there are two attempts to define the same mangled name, issue an // error. -if (IsForDefinition && !Entry->isDeclaration()) { - GlobalDecl OtherGD; - // Check that GD is

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-13 Thread Kerry McLaughlin via cfe-commits
kmclaughlin-arm wrote: > > I'm having a bit of trouble understanding the way the new code is structured. > What makes the definition of lambda call operators special here? Do we not > call GetOrCreateLLVMFunction with IsForDefinition set? When I added this error I incorrectly thought GetOrCre

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-13 Thread Kerry McLaughlin via cfe-commits
https://github.com/kmclaughlin-arm updated https://github.com/llvm/llvm-project/pull/107581 >From 1e6f25c517d8d1adeeaf59f826141efdcad8f05a Mon Sep 17 00:00:00 2001 From: Kerry McLaughlin Date: Fri, 6 Sep 2024 10:13:33 + Subject: [PATCH 1/2] [Clang] Emit error for duplicate mangled names wit

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-11 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Sure, it makes sense to print a diagnostic for lambdas. - I'm having a bit of trouble understanding the way the new code is structured. What makes the definition of lambda call operators special here? Do we not call GetOrCreateLLVMFunction with IsForDefinition set?

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-11 Thread Sander de Smalen via cfe-commits
sdesmalen-arm wrote: > > The SME type attributes are not part of the name mangling > > If `int(&)() __arm_streaming` is a different type from `int(&)()` for > template instantiation, it should have different mangling. If it doesn't, > that's a bug. If there is no spec for the correct mangling,

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-09 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: (You shouldn't need to special-case lambdas; any use of the type needs the appropriate mangling, except maybe the function declaration itself.) https://github.com/llvm/llvm-project/pull/107581 ___ cfe-commits mailing list cfe-comm

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-09 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > The SME type attributes are not part of the name mangling If `int(&)() __arm_streaming` is a different type from `int(&)()` for template instantiation, it should have different mangling. If it doesn't, that's a bug. If there is no spec for the correct mangling, someone

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-09 Thread Kerry McLaughlin via cfe-commits
kmclaughlin-arm wrote: > Isn't this a bug in the mangler? I mean, it's better to print an error rather > than silently miscompile, but this doesn't really solve the issue. Hi @efriedma-quic, The SME type attributes are not part of the name mangling. We figured an error message would be useful

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-06 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Isn't this a bug in the mangler? I mean, it's better to print an error rather than silently miscompile, but this doesn't really solve the issue. https://github.com/llvm/llvm-project/pull/107581 ___ cfe-commits mailing list cfe-com

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-06 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: Kerry McLaughlin (kmclaughlin-arm) Changes When functions are passed as arguments to a lambda, it's possible for the mangled names of these functions to be the same despite the prototypes being different. For example: ``` int non

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-06 Thread Kerry McLaughlin via cfe-commits
https://github.com/kmclaughlin-arm created https://github.com/llvm/llvm-project/pull/107581 When functions are passed as arguments to a lambda, it's possible for the mangled names of these functions to be the same despite the prototypes being different. For example: ``` int non_streaming_fn(i