diff options
author | Andy Kaylor <akaylor@nvidia.com> | 2025-04-09 15:27:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-09 15:27:50 -0700 |
commit | 58b91d10a4c9dcd71ea0bcf6ff702a46dad147cb (patch) | |
tree | 71f53c1e7fa5a187c23be2aec3c1c77b9e427556 /clang/lib/CIR/CodeGen/CIRGenModule.cpp | |
parent | 688c3ffb057a87b86c6c1e77040418adf511efbb (diff) | |
download | llvm-58b91d10a4c9dcd71ea0bcf6ff702a46dad147cb.zip llvm-58b91d10a4c9dcd71ea0bcf6ff702a46dad147cb.tar.gz llvm-58b91d10a4c9dcd71ea0bcf6ff702a46dad147cb.tar.bz2 |
[CIR][NFC] Upstream LValueBaseInfo handling (#134928)
Previous implementations that used the cir::LValue class omitted hanling
of the LValueBaseInfo class, which tracks information about the basis
for the LValue's alignment. As more code was upstreamed from the
incubator, we were accumulating technical debt by adding more places
where this wasn't handled correctly. This change puts the interfaces in
place to track this information.
The information being tracked isn't used yet, so no functional change is
intended. The tracking is being added now because it will become more
difficult to add it as more features are implemented.
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenModule.cpp')
-rw-r--r-- | clang/lib/CIR/CodeGen/CIRGenModule.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index 78d995b..d2259a9 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -74,18 +74,20 @@ CIRGenModule::CIRGenModule(mlir::MLIRContext &mlirContext, builder.getStringAttr(getTriple().str())); } -CharUnits CIRGenModule::getNaturalTypeAlignment(QualType t) { +CharUnits CIRGenModule::getNaturalTypeAlignment(QualType t, + LValueBaseInfo *baseInfo) { assert(!cir::MissingFeatures::opTBAA()); - // FIXME: This duplicates logic in ASTContext::getTypeAlignIfKnown. But - // that doesn't return the information we need to compute BaseInfo. + // FIXME: This duplicates logic in ASTContext::getTypeAlignIfKnown, but + // that doesn't return the information we need to compute baseInfo. // Honor alignment typedef attributes even on incomplete types. // We also honor them straight for C++ class types, even as pointees; // there's an expressivity gap here. if (const auto *tt = t->getAs<TypedefType>()) { if (unsigned align = tt->getDecl()->getMaxAlignment()) { - assert(!cir::MissingFeatures::lvalueBaseInfo()); + if (baseInfo) + *baseInfo = LValueBaseInfo(AlignmentSource::AttributedType); return astContext.toCharUnitsFromBits(align); } } @@ -99,13 +101,15 @@ CharUnits CIRGenModule::getNaturalTypeAlignment(QualType t) { // ASTContext::getTypeAlignIfKnown, but nothing uses the alignment if the // type is incomplete, so it's impossible to test. We could try to reuse // getTypeAlignIfKnown, but that doesn't return the information we need - // to set BaseInfo. So just ignore the possibility that the alignment is + // to set baseInfo. So just ignore the possibility that the alignment is // greater than one. - assert(!cir::MissingFeatures::lvalueBaseInfo()); + if (baseInfo) + *baseInfo = LValueBaseInfo(AlignmentSource::Type); return CharUnits::One(); } - assert(!cir::MissingFeatures::lvalueBaseInfo()); + if (baseInfo) + *baseInfo = LValueBaseInfo(AlignmentSource::Type); CharUnits alignment; if (t.getQualifiers().hasUnaligned()) { |