llvm-project/clang/lib/CIR/CodeGen/CIRGenDeclCXX.cpp
Andy Kaylor ca84f2aa3b
[CIR] Upstream support for generating global ctor regions (#161298)
This adds support for handling global variables with non-trivial
constructors. The constructor call is emitted in CIR as a 'ctor' region
associated with the global definition. This form of global definition
cannot be lowered to LLVM IR yet.

A later change will add support in LoweringPrepare to move the ctor code
into a __cxx_global_var_init() function and add that function to the
list of global global ctors, but for now we must stop at the initial CIR
generation.
2025-09-30 14:20:13 -07:00

29 lines
1.0 KiB
C++

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This contains code dealing with code generation of C++ declarations
//
//===----------------------------------------------------------------------===//
#include "CIRGenModule.h"
#include "clang/AST/Attr.h"
#include "clang/Basic/LangOptions.h"
using namespace clang;
using namespace clang::CIRGen;
void CIRGenModule::emitCXXGlobalVarDeclInitFunc(const VarDecl *vd,
cir::GlobalOp addr,
bool performInit) {
assert(!cir::MissingFeatures::cudaSupport());
assert(!cir::MissingFeatures::deferredCXXGlobalInit());
emitCXXGlobalVarDeclInit(vd, addr, performInit);
}