-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Add __attribute__((retain)) to LLVM_DUMP_METHOD #133025
Conversation
Without the retain attribute the dump functions will be stripped when LLVM is compiled with `-ffunction-section -Wl,--gc-sections` on ELF-based systems.
Some of our internal builds use Is there any downside to using this attribute in LLVM? |
@llvm/pr-subscribers-llvm-support Author: Matthias Braun (MatzeB) ChangesWithout the retain attribute the dump functions will be stripped when Full diff: https://github.com/llvm/llvm-project/pull/133025.diff 1 Files Affected:
diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index dc8b5389069eb..b6d06238f8d83 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -224,7 +224,9 @@
#define LLVM_PREFETCH(addr, rw, locality)
#endif
-#if __has_attribute(used)
+#if __has_attribute(used) && __has_attribute(retain)
+#define LLVM_ATTRIBUTE_USED __attribute__((__used__, __retain__))
+#elif __has_attribute(used)
#define LLVM_ATTRIBUTE_USED __attribute__((__used__))
#else
#define LLVM_ATTRIBUTE_USED
|
Perhaps we should just add retained to This will enable USED functions to be garbage-collectable on ELF platforms, where this behavior has been consistently present. |
Are you saying you rather have a separate macro for retain? Updated the PR to do that. |
0121c39
to
584a2db
Compare
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, the title needs an adjustment now.
Without the retain attribute the dump functions will be stripped when
LLVM is compiled with
-ffunction-section -Wl,--gc-sections
onELF-based systems.