[llvm-commits] [llvm] r52319 - in /llvm/trunk: include/llvm/Analysis/ValueTracking.h lib/Analysis/ValueTracking.cpp

Matthijs Kooijman matthijs at stdin.nl
Mon Jun 16 06:28:31 PDT 2008


Author: matthijs
Date: Mon Jun 16 08:28:31 2008
New Revision: 52319

URL: http://llvm.org/viewvc/llvm-project?rev=52319&view=rev
Log:
Make the InsertBefore argument to FindInsertedValue optional, so you can find an inserted value without modifying the code.

Modified:
    llvm/trunk/include/llvm/Analysis/ValueTracking.h
    llvm/trunk/lib/Analysis/ValueTracking.cpp

Modified: llvm/trunk/include/llvm/Analysis/ValueTracking.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ValueTracking.h?rev=52319&r1=52318&r2=52319&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Analysis/ValueTracking.h (original)
+++ llvm/trunk/include/llvm/Analysis/ValueTracking.h Mon Jun 16 08:28:31 2008
@@ -55,10 +55,13 @@
   /// FindScalarValue - Given an aggregrate and an sequence of indices, see if the
   /// scalar value indexed is already around as a register, for example if it were
   /// inserted directly into the aggregrate.
+  ///
+  /// If InsertBefore is not null, this function will duplicate (modified)
+  /// insertvalues when a part of a nested struct is extracted.
   Value *FindInsertedValue(Value *V,
                          const unsigned *idx_begin,
                          const unsigned *idx_end,
-                         Instruction *InsertBefore);
+                         Instruction *InsertBefore = 0);
 } // end namespace llvm
 
 #endif

Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=52319&r1=52318&r2=52319&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Jun 16 08:28:31 2008
@@ -805,6 +805,7 @@
 // Any inserted instructions are inserted before InsertBefore
 Value *BuildSubAggregate(Value *From, const unsigned *idx_begin,
                          const unsigned *idx_end, Instruction *InsertBefore) {
+  assert(InsertBefore && "Must have someplace to insert!");
   const Type *IndexedType = ExtractValueInst::getIndexedType(From->getType(),
                                                              idx_begin,
                                                              idx_end);
@@ -851,9 +852,13 @@
     for (const unsigned *i = I->idx_begin(), *e = I->idx_end();
          i != e; ++i, ++req_idx) {
       if (req_idx == idx_end)
-        // The requested index is a part of a nested aggregate. Handle this
-        // specially.
-        return BuildSubAggregate(V, idx_begin, req_idx, InsertBefore);
+        if (InsertBefore)
+          // The requested index is a part of a nested aggregate. Handle this
+          // specially.
+          return BuildSubAggregate(V, idx_begin, req_idx, InsertBefore);
+        else
+          // We can't handle this without inserting insertvalues
+          return 0;
       
       // This insert value inserts something else than what we are looking for.
       // See if the (aggregrate) value inserted into has the value we are





More information about the llvm-commits mailing list