[llvm-commits] CVS: llvm/lib/Reoptimizer/Inst/lib/Phases.cpp SparcInstManip.cpp SparcInstManip.h

Joel Stanley jstanley at cs.uiuc.edu
Tue May 13 14:44:47 PDT 2003


Changes in directory llvm/lib/Reoptimizer/Inst/lib:

Phases.cpp updated: 1.29 -> 1.30
SparcInstManip.cpp updated: 1.9 -> 1.10
SparcInstManip.h updated: 1.10 -> 1.11

---
Log message:

Old alloca-finding code removed; code cleanup.


---
Diffs of the changes:

Index: llvm/lib/Reoptimizer/Inst/lib/Phases.cpp
diff -u llvm/lib/Reoptimizer/Inst/lib/Phases.cpp:1.29 llvm/lib/Reoptimizer/Inst/lib/Phases.cpp:1.30
--- llvm/lib/Reoptimizer/Inst/lib/Phases.cpp:1.29	Tue May 13 13:36:33 2003
+++ llvm/lib/Reoptimizer/Inst/lib/Phases.cpp	Tue May 13 14:43:02 2003
@@ -347,7 +347,7 @@
         copySnippetToSlot(snippet, slotBase, m_pTC->getVM(), m_pIM);
 
         // just one candidate for now
-        //break;
+        break;
     }
 }
 
@@ -518,5 +518,5 @@
         }
     }
 
-    DEBUG_MSG(1, "--- phase 5 invocation completed ---\n");
+    DEBUG_MSG(1, "--- phase 5 invocation completed ---\n" << std::flush);
 }


Index: llvm/lib/Reoptimizer/Inst/lib/SparcInstManip.cpp
diff -u llvm/lib/Reoptimizer/Inst/lib/SparcInstManip.cpp:1.9 llvm/lib/Reoptimizer/Inst/lib/SparcInstManip.cpp:1.10
--- llvm/lib/Reoptimizer/Inst/lib/SparcInstManip.cpp:1.9	Tue May 13 13:36:33 2003
+++ llvm/lib/Reoptimizer/Inst/lib/SparcInstManip.cpp	Tue May 13 14:43:02 2003
@@ -843,85 +843,3 @@
 
     return 0;
 }
-
-bool SparcInstManip::isAllocaSignature(unsigned inst, unsigned& offset)
-{
-    if(RD_FLD(inst, INSTR_OP) == OP_2 &&
-       RD_FLD(inst, INSTR_OP3) == OP3_ADD &&
-       RD_FLD(inst, INSTR_I) == 1 &&
-       RD_FLD(inst, INSTR_RS1) == R_O6 && // Src == %sp
-       RD_FLD(inst, INSTR_RD) != R_O6) {  // Target != %sp
-
-        // Examine the immediate value and determine if it falls into one of the two
-        // special cases, with an as-yet-unimplemented fallback (TODO).  Stack addresses
-        // must be multiples of STACK_ALIGN (16 for SparcV9). We also know that the alloca
-        // we are concerned about is always of size STACK_ALIGN (the minimum size). The
-        // compiler generates an a value v = (immediate value - BIAS) such that
-        // 
-        //   a) v is a multiple of STACK_ALIGN -or-
-        //   b) v - STACK_ALIGN + 1 is a multiple of STACK_ALIGN
-        //
-        // This is gross and hackish but it'll do for the time being.
-
-        unsigned imm = RD_FLD(inst, INSTR_SIMM13);
-
-        if(0 == (imm - BIAS) % STACK_ALIGN) {
-            offset = imm - BIAS;
-            DEBUG_MSG(1, "Alloca marker case (a)\n");
-        }
-        else if(0 == (imm - BIAS - STACK_ALIGN + 1) % STACK_ALIGN) {
-            offset = imm - BIAS - STACK_ALIGN + 1;
-            DEBUG_MSG(1, "Alloca marker case (b)\n");
-        }
-        else
-            assert(0 && "Alloca special cases failed, need fallback implementation");
-
-        DEBUG_MSG(1, "Found alloca marker: ");
-#if VERBOSE > 0
-        sparc_print(inst);
-        fflush(stdout);
-#endif
-        DEBUG_MSG(1, endl);
-
-        return true;
-    }
-    
-    return false;
-}
-
-unsigned SparcInstManip::findAllocaOffset(uint64_t instAddr,
-                                          const std::pair<uint64_t, uint64_t>& range)
-{
-    // Search around the vicinity of instAddr, looking for the alloca instance (more
-    // specifically, the "second" part of the alloca -- the add of the "magic" offset to
-    // the stack pointer with a non-SP destination reg) that *must* exist if Phase 1
-    // worked properly (introduced an immutable alloca).  Unfortunately, we cannot
-    // guarantee instruction ordering, so we have to search both forwards and backwards,
-    // within the bounds of the function.
-
-    uint64_t curr;
-
-    // Search backwards from SEARCH_DELTA instructions beyond the instrumentation site (or
-    // the end of the function, whichever is closer).  We start ahead by SEARCH_DELTA to
-    // catch the common case where the instruction we are looking for occurs very soon
-    // after the instrumentation site.
-
-    curr = std::min<uint64_t>(instAddr + SEARCH_DELTA * getInstWidth(), range.second);
-    for( ; curr >= range.first; curr -= getInstWidth()) {
-        unsigned inst = m_pTC->getVM()->readInstrFrmVm(curr);
-        unsigned offset;
-        if(isAllocaSignature(inst, offset))
-            return offset;
-    }
-
-    // Forwards from instrumentation site to function end
-    for(curr = instAddr + getInstWidth(); curr <= range.second; curr += getInstWidth()) {
-        unsigned inst = m_pTC->getVM()->readInstrFrmVm(curr);
-        unsigned offset;
-        if(isAllocaSignature(inst, offset))
-            return offset;
-    }
-
-    assert(0 && "Failed to find alloca marker");
-    return 0;
-}


Index: llvm/lib/Reoptimizer/Inst/lib/SparcInstManip.h
diff -u llvm/lib/Reoptimizer/Inst/lib/SparcInstManip.h:1.10 llvm/lib/Reoptimizer/Inst/lib/SparcInstManip.h:1.11
--- llvm/lib/Reoptimizer/Inst/lib/SparcInstManip.h:1.10	Tue May 13 13:36:34 2003
+++ llvm/lib/Reoptimizer/Inst/lib/SparcInstManip.h	Tue May 13 14:43:03 2003
@@ -109,11 +109,6 @@
                                       uint64_t end,
                                       unsigned fpOffset);
 
-    unsigned        findAllocaOffset(uint64_t instAddr,
-                                     const std::pair<uint64_t, uint64_t>& range);
-
-    static bool     isAllocaSignature(unsigned inst, unsigned& offset);
-
     std::vector<unsigned>* m_pCurrSnippet;
     GBTStackMap            m_gbtStackMap;        // Maps GBTElem* -> param address stack
     OutputToInputRegMap    m_outputToInputReg;   // Maps input register -> output register





More information about the llvm-commits mailing list