From: Vassil Vassilev Date: Thu, 27 Oct 2016 09:12:20 +0000 (+0000) Subject: Empty the CtorLists/DtorLists once emitted. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=926caf25d5ae278d9570309e562133a970cc80db;p=clang Empty the CtorLists/DtorLists once emitted. This is essential when clang is running in incremental processing mode because we don't want to reemit the 'tors over and over again. Patch by Axel Naumann! Reviewed by Richard Smith and me. (https://reviews.llvm.org/D25605) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285277 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 21849590b1..81d9ead3d1 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -721,7 +721,7 @@ void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority) { GlobalDtors.push_back(Structor(Priority, Dtor, nullptr)); } -void CodeGenModule::EmitCtorList(const CtorList &Fns, const char *GlobalName) { +void CodeGenModule::EmitCtorList(CtorList &Fns, const char *GlobalName) { // Ctor function type is void()*. llvm::FunctionType* CtorFTy = llvm::FunctionType::get(VoidTy, false); llvm::Type *CtorPFTy = llvm::PointerType::getUnqual(CtorFTy); @@ -749,6 +749,7 @@ void CodeGenModule::EmitCtorList(const CtorList &Fns, const char *GlobalName) { llvm::ConstantArray::get(AT, Ctors), GlobalName); } + Fns.clear(); } llvm::GlobalValue::LinkageTypes diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index 30ccae648a..bdd2026db2 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -1209,10 +1209,10 @@ private: llvm::Constant *AssociatedData = nullptr); void AddGlobalDtor(llvm::Function *Dtor, int Priority = 65535); - /// Generates a global array of functions and priorities using the given list - /// and name. This array will have appending linkage and is suitable for use - /// as a LLVM constructor or destructor array. - void EmitCtorList(const CtorList &Fns, const char *GlobalName); + /// EmitCtorList - Generates a global array of functions and priorities using + /// the given list and name. This array will have appending linkage and is + /// suitable for use as a LLVM constructor or destructor array. Clears Fns. + void EmitCtorList(CtorList &Fns, const char *GlobalName); /// Emit any needed decls for which code generation was deferred. void EmitDeferred();