[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2024-03-18 Thread Akira Hatanaka via cfe-commits

ahatanak wrote:

Any other comments? Do the changes look good?

https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2024-03-12 Thread Anton Korobeynikov via cfe-commits

asl wrote:

> Maybe `emitRawPointerFromAddress` is better. I see a lot of functions 
> starting with `emit` in CodeGen.

Works for me!

https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2024-03-12 Thread Akira Hatanaka via cfe-commits

ahatanak wrote:

Maybe `emitRawPointerFromAddress` is better. I see a lot of functions starting 
with `emit` in CodeGen.

https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2024-03-11 Thread Anton Korobeynikov via cfe-commits

asl wrote:

> I'm not sure `extractRawPointerFromAddress` conveys the fact that the 
> function might do code-gen instead of just returning some pointer. I wonder 
> if there's a better name.
> 
> `computeRawPointerFromAddress` `genRawPointerFromAddress` 
> `generateRawPointerFromAddress` `codeGenRawPointerFromAddress`
> 
> Thoughts?

I do not have particular preference. But probably like `compute` / `gen` 
slightly more.

https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2024-03-11 Thread Akira Hatanaka via cfe-commits

ahatanak wrote:

I'm not sure `extractRawPointerFromAddress` conveys the fact that the function 
might do code-gen instead of just returning some pointer. I wonder if there's a 
better name.

`computeRawPointerFromAddress`
`genRawPointerFromAddress`
`generateRawPointerFromAddress`
`codeGenRawPointerFromAddress`

Thoughts?

https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2024-03-11 Thread Anton Korobeynikov via cfe-commits

asl wrote:

We discussed the naming thing (`extractRawPointerFromAddress` vs 
`getRawPointerFromAddress`) at pauth call and decided that it would be better 
to do this renaming now. @ahmedbougacha will coordinate that renaming.

https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2024-03-02 Thread Anton Korobeynikov via cfe-commits

https://github.com/asl milestoned 
https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2024-03-01 Thread Anton Korobeynikov via cfe-commits

asl wrote:

I am ok with the changes. Though with pauth we'd probably need to rename 
`getRawPointerFromAddress` to indicate clearer that it has side effects (like 
`extractRawPointerFromAddress` or something like this)

https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2024-03-01 Thread Akira Hatanaka via cfe-commits

ahatanak wrote:

ping

https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2024-02-22 Thread Akira Hatanaka via cfe-commits

ahatanak wrote:

I think I've addressed all the feedback I got. Are there any other comments?

https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2024-02-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-powerpc

Author: Akira Hatanaka (ahatanak)


Changes

To authenticate pointers, CodeGen needs access to the key and discriminators 
that were used to sign the pointer. That information is sometimes known from 
the context, but not always, which is why `Address` needs to hold that 
information.

This patch adds methods and data members to `Address`, which will be needed in 
subsequent patches to authenticate signed pointers, and uses the newly added 
methods throughout CodeGen. Although this patch isn't strictly NFC as it causes 
CodeGen to use different code paths in some cases (e.g., 
`mergeAddressesInConditionalExpr`), it doesn't cause any changes in 
functionality as it doesn't add any information needed for authentication.

In addition to the changes mentioned above, this patch introduces class 
`RawAddress`, which contains a pointer that we know is unsigned, and adds 
several new functions for creating `Address` and `LValue` objects.

---

Patch is 349.69 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/67454.diff


50 Files Affected:

- (modified) clang/lib/CodeGen/ABIInfoImpl.cpp (+5-5) 
- (modified) clang/lib/CodeGen/Address.h (+167-28) 
- (modified) clang/lib/CodeGen/CGAtomic.cpp (+29-26) 
- (modified) clang/lib/CodeGen/CGBlocks.cpp (+19-15) 
- (modified) clang/lib/CodeGen/CGBlocks.h (+2-1) 
- (modified) clang/lib/CodeGen/CGBuilder.h (+160-74) 
- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+90-83) 
- (modified) clang/lib/CodeGen/CGCUDANV.cpp (+10-9) 
- (modified) clang/lib/CodeGen/CGCXXABI.cpp (+15-6) 
- (modified) clang/lib/CodeGen/CGCXXABI.h (+2-12) 
- (modified) clang/lib/CodeGen/CGCall.cpp (+96-73) 
- (modified) clang/lib/CodeGen/CGCall.h (+1) 
- (modified) clang/lib/CodeGen/CGClass.cpp (+45-31) 
- (modified) clang/lib/CodeGen/CGCleanup.cpp (+41-69) 
- (modified) clang/lib/CodeGen/CGCleanup.h (+1-1) 
- (modified) clang/lib/CodeGen/CGCoroutine.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGDecl.cpp (+14-11) 
- (modified) clang/lib/CodeGen/CGException.cpp (+10-8) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (+119-108) 
- (modified) clang/lib/CodeGen/CGExprAgg.cpp (+16-13) 
- (modified) clang/lib/CodeGen/CGExprCXX.cpp (+47-57) 
- (modified) clang/lib/CodeGen/CGExprConstant.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGExprScalar.cpp (+19-4) 
- (modified) clang/lib/CodeGen/CGNonTrivialStruct.cpp (+4-4) 
- (modified) clang/lib/CodeGen/CGObjC.cpp (+19-24) 
- (modified) clang/lib/CodeGen/CGObjCGNU.cpp (+22-20) 
- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+47-46) 
- (modified) clang/lib/CodeGen/CGObjCRuntime.cpp (+3-3) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+102-92) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.h (+2-3) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (+37-35) 
- (modified) clang/lib/CodeGen/CGStmt.cpp (+4-4) 
- (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+45-42) 
- (modified) clang/lib/CodeGen/CGVTables.cpp (+4-5) 
- (modified) clang/lib/CodeGen/CGValue.h (+124-125) 
- (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+39-28) 
- (modified) clang/lib/CodeGen/CodeGenFunction.h (+186-71) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenPGO.cpp (+6-4) 
- (modified) clang/lib/CodeGen/CodeGenPGO.h (+4-2) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+22-30) 
- (modified) clang/lib/CodeGen/MicrosoftCXXABI.cpp (+23-35) 
- (modified) clang/lib/CodeGen/TargetInfo.h (+5) 
- (modified) clang/lib/CodeGen/Targets/NVPTX.cpp (+1-1) 
- (modified) clang/lib/CodeGen/Targets/PPC.cpp (+6-5) 
- (modified) clang/lib/CodeGen/Targets/Sparc.cpp (+1-1) 
- (modified) clang/lib/CodeGen/Targets/SystemZ.cpp (+4-5) 
- (modified) clang/lib/CodeGen/Targets/XCore.cpp (+1-1) 
- (modified) clang/utils/TableGen/MveEmitter.cpp (+1-1) 
- (modified) llvm/include/llvm/IR/IRBuilder.h (+1) 


``diff
diff --git a/clang/lib/CodeGen/ABIInfoImpl.cpp 
b/clang/lib/CodeGen/ABIInfoImpl.cpp
index 2b20d5a13346d3..1facf96ff27106 100644
--- a/clang/lib/CodeGen/ABIInfoImpl.cpp
+++ b/clang/lib/CodeGen/ABIInfoImpl.cpp
@@ -187,7 +187,7 @@ CodeGen::emitVoidPtrDirectVAArg(CodeGenFunction , 
Address VAListAddr,
   CharUnits FullDirectSize = DirectSize.alignTo(SlotSize);
   Address NextPtr =
   CGF.Builder.CreateConstInBoundsByteGEP(Addr, FullDirectSize, 
"argp.next");
-  CGF.Builder.CreateStore(NextPtr.getPointer(), VAListAddr);
+  CGF.Builder.CreateStore(NextPtr.getRawPointer(CGF), VAListAddr);
 
   // If the argument is smaller than a slot, and this is a big-endian
   // target, the argument will be right-adjusted in its slot.
@@ -239,8 +239,8 @@ Address CodeGen::emitMergePHI(CodeGenFunction , Address 
Addr1,
   const llvm::Twine ) {
   assert(Addr1.getType() == Addr2.getType());
   llvm::PHINode *PHI = CGF.Builder.CreatePHI(Addr1.getType(), 2, Name);
-  PHI->addIncoming(Addr1.getPointer(), Block1);
-  PHI->addIncoming(Addr2.getPointer(), 

[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2023-12-12 Thread Eli Friedman via cfe-commits


@@ -232,19 +232,19 @@ static Value *MakeBinaryAtomicValue(
 
 static Value *EmitNontemporalStore(CodeGenFunction , const CallExpr *E) {
   Value *Val = CGF.EmitScalarExpr(E->getArg(0));
-  Value *Address = CGF.EmitScalarExpr(E->getArg(1));
+  Address Addr = CGF.EmitPointerWithAlignment(E->getArg(1));
 
   Val = CGF.EmitToMemory(Val, E->getArg(0)->getType());
-  LValue LV = CGF.MakeNaturalAlignAddrLValue(Address, E->getArg(0)->getType());
+  LValue LV = CGF.MakeAddrLValue(Addr, E->getArg(0)->getType());
   LV.setNontemporal(true);
   CGF.EmitStoreOfScalar(Val, LV, false);
   return nullptr;
 }
 
 static Value *EmitNontemporalLoad(CodeGenFunction , const CallExpr *E) {
-  Value *Address = CGF.EmitScalarExpr(E->getArg(0));
+  Address Addr = CGF.EmitPointerWithAlignment(E->getArg(0));
 
-  LValue LV = CGF.MakeNaturalAlignAddrLValue(Address, E->getType());
+  LValue LV = CGF.MakeAddrLValue(Addr, E->getType());

efriedma-quic wrote:

EmitPointerWithAlignment tries to compute the alignment based on the underlying 
lvalue.  This can be higher or lower than the natural alignment of the type.  
Say you have something like `vec f() { struct S { char c[16]; } x; return 
__temporal_load((vec*)x.c); }`.  It looks through the cast, sees the field is 
unaligned, and therefore concludes the pointer is unaligned.  This is arguably 
an improvement, but it's a significant change to the generated code.

https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2023-12-11 Thread John McCall via cfe-commits


@@ -232,110 +279,133 @@ class CGBuilderTy : public CGBuilderBaseTy {
   /// where i64 is actually the target word size.
   Address CreateConstGEP(Address Addr, uint64_t Index,
  const llvm::Twine  = "") {
+llvm::Type *ElTy = Addr.getElementType();
 const llvm::DataLayout  = BB->getParent()->getParent()->getDataLayout();
-CharUnits EltSize =
-CharUnits::fromQuantity(DL.getTypeAllocSize(Addr.getElementType()));
+CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy));
 
-return Address(CreateGEP(Addr.getElementType(), Addr.getPointer(),
- getSize(Index), Name),
+return Address(CreateGEP(ElTy, Addr.getBasePointer(), getSize(Index), 
Name),
Addr.getElementType(),
-   Addr.getAlignment().alignmentAtOffset(Index * EltSize),
-   NotKnownNonNull);
+   Addr.getAlignment().alignmentAtOffset(Index * EltSize));
   }
 
   /// Create GEP with single dynamic index. The address alignment is reduced
   /// according to the element size.
   using CGBuilderBaseTy::CreateGEP;
-  Address CreateGEP(Address Addr, llvm::Value *Index,
+  Address CreateGEP(CodeGenFunction , Address Addr, llvm::Value *Index,
 const llvm::Twine  = "") {
 const llvm::DataLayout  = BB->getParent()->getParent()->getDataLayout();
 CharUnits EltSize =
 CharUnits::fromQuantity(DL.getTypeAllocSize(Addr.getElementType()));
 
 return Address(
-CreateGEP(Addr.getElementType(), Addr.getPointer(), Index, Name),
+CreateGEP(Addr.getElementType(), Addr.getRawPointer(CGF), Index, Name),
 Addr.getElementType(),
-Addr.getAlignment().alignmentOfArrayElement(EltSize), NotKnownNonNull);
+Addr.getAlignment().alignmentOfArrayElement(EltSize));
   }
 
   /// Given a pointer to i8, adjust it by a given constant offset.
   Address CreateConstInBoundsByteGEP(Address Addr, CharUnits Offset,
  const llvm::Twine  = "") {
 assert(Addr.getElementType() == TypeCache.Int8Ty);
-return Address(CreateInBoundsGEP(Addr.getElementType(), Addr.getPointer(),
- getSize(Offset), Name),
-   Addr.getElementType(),
-   Addr.getAlignment().alignmentAtOffset(Offset),
-   Addr.isKnownNonNull());
+return Address(
+CreateInBoundsGEP(Addr.getElementType(), Addr.getBasePointer(),
+  getSize(Offset), Name),
+Addr.getElementType(), Addr.getAlignment().alignmentAtOffset(Offset),
+Addr.isKnownNonNull());
   }
+
   Address CreateConstByteGEP(Address Addr, CharUnits Offset,
  const llvm::Twine  = "") {
 assert(Addr.getElementType() == TypeCache.Int8Ty);
-return Address(CreateGEP(Addr.getElementType(), Addr.getPointer(),
+return Address(CreateGEP(Addr.getElementType(), Addr.getBasePointer(),
  getSize(Offset), Name),
Addr.getElementType(),
-   Addr.getAlignment().alignmentAtOffset(Offset),
-   NotKnownNonNull);
+   Addr.getAlignment().alignmentAtOffset(Offset));
   }
 
   using CGBuilderBaseTy::CreateConstInBoundsGEP2_32;
   Address CreateConstInBoundsGEP2_32(Address Addr, unsigned Idx0, unsigned 
Idx1,
  const llvm::Twine  = "") {
-const llvm::DataLayout  = BB->getParent()->getParent()->getDataLayout();
+return createConstGEP2_32(Addr, Idx0, Idx1, Name);
+  }
 
-auto *GEP = cast(CreateConstInBoundsGEP2_32(
-Addr.getElementType(), Addr.getPointer(), Idx0, Idx1, Name));
-llvm::APInt Offset(
-DL.getIndexSizeInBits(Addr.getType()->getPointerAddressSpace()), 0,
-/*isSigned=*/true);
-if (!GEP->accumulateConstantOffset(DL, Offset))
-  llvm_unreachable("offset of GEP with constants is always computable");
-return Address(GEP, GEP->getResultElementType(),
-   Addr.getAlignment().alignmentAtOffset(
-   CharUnits::fromQuantity(Offset.getSExtValue())),
-   Addr.isKnownNonNull());
+  using CGBuilderBaseTy::CreateConstGEP2_32;
+  Address CreateConstGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1,
+ const llvm::Twine  = "") {
+return createConstGEP2_32(Addr, Idx0, Idx1, Name);
+  }
+
+  Address CreateGEP(Address Addr, ArrayRef IdxList,
+llvm::Type *ElementType, CharUnits Align,
+const Twine  = "") {
+llvm::Value *Ptr = getRawPointerFromAddress(Addr);
+return RawAddress(CreateGEP(Addr.getElementType(), Ptr, IdxList, Name),
+  ElementType, Align);
+  }
+
+  using CGBuilderBaseTy::CreateInBoundsGEP;
+  Address CreateInBoundsGEP(Address Addr, ArrayRef IdxList,
+llvm::Type *ElementType, 

[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2023-11-20 Thread Anton Korobeynikov via cfe-commits


@@ -232,110 +279,133 @@ class CGBuilderTy : public CGBuilderBaseTy {
   /// where i64 is actually the target word size.
   Address CreateConstGEP(Address Addr, uint64_t Index,
  const llvm::Twine  = "") {
+llvm::Type *ElTy = Addr.getElementType();
 const llvm::DataLayout  = BB->getParent()->getParent()->getDataLayout();
-CharUnits EltSize =
-CharUnits::fromQuantity(DL.getTypeAllocSize(Addr.getElementType()));
+CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy));
 
-return Address(CreateGEP(Addr.getElementType(), Addr.getPointer(),
- getSize(Index), Name),
+return Address(CreateGEP(ElTy, Addr.getBasePointer(), getSize(Index), 
Name),
Addr.getElementType(),
-   Addr.getAlignment().alignmentAtOffset(Index * EltSize),
-   NotKnownNonNull);
+   Addr.getAlignment().alignmentAtOffset(Index * EltSize));
   }
 
   /// Create GEP with single dynamic index. The address alignment is reduced
   /// according to the element size.
   using CGBuilderBaseTy::CreateGEP;
-  Address CreateGEP(Address Addr, llvm::Value *Index,
+  Address CreateGEP(CodeGenFunction , Address Addr, llvm::Value *Index,
 const llvm::Twine  = "") {
 const llvm::DataLayout  = BB->getParent()->getParent()->getDataLayout();
 CharUnits EltSize =
 CharUnits::fromQuantity(DL.getTypeAllocSize(Addr.getElementType()));
 
 return Address(
-CreateGEP(Addr.getElementType(), Addr.getPointer(), Index, Name),
+CreateGEP(Addr.getElementType(), Addr.getRawPointer(CGF), Index, Name),
 Addr.getElementType(),
-Addr.getAlignment().alignmentOfArrayElement(EltSize), NotKnownNonNull);
+Addr.getAlignment().alignmentOfArrayElement(EltSize));
   }
 
   /// Given a pointer to i8, adjust it by a given constant offset.
   Address CreateConstInBoundsByteGEP(Address Addr, CharUnits Offset,
  const llvm::Twine  = "") {
 assert(Addr.getElementType() == TypeCache.Int8Ty);
-return Address(CreateInBoundsGEP(Addr.getElementType(), Addr.getPointer(),
- getSize(Offset), Name),
-   Addr.getElementType(),
-   Addr.getAlignment().alignmentAtOffset(Offset),
-   Addr.isKnownNonNull());
+return Address(
+CreateInBoundsGEP(Addr.getElementType(), Addr.getBasePointer(),
+  getSize(Offset), Name),
+Addr.getElementType(), Addr.getAlignment().alignmentAtOffset(Offset),
+Addr.isKnownNonNull());
   }
+
   Address CreateConstByteGEP(Address Addr, CharUnits Offset,
  const llvm::Twine  = "") {
 assert(Addr.getElementType() == TypeCache.Int8Ty);
-return Address(CreateGEP(Addr.getElementType(), Addr.getPointer(),
+return Address(CreateGEP(Addr.getElementType(), Addr.getBasePointer(),
  getSize(Offset), Name),
Addr.getElementType(),
-   Addr.getAlignment().alignmentAtOffset(Offset),
-   NotKnownNonNull);
+   Addr.getAlignment().alignmentAtOffset(Offset));
   }
 
   using CGBuilderBaseTy::CreateConstInBoundsGEP2_32;
   Address CreateConstInBoundsGEP2_32(Address Addr, unsigned Idx0, unsigned 
Idx1,
  const llvm::Twine  = "") {
-const llvm::DataLayout  = BB->getParent()->getParent()->getDataLayout();
+return createConstGEP2_32(Addr, Idx0, Idx1, Name);
+  }
 
-auto *GEP = cast(CreateConstInBoundsGEP2_32(
-Addr.getElementType(), Addr.getPointer(), Idx0, Idx1, Name));
-llvm::APInt Offset(
-DL.getIndexSizeInBits(Addr.getType()->getPointerAddressSpace()), 0,
-/*isSigned=*/true);
-if (!GEP->accumulateConstantOffset(DL, Offset))
-  llvm_unreachable("offset of GEP with constants is always computable");
-return Address(GEP, GEP->getResultElementType(),
-   Addr.getAlignment().alignmentAtOffset(
-   CharUnits::fromQuantity(Offset.getSExtValue())),
-   Addr.isKnownNonNull());
+  using CGBuilderBaseTy::CreateConstGEP2_32;
+  Address CreateConstGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1,
+ const llvm::Twine  = "") {
+return createConstGEP2_32(Addr, Idx0, Idx1, Name);
+  }
+
+  Address CreateGEP(Address Addr, ArrayRef IdxList,
+llvm::Type *ElementType, CharUnits Align,
+const Twine  = "") {
+llvm::Value *Ptr = getRawPointerFromAddress(Addr);
+return RawAddress(CreateGEP(Addr.getElementType(), Ptr, IdxList, Name),
+  ElementType, Align);
+  }
+
+  using CGBuilderBaseTy::CreateInBoundsGEP;
+  Address CreateInBoundsGEP(Address Addr, ArrayRef IdxList,
+llvm::Type *ElementType, 

[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2023-11-20 Thread Anton Korobeynikov via cfe-commits

https://github.com/asl edited https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2023-11-16 Thread Eli Friedman via cfe-commits


@@ -395,27 +395,27 @@ namespace {
 void CodeGenFunction::EmitAnyExprToExn(const Expr *e, Address addr) {
   // Make sure the exception object is cleaned up if there's an
   // exception during initialization.
-  pushFullExprCleanup(EHCleanup, addr.getPointer());
-  EHScopeStack::stable_iterator cleanup = EHStack.stable_begin();
-
-  // __cxa_allocate_exception returns a void*;  we need to cast this
-  // to the appropriate type for the object.
-  llvm::Type *ty = ConvertTypeForMem(e->getType());
-  Address typedAddr = addr.withElementType(ty);
-
-  // FIXME: this isn't quite right!  If there's a final unelided call
-  // to a copy constructor, then according to [except.terminate]p1 we
-  // must call std::terminate() if that constructor throws, because
-  // technically that copy occurs after the exception expression is
-  // evaluated but before the exception is caught.  But the best way
-  // to handle that is to teach EmitAggExpr to do the final copy
-  // differently if it can't be elided.
-  EmitAnyExprToMem(e, typedAddr, e->getType().getQualifiers(),
-   /*IsInit*/ true);
-
-  // Deactivate the cleanup block.
-  DeactivateCleanupBlock(cleanup,
- cast(typedAddr.getPointer()));
+pushFullExprCleanup(EHCleanup, addr.getRawPointer(*this));

efriedma-quic wrote:

The new indentation here doesn't look right?

https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits