[llvm] Module::getOrInsertFunction: set debug info format (PR #82505)

Harald van Dijk via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 21 08:29:10 PST 2024


https://github.com/hvdijk created https://github.com/llvm/llvm-project/pull/82505

Function::Function's constructor sets the debug info format based on the passed in parent Module, so by using this rather than modifying the function list directly, we pick up the debug info format automatically.

>From 467f4ca42ca6192cdb22b8f693507e502a4f50a7 Mon Sep 17 00:00:00 2001
From: Harald van Dijk <harald at gigawatt.nl>
Date: Wed, 21 Feb 2024 14:54:07 +0000
Subject: [PATCH] Module::getOrInsertFunction: set debug info format

Function::Function's constructor sets the debug info format based on the
passed in parent Module, so by using this rather than modifying the
function list directly, we pick up the debug info format automatically.
---
 llvm/lib/IR/Module.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index eeb90a6cb3c465..1946db2ee0be7e 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -149,10 +149,9 @@ FunctionCallee Module::getOrInsertFunction(StringRef Name, FunctionType *Ty,
   if (!F) {
     // Nope, add it
     Function *New = Function::Create(Ty, GlobalVariable::ExternalLinkage,
-                                     DL.getProgramAddressSpace(), Name);
+                                     DL.getProgramAddressSpace(), Name, this);
     if (!New->isIntrinsic())       // Intrinsics get attrs set on construction
       New->setAttributes(AttributeList);
-    FunctionList.push_back(New);
     return {Ty, New}; // Return the new prototype.
   }
 



More information about the llvm-commits mailing list