mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-01 23:50:43 +03:00
Revert "Revert "Check existing runtime function declarations for matching type""
This reverts commit 2de6538241
.
This commit is contained in:
parent
bb2b648d8e
commit
d7b45f7c7d
1 changed files with 11 additions and 9 deletions
|
@ -127,22 +127,24 @@ llvm::Function *getRuntimeFunction(const Loc &loc, llvm::Module &target,
|
|||
const char *name) {
|
||||
checkForImplicitGCCall(loc, name);
|
||||
|
||||
if (!M) {
|
||||
if (!M)
|
||||
initRuntime();
|
||||
}
|
||||
|
||||
LLFunction *fn = target.getFunction(name);
|
||||
if (fn) {
|
||||
return fn;
|
||||
}
|
||||
|
||||
fn = M->getFunction(name);
|
||||
LLFunction *fn = M->getFunction(name);
|
||||
if (!fn) {
|
||||
error(loc, "Runtime function '%s' was not found", name);
|
||||
fatal();
|
||||
}
|
||||
|
||||
LLFunctionType *fnty = fn->getFunctionType();
|
||||
|
||||
if (LLFunction *existing = target.getFunction(name)) {
|
||||
if (existing->getFunctionType() != fnty) {
|
||||
error(Loc(), "Incompatible declaration of runtime function '%s'", name);
|
||||
fatal();
|
||||
}
|
||||
return existing;
|
||||
}
|
||||
|
||||
LLFunction *resfn =
|
||||
llvm::cast<llvm::Function>(target.getOrInsertFunction(name, fnty));
|
||||
resfn->setAttributes(fn->getAttributes());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue