mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 16:11:08 +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) {
|
const char *name) {
|
||||||
checkForImplicitGCCall(loc, name);
|
checkForImplicitGCCall(loc, name);
|
||||||
|
|
||||||
if (!M) {
|
if (!M)
|
||||||
initRuntime();
|
initRuntime();
|
||||||
}
|
|
||||||
|
|
||||||
LLFunction *fn = target.getFunction(name);
|
LLFunction *fn = M->getFunction(name);
|
||||||
if (fn) {
|
|
||||||
return fn;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn = M->getFunction(name);
|
|
||||||
if (!fn) {
|
if (!fn) {
|
||||||
error(loc, "Runtime function '%s' was not found", name);
|
error(loc, "Runtime function '%s' was not found", name);
|
||||||
fatal();
|
fatal();
|
||||||
}
|
}
|
||||||
|
|
||||||
LLFunctionType *fnty = fn->getFunctionType();
|
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 =
|
LLFunction *resfn =
|
||||||
llvm::cast<llvm::Function>(target.getOrInsertFunction(name, fnty));
|
llvm::cast<llvm::Function>(target.getOrInsertFunction(name, fnty));
|
||||||
resfn->setAttributes(fn->getAttributes());
|
resfn->setAttributes(fn->getAttributes());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue