Skip to content

Commit e0aa1b3

Browse files
committed
Save progress
1 parent ff0bf89 commit e0aa1b3

File tree

3 files changed

+4
-98
lines changed

3 files changed

+4
-98
lines changed

clang/lib/CIR/CodeGen/Address.h

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define LLVM_CLANG_LIB_CIR_ADDRESS_H
1616

1717
#include "clang/AST/CharUnits.h"
18+
#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
1819
#include "clang/CIR/Dialect/IR/CIRTypes.h"
1920

2021
#include "llvm/IR/Constants.h"
@@ -185,77 +186,6 @@ class Address {
185186
}
186187
};
187188

188-
/// An abstract representation of an aligned address. This is designed to be an
189-
/// IR-level abstraction, carrying just the information necessary to perform IR
190-
/// operations on an address like loads and stores. In particular, it doesn't
191-
/// carry C type information or allow the representation of things like
192-
/// bit-fields; clients working at that level should generally be using
193-
/// `LValue`.
194-
/// The pointer contained in this class is known to be unsigned.
195-
class RawAddress {
196-
llvm::PointerIntPair<mlir::Value *, 1, bool> PointerAndKnownNonNull;
197-
mlir::Type *ElementType;
198-
CharUnits Alignment;
199-
200-
protected:
201-
RawAddress(std::nullptr_t) : ElementType(nullptr) {}
202-
203-
public:
204-
RawAddress(mlir::Value *Pointer, mlir::Type *ElementType, CharUnits Alignment,
205-
KnownNonNull_t IsKnownNonNull = NotKnownNonNull)
206-
: PointerAndKnownNonNull(Pointer, IsKnownNonNull),
207-
ElementType(ElementType), Alignment(Alignment) {
208-
assert(Pointer != nullptr && "Pointer cannot be null");
209-
assert(ElementType != nullptr && "Element type cannot be null");
210-
}
211-
212-
inline RawAddress(Address Addr);
213-
214-
static RawAddress invalid() { return RawAddress(nullptr); }
215-
bool isValid() const {
216-
return PointerAndKnownNonNull.getPointer() != nullptr;
217-
}
218-
219-
mlir::Value *getPointer() const {
220-
assert(isValid());
221-
return PointerAndKnownNonNull.getPointer();
222-
}
223-
224-
/// Return the type of the pointer value.
225-
llvm::PointerType *getType() const {
226-
return llvm::cast<llvm::PointerType>(getPointer()->getType());
227-
}
228-
229-
/// Return the type of the values stored in this address.
230-
mlir::Type *getElementType() const {
231-
assert(isValid());
232-
return ElementType;
233-
}
234-
235-
/// Return the address space that this address resides in.
236-
unsigned getAddressSpace() const { return getType()->getAddressSpace(); }
237-
238-
/// Return the IR name of the pointer value.
239-
llvm::StringRef getName() const { return getPointer()->getName(); }
240-
241-
/// Return the alignment of this pointer.
242-
CharUnits getAlignment() const {
243-
assert(isValid());
244-
return Alignment;
245-
}
246-
247-
/// Return address with different element type, but same pointer and
248-
/// alignment.
249-
RawAddress withElementType(mlir::Type *ElemTy) const {
250-
return RawAddress(getPointer(), ElemTy, getAlignment(), isKnownNonNull());
251-
}
252-
253-
KnownNonNull_t isKnownNonNull() const {
254-
assert(isValid());
255-
return (KnownNonNull_t)PointerAndKnownNonNull.getInt();
256-
}
257-
};
258-
259189
} // namespace clang::CIRGen
260190

261191
#endif // LLVM_CLANG_LIB_CIR_ADDRESS_H

clang/lib/CIR/CodeGen/CIRGenBuilder.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -729,28 +729,6 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
729729
return Address(derivedAddr, destType, addr.getAlignment());
730730
}
731731

732-
Address CreateInBoundsGEP(Address Addr, ArrayRef<llvm::Value *> IdxList,
733-
llvm::Type *ElementType, CharUnits Align,
734-
const Twine &Name = "") {
735-
return RawAddress(CreateInBoundsGEP(Addr.getElementType(),
736-
emitRawPointerFromAddress(Addr),
737-
IdxList, Name),
738-
ElementType, Align, Addr.isKnownNonNull());
739-
}
740-
741-
mlir::Value emitRawPointerFromAddress(Address Addr) const {
742-
return Addr.getBasePointer();
743-
}
744-
745-
Address createInBoundsGEP(Address Addr, ArrayRef<llvm::Value *> IdxList,
746-
llvm::Type *ElementType, CharUnits Align,
747-
const Twine &Name = "") {
748-
return RawAddress(CreateInBoundsGEP(Addr.getElementType(),
749-
emitRawPointerFromAddress(Addr),
750-
IdxList, Name),
751-
ElementType, Align, Addr.isKnownNonNull());
752-
}
753-
754732
mlir::Value createVTTAddrPoint(mlir::Location loc, mlir::Type retTy,
755733
mlir::Value addr, uint64_t offset) {
756734
return cir::VTTAddrPointOp::create(*this, loc, retTy,

clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,8 +1305,8 @@ struct CallArrayDelete final : EHScopeStack::Cleanup {
13051305
/// Emit the code for deleting an array of objects.
13061306
static void EmitArrayDelete(CIRGenFunction &CGF, const CXXDeleteExpr *E,
13071307
Address deletedPtr, QualType elementType) {
1308-
llvm::Value *numElements = nullptr;
1309-
llvm::Value *allocatedPtr = nullptr;
1308+
mlir::Value *numElements = nullptr;
1309+
mlir::Value *allocatedPtr = nullptr;
13101310
CharUnits cookieSize;
13111311
CGF.CGM.getCXXABI().ReadArrayCookie(CGF, deletedPtr, E, elementType,
13121312
numElements, allocatedPtr, cookieSize);
@@ -1328,13 +1328,11 @@ static void EmitArrayDelete(CIRGenFunction &CGF, const CXXDeleteExpr *E,
13281328
deletedPtr.getAlignment().alignmentOfArrayElement(elementSize);
13291329

13301330
mlir::Value arrayBegin = deletedPtr.emitRawPointer();
1331-
mlir::Value arrayEnd = CGF.Builder.createInBoundsGEP(
1332-
deletedPtr.getElementType(), arrayBegin, numElements, "delete.end");
13331331

13341332
// Note that it is legal to allocate a zero-length array, and we
13351333
// can never fold the check away because the length should always
13361334
// come from a cookie.
1337-
CGF.emitArrayDestroy(arrayBegin, arrayEnd, elementType, elementAlign,
1335+
CGF.emitArrayDestroy(arrayBegin, *numElements, elementType, elementAlign,
13381336
CGF.getDestroyer(dtorKind),
13391337
/*checkZeroLength*/ true,
13401338
CGF.needsEHCleanup(dtorKind));

0 commit comments

Comments
 (0)