forked from OSchip/llvm-project
				
			If the interpreter tries to execute an external function, kill it. Of course
since we are dirty, special case __main. This should fix the infinite loop horrible stuff that happens on linux-alpha when configuring llvm-gcc. It might also help cygwin, who knows?? llvm-svn: 19729
This commit is contained in:
		
							parent
							
								
									c78776d209
								
							
						
					
					
						commit
						28edd69eb4
					
				| 
						 | 
					@ -82,22 +82,24 @@ static ExFunc lookupFunction(const Function *F) {
 | 
				
			||||||
  return FnPtr;
 | 
					  return FnPtr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
GenericValue Interpreter::callExternalFunction(Function *M,
 | 
					GenericValue Interpreter::callExternalFunction(Function *F,
 | 
				
			||||||
                                     const std::vector<GenericValue> &ArgVals) {
 | 
					                                     const std::vector<GenericValue> &ArgVals) {
 | 
				
			||||||
  TheInterpreter = this;
 | 
					  TheInterpreter = this;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Do a lookup to see if the function is in our cache... this should just be a
 | 
					  // Do a lookup to see if the function is in our cache... this should just be a
 | 
				
			||||||
  // deferred annotation!
 | 
					  // deferred annotation!
 | 
				
			||||||
  std::map<const Function *, ExFunc>::iterator FI = Functions.find(M);
 | 
					  std::map<const Function *, ExFunc>::iterator FI = Functions.find(F);
 | 
				
			||||||
  ExFunc Fn = (FI == Functions.end()) ? lookupFunction(M) : FI->second;
 | 
					  ExFunc Fn = (FI == Functions.end()) ? lookupFunction(F) : FI->second;
 | 
				
			||||||
  if (Fn == 0) {
 | 
					  if (Fn == 0) {
 | 
				
			||||||
    std::cout << "Tried to execute an unknown external function: "
 | 
					    std::cout << "Tried to execute an unknown external function: "
 | 
				
			||||||
              << M->getType()->getDescription() << " " << M->getName() << "\n";
 | 
					              << F->getType()->getDescription() << " " << F->getName() << "\n";
 | 
				
			||||||
    return GenericValue();
 | 
					    if (F->getName() == "__main")
 | 
				
			||||||
 | 
					      return GenericValue();
 | 
				
			||||||
 | 
					    abort();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // TODO: FIXME when types are not const!
 | 
					  // TODO: FIXME when types are not const!
 | 
				
			||||||
  GenericValue Result = Fn(const_cast<FunctionType*>(M->getFunctionType()),
 | 
					  GenericValue Result = Fn(const_cast<FunctionType*>(F->getFunctionType()),
 | 
				
			||||||
                           ArgVals);
 | 
					                           ArgVals);
 | 
				
			||||||
  return Result;
 | 
					  return Result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue