From: Zack Rusin Date: Fri, 26 Oct 2007 23:12:02 +0000 (-0400) Subject: Hold a stack of temporaries so that we can redeclare them X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=789d248558061fe4d65f664d6770a12b90fa2e34;p=mesa.git Hold a stack of temporaries so that we can redeclare them for all defined functions. Fixes crashes in function calls. --- diff --git a/src/mesa/pipe/llvm/llvmtgsi.cpp b/src/mesa/pipe/llvm/llvmtgsi.cpp index cfeb19e4ba8..af602326ae6 100644 --- a/src/mesa/pipe/llvm/llvmtgsi.cpp +++ b/src/mesa/pipe/llvm/llvmtgsi.cpp @@ -508,19 +508,21 @@ translate_instruction(llvm::Module *module, case TGSI_OPCODE_BGNSUB: { instr->bgnSub(instno, storage); storage->setCurrentBlock(instr->currentBlock()); + storage->pushTemps(); return; } break; case TGSI_OPCODE_ENDLOOP2: { instr->endLoop(); storage->setCurrentBlock(instr->currentBlock()); - storage->popArguments(); return; } break; case TGSI_OPCODE_ENDSUB: { instr->endSub(); storage->setCurrentBlock(instr->currentBlock()); + storage->popArguments(); + storage->popTemps(); return; } break; diff --git a/src/mesa/pipe/llvm/storage.cpp b/src/mesa/pipe/llvm/storage.cpp index 88ef6711cfb..7300cdfef06 100644 --- a/src/mesa/pipe/llvm/storage.cpp +++ b/src/mesa/pipe/llvm/storage.cpp @@ -369,3 +369,24 @@ void Storage::popArguments() m_CONST = arg.cst; m_argStack.pop(); } + +void Storage::pushTemps() +{ + m_tempStack.push(m_temps); + std::vector oldTemps = m_temps; + m_temps = std::vector(32); + int i = 0; + for (std::vector::iterator itr = oldTemps.begin(); + itr != oldTemps.end(); ++itr) { + if (*itr) { + declareTemp(i); + } + ++i; + } +} + +void Storage::popTemps() +{ + m_temps = m_tempStack.top(); + m_tempStack.pop(); +} diff --git a/src/mesa/pipe/llvm/storage.h b/src/mesa/pipe/llvm/storage.h index b8d6eb06049..eeadaa0506a 100644 --- a/src/mesa/pipe/llvm/storage.h +++ b/src/mesa/pipe/llvm/storage.h @@ -84,6 +84,8 @@ public: void pushArguments(llvm::Value *out, llvm::Value *in, llvm::Value *constPtr); void popArguments(); + void pushTemps(); + void popTemps(); private: llvm::Value *maskWrite(llvm::Value *src, int mask, llvm::Value *templ); @@ -122,6 +124,7 @@ private: llvm::Value *cst; }; std::stack m_argStack; + std::stack > m_tempStack; }; #endif