rsundahl updated this revision to Diff 428718.
rsundahl added a comment.
Revert ItaniumCXXABI.cpp for now (unintentional push)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125195/new/
https://reviews.llvm.org/D125195
Files:
clang/lib/CodeGen/ItaniumCXXABI.cpp
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===================================================================
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2339,10 +2339,16 @@
QualType ElementType) {
assert(requiresArrayCookie(expr));
- CharUnits SizeSize = CGF.getSizeSize();
- CharUnits CookieSize = getArrayCookieSizeImpl(ElementType);
unsigned AS = NewPtr.getAddressSpace();
+ ASTContext &Ctx = getContext();
+ CharUnits SizeSize = CGF.getSizeSize();
+
+ // The size of the cookie.
+ CharUnits CookieSize =
+ std::max(SizeSize, Ctx.getPreferredTypeAlignInChars(ElementType));
+ assert(CookieSize == getArrayCookieSizeImpl(ElementType));
+
// Compute an offset to the cookie.
Address CookiePtr = NewPtr;
CharUnits CookieOffset = CookieSize - SizeSize;
@@ -2418,19 +2424,11 @@
QualType elementType) {
assert(requiresArrayCookie(expr));
- CharUnits sizeSize = CGF.getSizeSize();
- CharUnits cookieSize = getArrayCookieSizeImpl(elementType);
unsigned AS = newPtr.getAddressSpace();
// The cookie is always at the start of the buffer.
Address cookie = newPtr;
- // Compute an offset to the cookie.
- CharUnits cookieOffset = cookieSize - sizeSize*2;
- assert(cookieOffset.isZero());
- if (!cookieOffset.isZero())
- cookie = CGF.Builder.CreateConstInBoundsByteGEP(cookie, cookieOffset);
-
// The first element is the element size.
cookie = CGF.Builder.CreateElementBitCast(cookie, CGF.SizeTy);
llvm::Value *elementSize = llvm::ConstantInt::get(CGF.SizeTy,
@@ -2456,6 +2454,7 @@
// Finally, compute a pointer to the actual data buffer by skipping
// over the cookie completely.
+ CharUnits cookieSize = ARMCXXABI::getArrayCookieSizeImpl(elementType);
return CGF.Builder.CreateConstInBoundsByteGEP(newPtr, cookieSize);
}
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===================================================================
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2339,10 +2339,16 @@
QualType ElementType) {
assert(requiresArrayCookie(expr));
- CharUnits SizeSize = CGF.getSizeSize();
- CharUnits CookieSize = getArrayCookieSizeImpl(ElementType);
unsigned AS = NewPtr.getAddressSpace();
+ ASTContext &Ctx = getContext();
+ CharUnits SizeSize = CGF.getSizeSize();
+
+ // The size of the cookie.
+ CharUnits CookieSize =
+ std::max(SizeSize, Ctx.getPreferredTypeAlignInChars(ElementType));
+ assert(CookieSize == getArrayCookieSizeImpl(ElementType));
+
// Compute an offset to the cookie.
Address CookiePtr = NewPtr;
CharUnits CookieOffset = CookieSize - SizeSize;
@@ -2418,19 +2424,11 @@
QualType elementType) {
assert(requiresArrayCookie(expr));
- CharUnits sizeSize = CGF.getSizeSize();
- CharUnits cookieSize = getArrayCookieSizeImpl(elementType);
unsigned AS = newPtr.getAddressSpace();
// The cookie is always at the start of the buffer.
Address cookie = newPtr;
- // Compute an offset to the cookie.
- CharUnits cookieOffset = cookieSize - sizeSize*2;
- assert(cookieOffset.isZero());
- if (!cookieOffset.isZero())
- cookie = CGF.Builder.CreateConstInBoundsByteGEP(cookie, cookieOffset);
-
// The first element is the element size.
cookie = CGF.Builder.CreateElementBitCast(cookie, CGF.SizeTy);
llvm::Value *elementSize = llvm::ConstantInt::get(CGF.SizeTy,
@@ -2456,6 +2454,7 @@
// Finally, compute a pointer to the actual data buffer by skipping
// over the cookie completely.
+ CharUnits cookieSize = ARMCXXABI::getArrayCookieSizeImpl(elementType);
return CGF.Builder.CreateConstInBoundsByteGEP(newPtr, cookieSize);
}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits