[llvm-commits] [dragonegg] r149384 - /dragonegg/trunk/src/Constants.cpp

Duncan Sands baldrick at free.fr
Tue Jan 31 05:40:31 PST 2012


Author: baldrick
Date: Tue Jan 31 07:40:31 2012
New Revision: 149384

URL: http://llvm.org/viewvc/llvm-project?rev=149384&view=rev
Log:
Speed up handling of type mismatches with huge initial values.
The origin of this kind of thing is usually that the two types
are structurally identical struct types, one named the other
anonymous.  It's probably worth trying to avoid this kind of
thing altogether by catching it earlier on.

Modified:
    dragonegg/trunk/src/Constants.cpp

Modified: dragonegg/trunk/src/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=149384&r1=149383&r2=149384&view=diff
==============================================================================
--- dragonegg/trunk/src/Constants.cpp (original)
+++ dragonegg/trunk/src/Constants.cpp Tue Jan 31 07:40:31 2012
@@ -412,9 +412,17 @@
 /// value of type 'Ty' from the stored to memory location.
 static Constant *InterpretAsType(Constant *C, Type* Ty, int StartingBit,
                                  TargetFolder &Folder) {
+  // Efficient handling for some common cases.
   if (C->getType() == Ty)
     return C;
 
+  if (isa<UndefValue>(C))
+    return UndefValue::get(Ty);
+
+  if (C->isNullValue())
+    return Constant::getNullValue(Ty);
+
+  // The general case.
   switch (Ty->getTypeID()) {
   default:
     DieAbjectly("Unsupported type!");





More information about the llvm-commits mailing list