================ @@ -46,21 +52,124 @@ void CIRGenFunction::emitAutoVarAlloca(const VarDecl &d) { address = createTempAlloca(allocaTy, alignment, loc, d.getName()); declare(address.getPointer(), &d, ty, getLoc(d.getSourceRange()), alignment); + emission.Addr = address; setAddrOfLocalVar(&d, address); + + return emission; +} + +/// Determine whether the given initializer is trivial in the sense +/// that it requires no code to be generated. +bool CIRGenFunction::isTrivialInitializer(const Expr *init) { + if (!init) + return true; + + if (const CXXConstructExpr *construct = dyn_cast<CXXConstructExpr>(init)) + if (CXXConstructorDecl *constructor = construct->getConstructor()) + if (constructor->isTrivial() && constructor->isDefaultConstructor() && + !construct->requiresZeroInitialization()) + return true; + + return false; } -void CIRGenFunction::emitAutoVarInit(const clang::VarDecl &d) { +void CIRGenFunction::emitAutoVarInit( + const CIRGenFunction::AutoVarEmission &emission) { + const VarDecl &d = *emission.Variable; + ---------------- xlauko wrote:
Corresponding `CodeGenFunction::EmitAutoVarInit` has here: ``` // If this was emitted as a global constant, we're done. if (emission.wasEmittedAsGlobal()) return; ``` is there any reason why this is not here for CIR? https://github.com/llvm/llvm-project/pull/130164 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits