[pkg-d-commits] [ldc] 92/211: Revert "Revert "Check existing runtime function declarations for matching type""

Matthias Klumpp mak at moszumanska.debian.org
Sun Apr 23 22:36:13 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.1.0
in repository ldc.

commit d7b45f7c7d906d09200698399a9418aef08a774c
Author: Martin <noone at nowhere.com>
Date:   Sat Oct 15 23:30:07 2016 +0200

    Revert "Revert "Check existing runtime function declarations for matching type""
    
    This reverts commit 2de6538241c2a651b44245562a9dfd30ee16c209.
---
 gen/runtime.cpp | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/gen/runtime.cpp b/gen/runtime.cpp
index a680a9f..e83385c 100644
--- a/gen/runtime.cpp
+++ b/gen/runtime.cpp
@@ -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());

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list