[llvm-commits] [dragonegg] r137937 - /dragonegg/trunk/src/Backend.cpp
Duncan Sands
baldrick at free.fr
Thu Aug 18 04:48:30 PDT 2011
Author: baldrick
Date: Thu Aug 18 06:48:30 2011
New Revision: 137937
URL: http://llvm.org/viewvc/llvm-project?rev=137937&view=rev
Log:
Mark constant globals "unnamed_addr", enabing constant merging, when doing
so is clearly safe.
Modified:
dragonegg/trunk/src/Backend.cpp
Modified: dragonegg/trunk/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=137937&r1=137936&r2=137937&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Thu Aug 18 06:48:30 2011
@@ -886,6 +886,14 @@
TARGET_ADJUST_LLVM_LINKAGE(GV, decl);
#endif /* TARGET_ADJUST_LLVM_LINKAGE */
+ // If this is a constant that never has its address taken then allow it to be
+ // merged with other constants (C and C++ say that different variables should
+ // have different addresses, which is why this is only correct if the address
+ // is not taken). However if -fmerge-all-constants was specified then allow
+ // merging even if the address was taken.
+ GV->setUnnamedAddr(GV->isConstant() && (flag_merge_constants >= 2 ||
+ !TREE_ADDRESSABLE(decl)));
+
handleVisibility(decl, GV);
// Set the section for the global.
More information about the llvm-commits
mailing list