[clang] 3e65861 - [CodeGen] Avoid one more pointer element type access
Nikita Popov via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 27 03:58:30 PST 2021
Author: Nikita Popov
Date: 2021-12-27T12:58:22+01:00
New Revision: 3e6586113157c164d39120139c14295058e88ccb
URL: https://github.com/llvm/llvm-project/commit/3e6586113157c164d39120139c14295058e88ccb
DIFF: https://github.com/llvm/llvm-project/commit/3e6586113157c164d39120139c14295058e88ccb.diff
LOG: [CodeGen] Avoid one more pointer element type access
The number of elements is always a SizeTy here.
Added:
Modified:
clang/lib/CodeGen/CGDecl.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index e09279c1d455..36185faf942f 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -1392,9 +1392,11 @@ void CodeGenFunction::EmitAndRegisterVariableArrayDimensions(
else {
// Create an artificial VarDecl to generate debug info for.
IdentifierInfo *NameIdent = VLAExprNames[NameIdx++];
- auto VlaExprTy = VlaSize.NumElts->getType()->getPointerElementType();
+ assert(cast<llvm::PointerType>(VlaSize.NumElts->getType())
+ ->isOpaqueOrPointeeTypeMatches(SizeTy) &&
+ "Number of VLA elements must be SizeTy");
auto QT = getContext().getIntTypeForBitwidth(
- VlaExprTy->getScalarSizeInBits(), false);
+ SizeTy->getScalarSizeInBits(), false);
auto *ArtificialDecl = VarDecl::Create(
getContext(), const_cast<DeclContext *>(D.getDeclContext()),
D.getLocation(), D.getLocation(), NameIdent, QT,
More information about the cfe-commits
mailing list