Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should consteval constructor produce symbols? #82154

Closed
ChuanqiXu9 opened this issue Feb 18, 2024 · 3 comments · Fixed by #82179
Closed

Should consteval constructor produce symbols? #82154

ChuanqiXu9 opened this issue Feb 18, 2024 · 3 comments · Fixed by #82179
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party consteval C++20 consteval

Comments

@ChuanqiXu9
Copy link
Member

(From #81745)

During the debugging process, I found the codegen will generate consteval constructor. It is surprising to me. In my memory, we shouldn't emit consteval functions at all.

Reproducer:

// test-main.cc
struct S1 { consteval S1(int) {} };
int main() {
    struct S2 { S1 s = 0; };
    S2 s;
}
$ clang++ -std=c++20 test-main.cc -c -o main.o
$nm -C main.o | grep S1
0000000000000000 W S1::S1(int)

We can double check the LLVM IR:

$ clang++ -std=c++20 test-main.cc -fmodule-file=M=test.pcm -S -emit-llvm -o -

We should be able to see the definition of @_ZN2S1C2Ei. And we can demangle it by:

$ llvm-cxxfilt _ZN2S1C2Ei
S1::S1(int)
@ChuanqiXu9 ChuanqiXu9 added c++20 consteval C++20 consteval labels Feb 18, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 18, 2024

@llvm/issue-subscribers-c-20

Author: Chuanqi Xu (ChuanqiXu9)

(From https://github.com//issues/81745)

During the debugging process, I found the codegen will generate consteval constructor. It is surprising to me. In my memory, we shouldn't emit consteval functions at all.

Reproducer:

// test-main.cc
struct S1 { consteval S1(int) {} };
int main() {
    struct S2 { S1 s = 0; };
    S2 s;
}
$ clang++ -std=c++20 test-main.cc -c -o main.o
$nm -C main.o | grep S1
0000000000000000 W S1::S1(int)

We can double check the LLVM IR:

$ clang++ -std=c++20 test-main.cc -fmodule-file=M=test.pcm -S -emit-llvm -o -

We should be able to see the definition of @<!-- -->_ZN2S1C2Ei. And we can demangle it by:

$ llvm-cxxfilt _ZN2S1C2Ei
S1::S1(int)

@ChuanqiXu9
Copy link
Member Author

CC: @erichkeane @cor3ntin @tbaederr

@cor3ntin cor3ntin added the confirmed Verified by a second party label Feb 18, 2024
cor3ntin added a commit to cor3ntin/llvm-project that referenced this issue Feb 18, 2024
A CXXConstructExpr may refer to an immediate constructor,
in which case it should be substituted in the
enclosing default init expression.

Fixes llvm#82154
cor3ntin added a commit that referenced this issue Feb 19, 2024
A CXXConstructExpr may refer to an immediate constructor, in which case
it should be substituted in the
enclosing default init expression.

Fixes #82154
@EugeneZelenko EugeneZelenko added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Feb 19, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 19, 2024

@llvm/issue-subscribers-clang-frontend

Author: Chuanqi Xu (ChuanqiXu9)

(From https://github.com//issues/81745)

During the debugging process, I found the codegen will generate consteval constructor. It is surprising to me. In my memory, we shouldn't emit consteval functions at all.

Reproducer:

// test-main.cc
struct S1 { consteval S1(int) {} };
int main() {
    struct S2 { S1 s = 0; };
    S2 s;
}
$ clang++ -std=c++20 test-main.cc -c -o main.o
$nm -C main.o | grep S1
0000000000000000 W S1::S1(int)

We can double check the LLVM IR:

$ clang++ -std=c++20 test-main.cc -fmodule-file=M=test.pcm -S -emit-llvm -o -

We should be able to see the definition of @<!-- -->_ZN2S1C2Ei. And we can demangle it by:

$ llvm-cxxfilt _ZN2S1C2Ei
S1::S1(int)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party consteval C++20 consteval
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants