mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 02:10:11 +01:00
Hold a stack of temporaries so that we can redeclare them
for all defined functions. Fixes crashes in function calls.
This commit is contained in:
parent
78c1f8b2de
commit
789d248558
3 changed files with 27 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -369,3 +369,24 @@ void Storage::popArguments()
|
|||
m_CONST = arg.cst;
|
||||
m_argStack.pop();
|
||||
}
|
||||
|
||||
void Storage::pushTemps()
|
||||
{
|
||||
m_tempStack.push(m_temps);
|
||||
std::vector<llvm::Value*> oldTemps = m_temps;
|
||||
m_temps = std::vector<llvm::Value*>(32);
|
||||
int i = 0;
|
||||
for (std::vector<llvm::Value*>::iterator itr = oldTemps.begin();
|
||||
itr != oldTemps.end(); ++itr) {
|
||||
if (*itr) {
|
||||
declareTemp(i);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void Storage::popTemps()
|
||||
{
|
||||
m_temps = m_tempStack.top();
|
||||
m_tempStack.pop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Args> m_argStack;
|
||||
std::stack<std::vector<llvm::Value*> > m_tempStack;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue