Skip to content

Commit 83f7f29

Browse files
lanzaxlauko
authored andcommitted
[CIR][CodeGen] Support static references to temporaries
Pull Request: llvm/clangir#872
1 parent f998fad commit 83f7f29

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

clang/lib/CIR/CodeGen/CIRGenCXXABI.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,7 @@ class CIRGenCXXABI {
263263
/// \param Dtor - a function taking a single pointer argument
264264
/// \param Addr - a pointer to pass to the destructor function.
265265
virtual void registerGlobalDtor(CIRGenFunction &CGF, const VarDecl *D,
266-
mlir::cir::FuncOp dtor,
267-
mlir::Attribute Addr) = 0;
266+
mlir::cir::FuncOp dtor, mlir::Value Addr) = 0;
268267

269268
virtual size_t getSrcArgforCopyCtor(const CXXConstructorDecl *,
270269
FunctionArgList &Args) const = 0;

clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4443,7 +4443,7 @@ void CIRGenItaniumCXXABI::buildDestructorCall(
44434443
void CIRGenItaniumCXXABI::registerGlobalDtor(CIRGenFunction &CGF,
44444444
const VarDecl *D,
44454445
mlir::cir::FuncOp dtor,
4446-
mlir::Attribute Addr) {
4446+
mlir::Value Addr) {
44474447
if (D->isNoDestroy(CGM.getASTContext()))
44484448
return;
44494449

clang/lib/CIR/CodeGen/CIRGenModule.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1662,7 +1662,7 @@ CIRGenModule::getAddrOfGlobalTemporary(const MaterializeTemporaryExpr *expr,
16621662
} else {
16631663
// No initializer, the initialization will be provided when we initialize
16641664
// the declaration which performed lifetime extension.
1665-
llvm_unreachable("else value");
1665+
type = getTypes().convertTypeForMem(materializedType);
16661666
}
16671667

16681668
// Create a global variable for this lifetime-extended temporary.

clang/lib/CIR/CodeGen/CIRGenModule.h

+2-7
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,8 @@ class CIRGenModule : public CIRGenTypeCache {
630630
bool IsTentative = false);
631631

632632
/// Emit the function that initializes the specified global
633-
void buildCXXGlobalVarDeclInit(const VarDecl *D, mlir::cir::GlobalOp Addr,
634-
bool PerformInit);
633+
void buildCXXGlobalVarDeclInit(const VarDecl *varDecl,
634+
mlir::cir::GlobalOp addr, bool performInit);
635635

636636
void buildCXXGlobalVarDeclInitFunc(const VarDecl *D, mlir::cir::GlobalOp Addr,
637637
bool PerformInit);
@@ -673,11 +673,6 @@ class CIRGenModule : public CIRGenTypeCache {
673673
// or if they are alias to each other.
674674
mlir::cir::FuncOp codegenCXXStructor(clang::GlobalDecl GD);
675675

676-
// Produce code for this constructor/destructor for global initialzation.
677-
void codegenGlobalInitCxxStructor(const clang::VarDecl *D,
678-
mlir::cir::GlobalOp Addr, bool NeedsCtor,
679-
bool NeedsDtor, bool isCstStorage);
680-
681676
bool lookupRepresentativeDecl(llvm::StringRef MangledName,
682677
clang::GlobalDecl &Result) const;
683678

0 commit comments

Comments
 (0)