-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
[clang-repl] Emit const variables only once #65257
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good to me. Can we backport that to the llvm17 release branch? I know at least one downstream project that jumps through hoops to support this.
I'd say we should not backport to 17.0.0; we need to get the final rc out the door and this isn't fixing a critical bug or regression. However, it may be reasonable to consider for 17.0.1+ |
Disable internal linkage for const variables if IncrementalExtensions are enabled. Otherwise the variables are emitted multiple times, with multiple constructions at unique memory locations, during every PTU.
fcea576
to
7b52d2a
Compare
The original patch worked for |
Ping on the updated patch, which is now also passing downstream testing after I realized that we were missing a backport of commit e451d55, which explains why some constructors were wrongly ordered... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(still getting used to the revised system)
I have no comments on this patch.
ping @vgvassilev |
// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s | ||
|
||
extern "C" int printf(const char*, ...); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a case for a file scope constant? We also should consider enabling that for C.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const A a(1);
is a file-scope constant, no? We don't need it for C because the special case in LinkageComputer::getLVForNamespaceScopeDecl
only applies to C++ (my understanding is that const
variables always have an identity in C).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const A a(1); is a file-scope constant, no?
Yes, missed that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Let's move forward here and rely on a further post-commit review if necessary.
// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s | ||
|
||
extern "C" int printf(const char*, ...); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const A a(1); is a file-scope constant, no?
Yes, missed that.
Note that this currently doesn't seem to work on Windows: #68092 |
Disable internal linkage for const variables if IncrementalExtensions are enabled. Otherwise the variables are emitted multiple times, with multiple constructions at unique memory locations, during every PTU.