Remove the loaded value if it is not needed, in GetStaticInstance.

llvm-svn: 60445
diff --git a/vmkit/lib/JnJVM/VMCore/LowerConstantCalls.cpp b/vmkit/lib/JnJVM/VMCore/LowerConstantCalls.cpp
index d18819f..939bc20 100644
--- a/vmkit/lib/JnJVM/VMCore/LowerConstantCalls.cpp
+++ b/vmkit/lib/JnJVM/VMCore/LowerConstantCalls.cpp
@@ -347,10 +347,14 @@
           
           ConstantInt* C = (ConstantInt*)CE->getOperand(0);
           Class* cl = (Class*)C->getZExtValue();
-
+          
+          Instruction* R = dyn_cast<Instruction>(Call.getArgument(0));
           Value* Replace = module->getStaticInstance(cl, CI);
           CI->replaceAllUsesWith(Replace);
           CI->eraseFromParent();
+          
+          if (R && !R->getNumUses()) R->eraseFromParent();
+         
 
 #elif defined(ISOLATE)
           Value* TCM = getTCM(module, Call.getArgument(0), CI);