[cfe-commits] PFR: Share c string literals
Chris Lattner
clattner at apple.com
Sat Nov 24 15:25:17 PST 2007
On Nov 24, 2007, at 1:13 PM, Oliver Hunt wrote:
> This patch adds support for sharing literal C strings
> <shared-cstrings.patch>
Looks great, some minor funkiness in indentation here:
+/// CodeGenModule::GetAddrOfConstantString -- returns a pointer to
the first
+/// element of a character array containing the literal.
+llvm::Constant *CodeGenModule::GetAddrOfConstantString(const
std::string &str) {
+ llvm::StringMapEntry<llvm::Constant *> &Entry =
+ ConstantStringMap.GetOrCreateValue(&str[0], &str[str.length()]);
+
+ if (Entry.getValue())
+ return Entry.getValue();
It looks like you switched to indent-by-4 instead of indent-by-2.
Another thing to consider: do you want to add -fwritable-strings
support while you're at it? This basically has two effects: 1) don't
ever share strings, and 2) don't mark the generated globalvariable as
constant.
-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20071124/4c8f46ef/attachment.html>
More information about the cfe-commits
mailing list