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:
Zachary Turner 2014-06-16 22:41:08 +00:00
parent 4641b6b427
commit 298ff80849
3 changed files with 29 additions and 29 deletions

View File

@ -151,7 +151,7 @@ JIT::JIT(Module *M, TargetMachine &tm, TargetJITInfo &tji,
// Add target data
MutexGuard locked(lock);
FunctionPassManager &PM = jitstate->getPM(locked);
FunctionPassManager &PM = jitstate->getPM();
M->setDataLayout(TM.getDataLayout());
PM.add(new DataLayoutPass(M));
@ -184,7 +184,7 @@ void JIT::addModule(Module *M) {
jitstate = new JITState(M);
FunctionPassManager &PM = jitstate->getPM(locked);
FunctionPassManager &PM = jitstate->getPM();
M->setDataLayout(TM.getDataLayout());
PM.add(new DataLayoutPass(M));
@ -216,7 +216,7 @@ bool JIT::removeModule(Module *M) {
if (!jitstate && !Modules.empty()) {
jitstate = new JITState(Modules[0]);
FunctionPassManager &PM = jitstate->getPM(locked);
FunctionPassManager &PM = jitstate->getPM();
M->setDataLayout(TM.getDataLayout());
PM.add(new DataLayoutPass(M));
@ -460,41 +460,41 @@ void JIT::runJITOnFunction(Function *F, MachineCodeInfo *MCI) {
if (MCI)
RegisterJITEventListener(&MCIL);
runJITOnFunctionUnlocked(F, locked);
runJITOnFunctionUnlocked(F);
if (MCI)
UnregisterJITEventListener(&MCIL);
}
void JIT::runJITOnFunctionUnlocked(Function *F, const MutexGuard &locked) {
void JIT::runJITOnFunctionUnlocked(Function *F) {
assert(!isAlreadyCodeGenerating && "Error: Recursive compilation detected!");
jitTheFunction(F, locked);
jitTheFunctionUnlocked(F);
// If the function referred to another function that had not yet been
// read from bitcode, and we are jitting non-lazily, emit it now.
while (!jitstate->getPendingFunctions(locked).empty()) {
Function *PF = jitstate->getPendingFunctions(locked).back();
jitstate->getPendingFunctions(locked).pop_back();
while (!jitstate->getPendingFunctions().empty()) {
Function *PF = jitstate->getPendingFunctions().back();
jitstate->getPendingFunctions().pop_back();
assert(!PF->hasAvailableExternallyLinkage() &&
"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
// 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;
jitstate->getPM(locked).run(*F);
jitstate->getPM().run(*F);
isAlreadyCodeGenerating = false;
// 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
@ -526,7 +526,7 @@ void *JIT::getPointerToFunction(Function *F) {
return Addr;
}
runJITOnFunctionUnlocked(F, locked);
runJITOnFunctionUnlocked(F);
void *Addr = getPointerToGlobalIfAvailable(F);
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);
BasicBlockAddressMapTy::iterator I =
getBasicBlockAddressMap(locked).find(BB);
if (I == getBasicBlockAddressMap(locked).end()) {
getBasicBlockAddressMap(locked)[BB] = Addr;
getBasicBlockAddressMap().find(BB);
if (I == getBasicBlockAddressMap().end()) {
getBasicBlockAddressMap()[BB] = Addr;
} else {
// 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) {
MutexGuard locked(lock);
getBasicBlockAddressMap(locked).erase(BB);
getBasicBlockAddressMap().erase(BB);
}
void *JIT::getPointerToBasicBlock(BasicBlock *BB) {
@ -558,8 +558,8 @@ void *JIT::getPointerToBasicBlock(BasicBlock *BB) {
MutexGuard locked(lock);
BasicBlockAddressMapTy::iterator I =
getBasicBlockAddressMap(locked).find(BB);
if (I != getBasicBlockAddressMap(locked).end()) {
getBasicBlockAddressMap().find(BB);
if (I != getBasicBlockAddressMap().end()) {
return I->second;
} else {
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) {
MutexGuard locked(lock);
jitstate->getPendingFunctions(locked).push_back(F);
jitstate->getPendingFunctions().push_back(F);
}

View File

@ -39,12 +39,12 @@ private:
public:
explicit JITState(Module *M) : PM(M), M(M) {}
FunctionPassManager &getPM(const MutexGuard &L) {
FunctionPassManager &getPM() {
return PM;
}
Module *getModule() const { return M; }
std::vector<AssertingVH<Function> > &getPendingFunctions(const MutexGuard &L){
std::vector<AssertingVH<Function> > &getPendingFunctions() {
return PendingFunctions;
}
};
@ -205,7 +205,7 @@ public:
void NotifyFreeingMachineCode(void *OldPtr);
BasicBlockAddressMapTy &
getBasicBlockAddressMap(const MutexGuard &) {
getBasicBlockAddressMap() {
return BasicBlockAddressMap;
}
@ -213,9 +213,9 @@ public:
private:
static JITCodeEmitter *createEmitter(JIT &J, JITMemoryManager *JMM,
TargetMachine &tm);
void runJITOnFunctionUnlocked(Function *F, const MutexGuard &locked);
void updateFunctionStub(Function *F);
void jitTheFunction(Function *F, const MutexGuard &locked);
void runJITOnFunctionUnlocked(Function *F);
void updateFunctionStubUnlocked(Function *F);
void jitTheFunctionUnlocked(Function *F);
protected:

View File

@ -1236,7 +1236,7 @@ void *JIT::getPointerToFunctionOrStub(Function *F) {
return JE->getJITResolver().getLazyFunctionStub(F);
}
void JIT::updateFunctionStub(Function *F) {
void JIT::updateFunctionStubUnlocked(Function *F) {
// Get the empty stub we generated earlier.
JITEmitter *JE = static_cast<JITEmitter*>(getCodeEmitter());
void *Stub = JE->getJITResolver().getLazyFunctionStub(F);