[clang] ba31cb4 - [CodeGen] Store element type in RValue
Nikita Popov via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 17 00:08:42 PST 2021
Author: Nikita Popov
Date: 2021-12-17T09:05:59+01:00
New Revision: ba31cb4d388098e01df226090db95aaf8c06d271
URL: https://github.com/llvm/llvm-project/commit/ba31cb4d388098e01df226090db95aaf8c06d271
DIFF: https://github.com/llvm/llvm-project/commit/ba31cb4d388098e01df226090db95aaf8c06d271.diff
LOG: [CodeGen] Store element type in RValue
For aggregates, we need to store the element type to be able to
reconstruct the aggregate Address. This increases the size of this
packed structure (as the second value is already used for alignment
in this case), but I did not observe any compile-time or memory
usage regression from this change.
Added:
Modified:
clang/lib/CodeGen/CGValue.h
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGValue.h b/clang/lib/CodeGen/CGValue.h
index 916f423ef5b88..f01eece042f86 100644
--- a/clang/lib/CodeGen/CGValue.h
+++ b/clang/lib/CodeGen/CGValue.h
@@ -47,6 +47,8 @@ class RValue {
llvm::PointerIntPair<llvm::Value *, 2, Flavor> V1;
// Stores second value and volatility.
llvm::PointerIntPair<llvm::Value *, 1, bool> V2;
+ // Stores element type for aggregate values.
+ llvm::Type *ElementType;
public:
bool isScalar() const { return V1.getInt() == Scalar; }
@@ -71,7 +73,8 @@ class RValue {
Address getAggregateAddress() const {
assert(isAggregate() && "Not an aggregate!");
auto align = reinterpret_cast<uintptr_t>(V2.getPointer()) >> AggAlignShift;
- return Address(V1.getPointer(), CharUnits::fromQuantity(align));
+ return Address(
+ V1.getPointer(), ElementType, CharUnits::fromQuantity(align));
}
llvm::Value *getAggregatePointer() const {
assert(isAggregate() && "Not an aggregate!");
@@ -108,6 +111,7 @@ class RValue {
RValue ER;
ER.V1.setPointer(addr.getPointer());
ER.V1.setInt(Aggregate);
+ ER.ElementType = addr.getElementType();
auto align = static_cast<uintptr_t>(addr.getAlignment().getQuantity());
ER.V2.setPointer(reinterpret_cast<llvm::Value*>(align << AggAlignShift));
More information about the cfe-commits
mailing list