Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions clang/lib/CIR/CodeGen/CIRGenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ CIRGenFunction::emitAutoVarAlloca(const VarDecl &d,
getContext().getLangOpts().ElideConstructors && d.isNRVOVariable();

CIRGenFunction::AutoVarEmission emission(d);
emission.IsEscapingByRef = d.isEscapingByref();
if (emission.IsEscapingByRef)
emission.isEscapingByRef = d.isEscapingByref();
if (emission.isEscapingByRef)
cgm.errorNYI(d.getSourceRange(),
"emitAutoVarDecl: decl escaping by reference");

Expand Down Expand Up @@ -78,7 +78,7 @@ CIRGenFunction::emitAutoVarAlloca(const VarDecl &d,
alignment);
}

emission.Addr = address;
emission.addr = address;
setAddrOfLocalVar(&d, address);

return emission;
Expand All @@ -101,13 +101,13 @@ bool CIRGenFunction::isTrivialInitializer(const Expr *init) {

void CIRGenFunction::emitAutoVarInit(
const CIRGenFunction::AutoVarEmission &emission) {
assert(emission.Variable && "emission was not valid!");
assert(emission.variable && "emission was not valid!");

// If this was emitted as a global constant, we're done.
if (emission.wasEmittedAsGlobal())
return;

const VarDecl &d = *emission.Variable;
const VarDecl &d = *emission.variable;

QualType type = d.getType();

Expand All @@ -124,7 +124,7 @@ void CIRGenFunction::emitAutoVarInit(
return;
}

const Address addr = emission.Addr;
const Address addr = emission.addr;

// Check whether this is a byref variable that's potentially
// captured and moved by its own initializer. If so, we'll need to
Expand Down Expand Up @@ -153,7 +153,7 @@ void CIRGenFunction::emitAutoVarInit(
}

mlir::Attribute constant;
if (emission.IsConstantAggregate ||
if (emission.isConstantAggregate ||
d.mightBeUsableInConstantExpressions(getContext())) {
// FIXME: Differently from LLVM we try not to emit / lower too much
// here for CIR since we are interested in seeing the ctor in some
Expand Down Expand Up @@ -196,7 +196,7 @@ void CIRGenFunction::emitAutoVarInit(
// FIXME(cir): migrate most of this file to use mlir::TypedAttr directly.
auto typedConstant = mlir::dyn_cast<mlir::TypedAttr>(constant);
assert(typedConstant && "expected typed attribute");
if (!emission.IsConstantAggregate) {
if (!emission.isConstantAggregate) {
// For simple scalar/complex initialization, store the value directly.
LValue lv = makeAddrLValue(addr, type);
assert(init && "expected initializer");
Expand All @@ -209,7 +209,7 @@ void CIRGenFunction::emitAutoVarInit(

void CIRGenFunction::emitAutoVarCleanups(
const CIRGenFunction::AutoVarEmission &emission) {
const VarDecl &d = *emission.Variable;
const VarDecl &d = *emission.variable;

// Check the type for a cleanup.
if (QualType::DestructionKind dtorKind = d.needsDestruction(getContext()))
Expand Down Expand Up @@ -821,7 +821,7 @@ void CIRGenFunction::emitAutoVarTypeCleanup(
// original stack object, not the possibly forwarded object.
Address addr = emission.getObjectAddress(*this);

const VarDecl *var = emission.Variable;
const VarDecl *var = emission.variable;
QualType type = var->getType();

CleanupKind cleanupKind = NormalAndEHCleanup;
Expand All @@ -834,7 +834,7 @@ void CIRGenFunction::emitAutoVarTypeCleanup(
case QualType::DK_cxx_destructor:
// If there's an NRVO flag on the emission, we need a different
// cleanup.
if (emission.NRVOFlag) {
if (emission.nrvoFlag) {
cgm.errorNYI(var->getSourceRange(), "emitAutoVarTypeCleanup: NRVO");
return;
}
Expand Down
28 changes: 14 additions & 14 deletions clang/lib/CIR/CodeGen/CIRGenFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,55 +479,55 @@ class CIRGenFunction : public CIRGenTypeCache {
ConstantEmission tryEmitAsConstant(const MemberExpr *me);

struct AutoVarEmission {
const clang::VarDecl *Variable;
const clang::VarDecl *variable;
/// The address of the alloca for languages with explicit address space
/// (e.g. OpenCL) or alloca casted to generic pointer for address space
/// agnostic languages (e.g. C++). Invalid if the variable was emitted
/// as a global constant.
Address Addr;
Address addr;

/// True if the variable is of aggregate type and has a constant
/// initializer.
bool IsConstantAggregate = false;
bool isConstantAggregate = false;

/// True if the variable is a __block variable that is captured by an
/// escaping block.
bool IsEscapingByRef = false;
bool isEscapingByRef = false;

/// True if the variable was emitted as an offload recipe, and thus doesn't
/// have the same sort of alloca initialization.
bool EmittedAsOffload = false;
bool emittedAsOffload = false;

mlir::Value NRVOFlag{};
mlir::Value nrvoFlag{};

struct Invalid {};
AutoVarEmission(Invalid) : Variable(nullptr), Addr(Address::invalid()) {}
AutoVarEmission(Invalid) : variable(nullptr), addr(Address::invalid()) {}

AutoVarEmission(const clang::VarDecl &variable)
: Variable(&variable), Addr(Address::invalid()) {}
: variable(&variable), addr(Address::invalid()) {}

static AutoVarEmission invalid() { return AutoVarEmission(Invalid()); }

bool wasEmittedAsGlobal() const { return !Addr.isValid(); }
bool wasEmittedAsGlobal() const { return !addr.isValid(); }

bool wasEmittedAsOffloadClause() const { return EmittedAsOffload; }
bool wasEmittedAsOffloadClause() const { return emittedAsOffload; }

/// Returns the raw, allocated address, which is not necessarily
/// the address of the object itself. It is casted to default
/// address space for address space agnostic languages.
Address getAllocatedAddress() const { return Addr; }
Address getAllocatedAddress() const { return addr; }

// Changes the stored address for the emission. This function should only
// be used in extreme cases, and isn't required to model normal AST
// initialization/variables.
void setAllocatedAddress(Address A) { Addr = A; }
void setAllocatedAddress(Address a) { addr = a; }

/// Returns the address of the object within this declaration.
/// Note that this does not chase the forwarding pointer for
/// __block decls.
Address getObjectAddress(CIRGenFunction &cgf) const {
if (!IsEscapingByRef)
return Addr;
if (!isEscapingByRef)
return addr;

assert(!cir::MissingFeatures::opAllocaEscapeByReference());
return Address::invalid();
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ void OpenACCRecipeBuilderBase::makeBoundsInit(
CIRGenFunction::LexicalScope ls(cgf, loc, block);

CIRGenFunction::AutoVarEmission tempDeclEmission{*allocaDecl};
tempDeclEmission.EmittedAsOffload = true;
tempDeclEmission.emittedAsOffload = true;

// The init section is the only one of the handful that only has a single
// argument for the 'type', so we have to drop 1 for init, and future calls
Expand Down Expand Up @@ -504,7 +504,7 @@ void OpenACCRecipeBuilderBase::createFirstprivateRecipeCopy(
// that instead of the variable in the other block.
tempDeclEmission.setAllocatedAddress(
Address{toArg, elementTy, cgf.getContext().getDeclAlign(varRecipe)});
tempDeclEmission.EmittedAsOffload = true;
tempDeclEmission.emittedAsOffload = true;

CIRGenFunction::DeclMapRevertingRAII declMapRAII{cgf, temporary};
cgf.setAddrOfLocalVar(
Expand Down