[clang] [CIR] Upstream support for generating global ctor regions (PR #161298)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 30 09:06:49 PDT 2025
================
@@ -15,10 +15,72 @@
#include "clang/AST/GlobalDecl.h"
#include "clang/CIR/MissingFeatures.h"
+#include "llvm/Support/SaveAndRestore.h"
using namespace clang;
using namespace clang::CIRGen;
+static void emitDeclInit(CIRGenFunction &cgf, const VarDecl *varDecl,
+ Address declPtr) {
+ assert((varDecl->hasGlobalStorage() ||
+ (varDecl->hasLocalStorage() &&
+ cgf.getContext().getLangOpts().OpenCLCPlusPlus)) &&
+ "VarDecl must have global or local (in the case of OpenCL) storage!");
+ assert(!varDecl->getType()->isReferenceType() &&
+ "Should not call emitDeclInit on a reference!");
+
+ QualType type = varDecl->getType();
+ LValue lv = cgf.makeAddrLValue(declPtr, type);
+
+ const Expr *init = varDecl->getInit();
+ switch (CIRGenFunction::getEvaluationKind(type)) {
+ case cir::TEK_Scalar:
+ assert(!cir::MissingFeatures::objCGC());
+ cgf.emitScalarInit(init, cgf.getLoc(varDecl->getLocation()), lv, false);
+ return;
+ case cir::TEK_Complex:
+ cgf.cgm.errorNYI(varDecl->getSourceRange(), "complex global initializer");
+ return;
+ case cir::TEK_Aggregate:
+ assert(!cir::MissingFeatures::aggValueSlotGC());
+ cgf.emitAggExpr(init,
+ AggValueSlot::forLValue(lv, AggValueSlot::IsDestructed,
+ AggValueSlot::IsNotAliased,
----------------
xlauko wrote:
OGCG takes here `AggValueSlot::DoesNotNeedGCBarrier` as well.
Any reason it is missing?
https://github.com/llvm/llvm-project/pull/161298
More information about the cfe-commits
mailing list