[llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp

Alkis Evlogimenos alkis at cs.uiuc.edu
Wed Mar 23 20:24:35 PST 2005



Changes in directory llvm-java/lib/Compiler:

Compiler.cpp updated: 1.240 -> 1.241
---
Log message:

Do not call getConstant() on a String constant since that adds a load
instruction in the current basic block and we don't want that to
happen in emitStaticInitializers. Strings are not LLVM constants
anyway, so we don't need to check if the Value returned by
getConstant() for a String is an LLVM constant.


---
Diffs of the changes:  (+10 -8)

 Compiler.cpp |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)


Index: llvm-java/lib/Compiler/Compiler.cpp
diff -u llvm-java/lib/Compiler/Compiler.cpp:1.240 llvm-java/lib/Compiler/Compiler.cpp:1.241
--- llvm-java/lib/Compiler/Compiler.cpp:1.240	Mon Mar 21 14:59:16 2005
+++ llvm-java/lib/Compiler/Compiler.cpp	Wed Mar 23 22:24:24 2005
@@ -1593,14 +1593,16 @@
             // dynamic initializer. Because LLVM does not currently
             // support these semantics, we consider constants only
             // final fields with static initializers.
-            bool isConstant = field->isStatic();
-            llvm::Constant* init;
-            if (field->getConstantValueAttribute() &&
-                dyn_cast<llvm::Constant>(getConstant(field->getConstantValueAttribute()->getValue())))
-              init = ConstantExpr::getCast(dyn_cast<llvm::Constant>(getConstant(field->getConstantValueAttribute()->getValue())), globalTy);
-            else {
-              init = llvm::Constant::getNullValue(globalTy);
-              isConstant = false;
+            bool isConstant = false;
+            llvm::Constant* init = llvm::Constant::getNullValue(globalTy);
+            if (field->getConstantValueAttribute()) {
+              Constant* constant =
+                field->getConstantValueAttribute()->getValue();
+              if (!dynamic_cast<ConstantString*>(constant)) {
+                init = ConstantExpr::getCast(
+                  dyn_cast<llvm::Constant>(getConstant(constant)), globalTy);
+                isConstant = field->isFinal();
+              }
             }
 
             std::string globalName =






More information about the llvm-commits mailing list