[llvm-commits] [dragonegg] r127083 - /dragonegg/trunk/llvm-convert.cpp

Duncan Sands baldrick at free.fr
Sat Mar 5 06:02:31 PST 2011


Author: baldrick
Date: Sat Mar  5 08:02:31 2011
New Revision: 127083

URL: http://llvm.org/viewvc/llvm-project?rev=127083&view=rev
Log:
Remove some uses of TreeConstantToLLVM::Convert.  This is part of a program
to have the Convert routines only be used for converting initializers for
global variables.

Modified:
    dragonegg/trunk/llvm-convert.cpp

Modified: dragonegg/trunk/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=127083&r1=127082&r2=127083&view=diff
==============================================================================
--- dragonegg/trunk/llvm-convert.cpp (original)
+++ dragonegg/trunk/llvm-convert.cpp Sat Mar  5 08:02:31 2011
@@ -1851,6 +1851,19 @@
 //                           ... Control Flow ...
 //===----------------------------------------------------------------------===//
 
+/// ConvertTypeInfo - Convert an exception handling type info into a pointer to
+/// the associated runtime type info object.
+static Constant *ConvertTypeInfo(tree type) {
+  // TODO: Once pass_ipa_free_lang is made a default pass, remove the call to
+  // lookup_type_for_runtime below.
+  if (TYPE_P (type))
+    type = lookup_type_for_runtime (type);
+  STRIP_NOPS(type);
+  if (TREE_CODE(type) == ADDR_EXPR)
+    type = TREE_OPERAND(type, 0);
+  return TreeConstantToLLVM::EmitLV(type);
+}
+
 /// getExceptionPtr - Return the local holding the exception pointer for the
 /// given exception handling region, creating it if necessary.
 AllocaInst *TreeToLLVM::getExceptionPtr(unsigned RegionNo) {
@@ -2062,8 +2075,7 @@
         AllCaught = true;
         for (tree type = region->u.allowed.type_list; type;
              type = TREE_CHAIN(type)) {
-          tree value = lookup_type_for_runtime(TREE_VALUE(type));
-          Constant *TypeInfo = TreeConstantToLLVM::Convert(value);
+          Constant *TypeInfo = ConvertTypeInfo(TREE_VALUE(type));
           // No point in permitting a typeinfo to be thrown if we know it can
           // never reach the filter.
           if (AlreadyCaught.count(TypeInfo))
@@ -2095,8 +2107,7 @@
           } else {
             // Add the type infos.
             for (tree type = c->type_list; type; type = TREE_CHAIN(type)) {
-              tree value = lookup_type_for_runtime(TREE_VALUE(type));
-              Constant *TypeInfo = TreeConstantToLLVM::Convert(value);
+              Constant *TypeInfo = ConvertTypeInfo(TREE_VALUE(type));
               // No point in trying to catch a typeinfo that was already caught.
               if (!AlreadyCaught.insert(TypeInfo))
                 continue;
@@ -7364,8 +7375,7 @@
 
       Value *Cond = NULL;
       for (tree type = c->type_list; type; type = TREE_CHAIN (type)) {
-        tree value = lookup_type_for_runtime(TREE_VALUE(type));
-        Value *TypeInfo = TreeConstantToLLVM::Convert(value);
+        Value *TypeInfo = ConvertTypeInfo(TREE_VALUE(type));
         // No point in trying to catch a typeinfo that was already caught.
         if (!AlreadyCaught.insert(TypeInfo))
           continue;





More information about the llvm-commits mailing list