Revision: 124166
Author:   clattner
Date:     2007-02-21 19:28:53 -0800 (Wed, 21 Feb 2007)

Log Message:
-----------
writable strings shouldn't be cached.

Modified Paths:
--------------
    apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-convert.cpp      2007-02-22 01:53:25 UTC 
(rev 124165)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp      2007-02-22 03:28:53 UTC 
(rev 124166)
@@ -5229,16 +5229,18 @@
 
 Constant *TreeConstantToLLVM::EmitLV_STRING_CST(tree exp) {
   Constant *Init = TreeConstantToLLVM::ConvertSTRING_CST(exp);
-    
-  // Cache the string constants to avoid making obvious duplicate strings that
-  // have to be folded by the optimizer.
-  static std::map<Constant*, GlobalVariable*> StringCSTCache;
-  GlobalVariable *&Slot = StringCSTCache[Init];
-  if (Slot) return Slot;
-    
+
   // Support -fwritable-strings.
   bool StringIsConstant = !flag_writable_strings;
-  
+
+  if (StringIsConstant) {
+    // Cache the string constants to avoid making obvious duplicate strings 
that
+    // have to be folded by the optimizer.
+    static std::map<Constant*, GlobalVariable*> StringCSTCache;
+    GlobalVariable *&Slot = StringCSTCache[Init];
+    if (Slot) return Slot;
+  }
+    
   // Create a new string global.
   return Slot = new GlobalVariable(Init->getType(), StringIsConstant,
                                    GlobalVariable::InternalLinkage,


_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to