mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-16 15:08:59 +00:00
Cleanup more unreferenced MutexGuard parameters on functions.
These parameters are intended to serve as sort of a contract that you cannot access the functions outside of a mutex. However, the entire JIT class cannot be accessed outside of a mutex anyway, and all methods acquire a lock as soon as they are entered. Since the containing class already is not intended to be thread-safe, it only serves to add code clutter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211071 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4641b6b427
commit
298ff80849
@ -151,7 +151,7 @@ JIT::JIT(Module *M, TargetMachine &tm, TargetJITInfo &tji,
|
|||||||
|
|
||||||
// Add target data
|
// Add target data
|
||||||
MutexGuard locked(lock);
|
MutexGuard locked(lock);
|
||||||
FunctionPassManager &PM = jitstate->getPM(locked);
|
FunctionPassManager &PM = jitstate->getPM();
|
||||||
M->setDataLayout(TM.getDataLayout());
|
M->setDataLayout(TM.getDataLayout());
|
||||||
PM.add(new DataLayoutPass(M));
|
PM.add(new DataLayoutPass(M));
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ void JIT::addModule(Module *M) {
|
|||||||
|
|
||||||
jitstate = new JITState(M);
|
jitstate = new JITState(M);
|
||||||
|
|
||||||
FunctionPassManager &PM = jitstate->getPM(locked);
|
FunctionPassManager &PM = jitstate->getPM();
|
||||||
M->setDataLayout(TM.getDataLayout());
|
M->setDataLayout(TM.getDataLayout());
|
||||||
PM.add(new DataLayoutPass(M));
|
PM.add(new DataLayoutPass(M));
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ bool JIT::removeModule(Module *M) {
|
|||||||
if (!jitstate && !Modules.empty()) {
|
if (!jitstate && !Modules.empty()) {
|
||||||
jitstate = new JITState(Modules[0]);
|
jitstate = new JITState(Modules[0]);
|
||||||
|
|
||||||
FunctionPassManager &PM = jitstate->getPM(locked);
|
FunctionPassManager &PM = jitstate->getPM();
|
||||||
M->setDataLayout(TM.getDataLayout());
|
M->setDataLayout(TM.getDataLayout());
|
||||||
PM.add(new DataLayoutPass(M));
|
PM.add(new DataLayoutPass(M));
|
||||||
|
|
||||||
@ -460,41 +460,41 @@ void JIT::runJITOnFunction(Function *F, MachineCodeInfo *MCI) {
|
|||||||
if (MCI)
|
if (MCI)
|
||||||
RegisterJITEventListener(&MCIL);
|
RegisterJITEventListener(&MCIL);
|
||||||
|
|
||||||
runJITOnFunctionUnlocked(F, locked);
|
runJITOnFunctionUnlocked(F);
|
||||||
|
|
||||||
if (MCI)
|
if (MCI)
|
||||||
UnregisterJITEventListener(&MCIL);
|
UnregisterJITEventListener(&MCIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JIT::runJITOnFunctionUnlocked(Function *F, const MutexGuard &locked) {
|
void JIT::runJITOnFunctionUnlocked(Function *F) {
|
||||||
assert(!isAlreadyCodeGenerating && "Error: Recursive compilation detected!");
|
assert(!isAlreadyCodeGenerating && "Error: Recursive compilation detected!");
|
||||||
|
|
||||||
jitTheFunction(F, locked);
|
jitTheFunctionUnlocked(F);
|
||||||
|
|
||||||
// If the function referred to another function that had not yet been
|
// If the function referred to another function that had not yet been
|
||||||
// read from bitcode, and we are jitting non-lazily, emit it now.
|
// read from bitcode, and we are jitting non-lazily, emit it now.
|
||||||
while (!jitstate->getPendingFunctions(locked).empty()) {
|
while (!jitstate->getPendingFunctions().empty()) {
|
||||||
Function *PF = jitstate->getPendingFunctions(locked).back();
|
Function *PF = jitstate->getPendingFunctions().back();
|
||||||
jitstate->getPendingFunctions(locked).pop_back();
|
jitstate->getPendingFunctions().pop_back();
|
||||||
|
|
||||||
assert(!PF->hasAvailableExternallyLinkage() &&
|
assert(!PF->hasAvailableExternallyLinkage() &&
|
||||||
"Externally-defined function should not be in pending list.");
|
"Externally-defined function should not be in pending list.");
|
||||||
|
|
||||||
jitTheFunction(PF, locked);
|
jitTheFunctionUnlocked(PF);
|
||||||
|
|
||||||
// Now that the function has been jitted, ask the JITEmitter to rewrite
|
// Now that the function has been jitted, ask the JITEmitter to rewrite
|
||||||
// the stub with real address of the function.
|
// the stub with real address of the function.
|
||||||
updateFunctionStub(PF);
|
updateFunctionStubUnlocked(PF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JIT::jitTheFunction(Function *F, const MutexGuard &locked) {
|
void JIT::jitTheFunctionUnlocked(Function *F) {
|
||||||
isAlreadyCodeGenerating = true;
|
isAlreadyCodeGenerating = true;
|
||||||
jitstate->getPM(locked).run(*F);
|
jitstate->getPM().run(*F);
|
||||||
isAlreadyCodeGenerating = false;
|
isAlreadyCodeGenerating = false;
|
||||||
|
|
||||||
// clear basic block addresses after this function is done
|
// clear basic block addresses after this function is done
|
||||||
getBasicBlockAddressMap(locked).clear();
|
getBasicBlockAddressMap().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getPointerToFunction - This method is used to get the address of the
|
/// getPointerToFunction - This method is used to get the address of the
|
||||||
@ -526,7 +526,7 @@ void *JIT::getPointerToFunction(Function *F) {
|
|||||||
return Addr;
|
return Addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
runJITOnFunctionUnlocked(F, locked);
|
runJITOnFunctionUnlocked(F);
|
||||||
|
|
||||||
void *Addr = getPointerToGlobalIfAvailable(F);
|
void *Addr = getPointerToGlobalIfAvailable(F);
|
||||||
assert(Addr && "Code generation didn't add function to GlobalAddress table!");
|
assert(Addr && "Code generation didn't add function to GlobalAddress table!");
|
||||||
@ -537,9 +537,9 @@ void JIT::addPointerToBasicBlock(const BasicBlock *BB, void *Addr) {
|
|||||||
MutexGuard locked(lock);
|
MutexGuard locked(lock);
|
||||||
|
|
||||||
BasicBlockAddressMapTy::iterator I =
|
BasicBlockAddressMapTy::iterator I =
|
||||||
getBasicBlockAddressMap(locked).find(BB);
|
getBasicBlockAddressMap().find(BB);
|
||||||
if (I == getBasicBlockAddressMap(locked).end()) {
|
if (I == getBasicBlockAddressMap().end()) {
|
||||||
getBasicBlockAddressMap(locked)[BB] = Addr;
|
getBasicBlockAddressMap()[BB] = Addr;
|
||||||
} else {
|
} else {
|
||||||
// ignore repeats: some BBs can be split into few MBBs?
|
// ignore repeats: some BBs can be split into few MBBs?
|
||||||
}
|
}
|
||||||
@ -547,7 +547,7 @@ void JIT::addPointerToBasicBlock(const BasicBlock *BB, void *Addr) {
|
|||||||
|
|
||||||
void JIT::clearPointerToBasicBlock(const BasicBlock *BB) {
|
void JIT::clearPointerToBasicBlock(const BasicBlock *BB) {
|
||||||
MutexGuard locked(lock);
|
MutexGuard locked(lock);
|
||||||
getBasicBlockAddressMap(locked).erase(BB);
|
getBasicBlockAddressMap().erase(BB);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *JIT::getPointerToBasicBlock(BasicBlock *BB) {
|
void *JIT::getPointerToBasicBlock(BasicBlock *BB) {
|
||||||
@ -558,8 +558,8 @@ void *JIT::getPointerToBasicBlock(BasicBlock *BB) {
|
|||||||
MutexGuard locked(lock);
|
MutexGuard locked(lock);
|
||||||
|
|
||||||
BasicBlockAddressMapTy::iterator I =
|
BasicBlockAddressMapTy::iterator I =
|
||||||
getBasicBlockAddressMap(locked).find(BB);
|
getBasicBlockAddressMap().find(BB);
|
||||||
if (I != getBasicBlockAddressMap(locked).end()) {
|
if (I != getBasicBlockAddressMap().end()) {
|
||||||
return I->second;
|
return I->second;
|
||||||
} else {
|
} else {
|
||||||
llvm_unreachable("JIT does not have BB address for address-of-label, was"
|
llvm_unreachable("JIT does not have BB address for address-of-label, was"
|
||||||
@ -688,7 +688,7 @@ char* JIT::getMemoryForGV(const GlobalVariable* GV) {
|
|||||||
|
|
||||||
void JIT::addPendingFunction(Function *F) {
|
void JIT::addPendingFunction(Function *F) {
|
||||||
MutexGuard locked(lock);
|
MutexGuard locked(lock);
|
||||||
jitstate->getPendingFunctions(locked).push_back(F);
|
jitstate->getPendingFunctions().push_back(F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,12 +39,12 @@ private:
|
|||||||
public:
|
public:
|
||||||
explicit JITState(Module *M) : PM(M), M(M) {}
|
explicit JITState(Module *M) : PM(M), M(M) {}
|
||||||
|
|
||||||
FunctionPassManager &getPM(const MutexGuard &L) {
|
FunctionPassManager &getPM() {
|
||||||
return PM;
|
return PM;
|
||||||
}
|
}
|
||||||
|
|
||||||
Module *getModule() const { return M; }
|
Module *getModule() const { return M; }
|
||||||
std::vector<AssertingVH<Function> > &getPendingFunctions(const MutexGuard &L){
|
std::vector<AssertingVH<Function> > &getPendingFunctions() {
|
||||||
return PendingFunctions;
|
return PendingFunctions;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -205,7 +205,7 @@ public:
|
|||||||
void NotifyFreeingMachineCode(void *OldPtr);
|
void NotifyFreeingMachineCode(void *OldPtr);
|
||||||
|
|
||||||
BasicBlockAddressMapTy &
|
BasicBlockAddressMapTy &
|
||||||
getBasicBlockAddressMap(const MutexGuard &) {
|
getBasicBlockAddressMap() {
|
||||||
return BasicBlockAddressMap;
|
return BasicBlockAddressMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,9 +213,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
static JITCodeEmitter *createEmitter(JIT &J, JITMemoryManager *JMM,
|
static JITCodeEmitter *createEmitter(JIT &J, JITMemoryManager *JMM,
|
||||||
TargetMachine &tm);
|
TargetMachine &tm);
|
||||||
void runJITOnFunctionUnlocked(Function *F, const MutexGuard &locked);
|
void runJITOnFunctionUnlocked(Function *F);
|
||||||
void updateFunctionStub(Function *F);
|
void updateFunctionStubUnlocked(Function *F);
|
||||||
void jitTheFunction(Function *F, const MutexGuard &locked);
|
void jitTheFunctionUnlocked(Function *F);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -1236,7 +1236,7 @@ void *JIT::getPointerToFunctionOrStub(Function *F) {
|
|||||||
return JE->getJITResolver().getLazyFunctionStub(F);
|
return JE->getJITResolver().getLazyFunctionStub(F);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JIT::updateFunctionStub(Function *F) {
|
void JIT::updateFunctionStubUnlocked(Function *F) {
|
||||||
// Get the empty stub we generated earlier.
|
// Get the empty stub we generated earlier.
|
||||||
JITEmitter *JE = static_cast<JITEmitter*>(getCodeEmitter());
|
JITEmitter *JE = static_cast<JITEmitter*>(getCodeEmitter());
|
||||||
void *Stub = JE->getJITResolver().getLazyFunctionStub(F);
|
void *Stub = JE->getJITResolver().getLazyFunctionStub(F);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user