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

[CIR][CIRGen] Enable comdat for static variables #1015

Merged
merged 2 commits into from
Oct 30, 2024
Merged

Conversation

ghehg
Copy link
Collaborator

@ghehg ghehg commented Oct 29, 2024

No description provided.

@ghehg ghehg marked this pull request as ready for review October 29, 2024 02:32
Copy link
Collaborator

@smeenai smeenai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good, but I think the test can be simpler :)

Comment on lines 3 to 6
// RUN: %clang_cc1 -triple aarch64-none-linux-android24 -fclangir -emit-cir %s -o %t1.cir
// RUN: FileCheck --check-prefix=CIR-AARCH64 --input-file=%t1.cir %s
// RUN: %clang_cc1 -triple aarch64-none-linux-android24 -fclangir -emit-llvm %s -o %t1.ll
// RUN: FileCheck --check-prefix=LLVM-AARCH64 --input-file=%t1.ll %s
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this to be AArch64-specific, or can we just reuse the existing RUN lines?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, no need for comdat, I was just thinking to prepare for future target-dependent features testing in this file. But probably we should wait until that comes.

Comment on lines 43 to 52
class b {
public:
// CIR-AARCH64-DAG: cir.global linkonce_odr comdat @_ZZN1b4testEvE1c = #cir.int<0> : !s32i

// LLVM-AARCH64-DAG: $_ZZN1b4testEvE1c = comdat any
// LLVM-AARCH64-DAG: @_ZZN1b4testEvE1c = linkonce_odr global i32 0, comdat, align 4
void test() { static int c; }
// CIR-AARCH64-LABEL: @_ZN1b4testEv
// CIR-AARCH64: {{%.*}} = cir.get_global @_ZZN1b4testEvE1c : !cir.ptr<!s32i>
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an static inside an inline function should do the trick: https://godbolt.org/z/8anK6G9x5

Copy link
Collaborator

@smeenai smeenai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bcardosolopes bcardosolopes merged commit 29e5998 into llvm:main Oct 30, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants