Skip to content

Commit

Permalink
Call llvm.reducer.register to register hyperobject struct members
Browse files Browse the repository at this point in the history
  • Loading branch information
VoxSciurorum committed Dec 27, 2023
1 parent aee817f commit a5c8b8e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions clang/lib/CodeGen/CGClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,10 @@ void CodeGenFunction::EmitInitializerForField(FieldDecl *Field, LValue LHS,
}
}

ReducerCallbacks RCB = {0, 0};
if (getReducer(Field, RCB))
EmitReducerInit(Field, RCB, LHS.getPointer(*this));

// Ensure that we destroy this object if an exception is thrown
// later in the constructor.
QualType::DestructionKind dtorKind = FieldType.isDestructedType();
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/CodeGen/CGDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,8 @@ void CodeGenFunction::emitZeroOrPatternForAutoVarInit(QualType type,
}
}

bool CodeGenFunction::getReducer(const VarDecl *D, ReducerCallbacks &CB) {
bool CodeGenFunction::getReducer(const DeclaratorDecl *D,
ReducerCallbacks &CB) {
if (const HyperobjectType *H = D->getType()->getAs<HyperobjectType>()) {
if (H->hasCallbacks()) {
CB.Identity = H->getIdentity();
Expand All @@ -1841,7 +1842,7 @@ void CodeGenFunction::destroyHyperobject(CodeGenFunction &CGF, Address Addr,
}
}

void CodeGenFunction::EmitReducerInit(const VarDecl *D,
void CodeGenFunction::EmitReducerInit(const DeclaratorDecl *D,
const ReducerCallbacks &C,
llvm::Value *Addr) {
RValue Identity = EmitAnyExpr(C.Identity);
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/CodeGenFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -3694,8 +3694,8 @@ class CodeGenFunction : public CodeGenTypeCache {
Expr *Reduce;
};

bool getReducer(const VarDecl *D, ReducerCallbacks &CB);
void EmitReducerInit(const VarDecl *D, const ReducerCallbacks &CB,
bool getReducer(const DeclaratorDecl *D, ReducerCallbacks &CB);
void EmitReducerInit(const DeclaratorDecl *D, const ReducerCallbacks &CB,
llvm::Value *Addr);

/// Emits the alloca and debug information for the size expressions for each
Expand Down

0 comments on commit a5c8b8e

Please sign in to comment.