summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/bugpoint/Miscompilation.cpp5
-rw-r--r--llvm/tools/lli/lli.cpp30
2 files changed, 19 insertions, 16 deletions
diff --git a/llvm/tools/bugpoint/Miscompilation.cpp b/llvm/tools/bugpoint/Miscompilation.cpp
index 2ac4fe774f4..c67d38fb5a6 100644
--- a/llvm/tools/bugpoint/Miscompilation.cpp
+++ b/llvm/tools/bugpoint/Miscompilation.cpp
@@ -826,13 +826,14 @@ CleanupAndPrepareModules(BugDriver &BD, std::unique_ptr<Module> Test,
// Add the resolver to the Safe module.
// Prototype: void *getPointerToNamedFunction(const char* Name)
- Constant *resolverFunc = Safe->getOrInsertFunction(
+ FunctionCallee resolverFunc = Safe->getOrInsertFunction(
"getPointerToNamedFunction", Type::getInt8PtrTy(Safe->getContext()),
Type::getInt8PtrTy(Safe->getContext()));
// Use the function we just added to get addresses of functions we need.
for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) {
- if (F->isDeclaration() && !F->use_empty() && &*F != resolverFunc &&
+ if (F->isDeclaration() && !F->use_empty() &&
+ &*F != resolverFunc.getCallee() &&
!F->isIntrinsic() /* ignore intrinsics */) {
Function *TestFn = Test->getFunction(F->getName());
diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index d7b9368a327..36d7d98265e 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -595,8 +595,8 @@ int main(int argc, char **argv, char * const *envp) {
if (!RemoteMCJIT) {
// If the program doesn't explicitly call exit, we will need the Exit
// function later on to make an explicit call, so get the function now.
- Constant *Exit = Mod->getOrInsertFunction("exit", Type::getVoidTy(Context),
- Type::getInt32Ty(Context));
+ FunctionCallee Exit = Mod->getOrInsertFunction(
+ "exit", Type::getVoidTy(Context), Type::getInt32Ty(Context));
// Run static constructors.
if (!ForceInterpreter) {
@@ -620,19 +620,21 @@ int main(int argc, char **argv, char * const *envp) {
// If the program didn't call exit explicitly, we should call it now.
// This ensures that any atexit handlers get called correctly.
- if (Function *ExitF = dyn_cast<Function>(Exit)) {
- std::vector<GenericValue> Args;
- GenericValue ResultGV;
- ResultGV.IntVal = APInt(32, Result);
- Args.push_back(ResultGV);
- EE->runFunction(ExitF, Args);
- WithColor::error(errs(), argv[0]) << "exit(" << Result << ") returned!\n";
- abort();
- } else {
- WithColor::error(errs(), argv[0])
- << "exit defined with wrong prototype!\n";
- abort();
+ if (Function *ExitF =
+ dyn_cast<Function>(Exit.getCallee()->stripPointerCasts())) {
+ if (ExitF->getFunctionType() == Exit.getFunctionType()) {
+ std::vector<GenericValue> Args;
+ GenericValue ResultGV;
+ ResultGV.IntVal = APInt(32, Result);
+ Args.push_back(ResultGV);
+ EE->runFunction(ExitF, Args);
+ WithColor::error(errs(), argv[0])
+ << "exit(" << Result << ") returned!\n";
+ abort();
+ }
}
+ WithColor::error(errs(), argv[0]) << "exit defined with wrong prototype!\n";
+ abort();
} else {
// else == "if (RemoteMCJIT)"
OpenPOWER on IntegriCloud