[clang] a0cf066 - [CodeGen] Store element type in ParamValue
Nikita Popov via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 16 06:32:04 PST 2021
Author: Nikita Popov
Date: 2021-12-16T15:31:55+01:00
New Revision: a0cf066eac8aa55782a6dd2deb90adc89a707a8b
URL: https://github.com/llvm/llvm-project/commit/a0cf066eac8aa55782a6dd2deb90adc89a707a8b
DIFF: https://github.com/llvm/llvm-project/commit/a0cf066eac8aa55782a6dd2deb90adc89a707a8b.diff
LOG: [CodeGen] Store element type in ParamValue
ParamValue is basically a union between an Address and a Value*.
To be able to reconstruct the Address, we now need to store the
pointer element type.
Added:
Modified:
clang/lib/CodeGen/CodeGenFunction.h
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 411a36a26332..679c720f7bd7 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -3130,15 +3130,18 @@ class CodeGenFunction : public CodeGenTypeCache {
class ParamValue {
llvm::Value *Value;
+ llvm::Type *ElementType;
unsigned Alignment;
- ParamValue(llvm::Value *V, unsigned A) : Value(V), Alignment(A) {}
+ ParamValue(llvm::Value *V, llvm::Type *T, unsigned A)
+ : Value(V), ElementType(T), Alignment(A) {}
public:
static ParamValue forDirect(llvm::Value *value) {
- return ParamValue(value, 0);
+ return ParamValue(value, nullptr, 0);
}
static ParamValue forIndirect(Address addr) {
assert(!addr.getAlignment().isZero());
- return ParamValue(addr.getPointer(), addr.getAlignment().getQuantity());
+ return ParamValue(addr.getPointer(), addr.getElementType(),
+ addr.getAlignment().getQuantity());
}
bool isIndirect() const { return Alignment != 0; }
@@ -3151,7 +3154,7 @@ class CodeGenFunction : public CodeGenTypeCache {
Address getIndirectAddress() const {
assert(isIndirect());
- return Address(Value, CharUnits::fromQuantity(Alignment));
+ return Address(Value, ElementType, CharUnits::fromQuantity(Alignment));
}
};
More information about the cfe-commits
mailing list