aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanak@gmail.com>2024-03-26 07:37:57 -0700
committerGitHub <noreply@github.com>2024-03-26 07:37:57 -0700
commitb3117564508ce53b3af408bf2b8ab643a6030bc4 (patch)
treec9e144169684f14d8684ea3298f50ddd4f8b91d5 /clang/lib/CodeGen/CodeGenFunction.cpp
parent2e38c50e5c53d66d4968fbd47b78e71a220a28ca (diff)
downloadllvm-b3117564508ce53b3af408bf2b8ab643a6030bc4.zip
llvm-b3117564508ce53b3af408bf2b8ab643a6030bc4.tar.gz
llvm-b3117564508ce53b3af408bf2b8ab643a6030bc4.tar.bz2
Revert "[CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (#67454)" (#86674)
This reverts commit 8bd1f9116aab879183f34707e6d21c7051d083b6. It appears that the commit broke msan bots.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp71
1 files changed, 29 insertions, 42 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 0ceac7d..fad26c4 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -193,35 +193,26 @@ CodeGenFunction::CGFPOptionsRAII::~CGFPOptionsRAII() {
CGF.Builder.setDefaultConstrainedRounding(OldRounding);
}
-static LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T,
- bool ForPointeeType,
- CodeGenFunction &CGF) {
+LValue CodeGenFunction::MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T) {
LValueBaseInfo BaseInfo;
TBAAAccessInfo TBAAInfo;
- CharUnits Alignment =
- CGF.CGM.getNaturalTypeAlignment(T, &BaseInfo, &TBAAInfo, ForPointeeType);
- Address Addr = Address(V, CGF.ConvertTypeForMem(T), Alignment);
- return CGF.MakeAddrLValue(Addr, T, BaseInfo, TBAAInfo);
-}
-
-LValue CodeGenFunction::MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T) {
- return ::MakeNaturalAlignAddrLValue(V, T, /*ForPointeeType*/ false, *this);
+ CharUnits Alignment = CGM.getNaturalTypeAlignment(T, &BaseInfo, &TBAAInfo);
+ Address Addr(V, ConvertTypeForMem(T), Alignment);
+ return LValue::MakeAddr(Addr, T, getContext(), BaseInfo, TBAAInfo);
}
+/// Given a value of type T* that may not be to a complete object,
+/// construct an l-value with the natural pointee alignment of T.
LValue
CodeGenFunction::MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T) {
- return ::MakeNaturalAlignAddrLValue(V, T, /*ForPointeeType*/ true, *this);
-}
-
-LValue CodeGenFunction::MakeNaturalAlignRawAddrLValue(llvm::Value *V,
- QualType T) {
- return ::MakeNaturalAlignAddrLValue(V, T, /*ForPointeeType*/ false, *this);
+ LValueBaseInfo BaseInfo;
+ TBAAAccessInfo TBAAInfo;
+ CharUnits Align = CGM.getNaturalTypeAlignment(T, &BaseInfo, &TBAAInfo,
+ /* forPointeeType= */ true);
+ Address Addr(V, ConvertTypeForMem(T), Align);
+ return MakeAddrLValue(Addr, T, BaseInfo, TBAAInfo);
}
-LValue CodeGenFunction::MakeNaturalAlignPointeeRawAddrLValue(llvm::Value *V,
- QualType T) {
- return ::MakeNaturalAlignAddrLValue(V, T, /*ForPointeeType*/ true, *this);
-}
llvm::Type *CodeGenFunction::ConvertTypeForMem(QualType T) {
return CGM.getTypes().ConvertTypeForMem(T);
@@ -534,8 +525,7 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
ReturnBlock.getBlock()->eraseFromParent();
}
if (ReturnValue.isValid()) {
- auto *RetAlloca =
- dyn_cast<llvm::AllocaInst>(ReturnValue.emitRawPointer(*this));
+ auto *RetAlloca = dyn_cast<llvm::AllocaInst>(ReturnValue.getPointer());
if (RetAlloca && RetAlloca->use_empty()) {
RetAlloca->eraseFromParent();
ReturnValue = Address::invalid();
@@ -1132,14 +1122,13 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
auto AI = CurFn->arg_begin();
if (CurFnInfo->getReturnInfo().isSRetAfterThis())
++AI;
- ReturnValue = makeNaturalAddressForPointer(
- &*AI, RetTy, CurFnInfo->getReturnInfo().getIndirectAlign(), false,
- nullptr, nullptr, KnownNonNull);
+ ReturnValue =
+ Address(&*AI, ConvertType(RetTy),
+ CurFnInfo->getReturnInfo().getIndirectAlign(), KnownNonNull);
if (!CurFnInfo->getReturnInfo().getIndirectByVal()) {
- ReturnValuePointer =
- CreateDefaultAlignTempAlloca(ReturnValue.getType(), "result.ptr");
- Builder.CreateStore(ReturnValue.emitRawPointer(*this),
- ReturnValuePointer);
+ ReturnValuePointer = CreateDefaultAlignTempAlloca(
+ ReturnValue.getPointer()->getType(), "result.ptr");
+ Builder.CreateStore(ReturnValue.getPointer(), ReturnValuePointer);
}
} else if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::InAlloca &&
!hasScalarEvaluationKind(CurFnInfo->getReturnType())) {
@@ -1200,9 +1189,8 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
// or contains the address of the enclosing object).
LValue ThisFieldLValue = EmitLValueForLambdaField(LambdaThisCaptureField);
if (!LambdaThisCaptureField->getType()->isPointerType()) {
- // If the enclosing object was captured by value, just use its
- // address. Sign this pointer.
- CXXThisValue = ThisFieldLValue.getPointer(*this);
+ // If the enclosing object was captured by value, just use its address.
+ CXXThisValue = ThisFieldLValue.getAddress(*this).getPointer();
} else {
// Load the lvalue pointed to by the field, since '*this' was captured
// by reference.
@@ -2024,9 +2012,8 @@ static void emitNonZeroVLAInit(CodeGenFunction &CGF, QualType baseType,
= llvm::ConstantInt::get(CGF.IntPtrTy, baseSize.getQuantity());
Address begin = dest.withElementType(CGF.Int8Ty);
- llvm::Value *end = Builder.CreateInBoundsGEP(begin.getElementType(),
- begin.emitRawPointer(CGF),
- sizeInChars, "vla.end");
+ llvm::Value *end = Builder.CreateInBoundsGEP(
+ begin.getElementType(), begin.getPointer(), sizeInChars, "vla.end");
llvm::BasicBlock *originBB = CGF.Builder.GetInsertBlock();
llvm::BasicBlock *loopBB = CGF.createBasicBlock("vla-init.loop");
@@ -2037,7 +2024,7 @@ static void emitNonZeroVLAInit(CodeGenFunction &CGF, QualType baseType,
CGF.EmitBlock(loopBB);
llvm::PHINode *cur = Builder.CreatePHI(begin.getType(), 2, "vla.cur");
- cur->addIncoming(begin.emitRawPointer(CGF), originBB);
+ cur->addIncoming(begin.getPointer(), originBB);
CharUnits curAlign =
dest.getAlignment().alignmentOfArrayElement(baseSize);
@@ -2231,10 +2218,10 @@ llvm::Value *CodeGenFunction::emitArrayLength(const ArrayType *origArrayType,
addr = addr.withElementType(baseType);
} else {
// Create the actual GEP.
- addr = Address(Builder.CreateInBoundsGEP(addr.getElementType(),
- addr.emitRawPointer(*this),
- gepIndices, "array.begin"),
- ConvertTypeForMem(eltType), addr.getAlignment());
+ addr = Address(Builder.CreateInBoundsGEP(
+ addr.getElementType(), addr.getPointer(), gepIndices, "array.begin"),
+ ConvertTypeForMem(eltType),
+ addr.getAlignment());
}
baseType = eltType;
@@ -2575,7 +2562,7 @@ void CodeGenFunction::EmitVarAnnotations(const VarDecl *D, llvm::Value *V) {
Address CodeGenFunction::EmitFieldAnnotations(const FieldDecl *D,
Address Addr) {
assert(D->hasAttr<AnnotateAttr>() && "no annotate attribute");
- llvm::Value *V = Addr.emitRawPointer(*this);
+ llvm::Value *V = Addr.getPointer();
llvm::Type *VTy = V->getType();
auto *PTy = dyn_cast<llvm::PointerType>(VTy);
unsigned AS = PTy ? PTy->getAddressSpace() : 0;