[llvm] [Attributor] New attribute to identify what byte ranges are alive for an allocation (PR #66148)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 18 20:38:40 PDT 2023
================
@@ -12672,6 +12678,236 @@ struct AAAddressSpaceCallSiteArgument final : AAAddressSpaceImpl {
};
} // namespace
+/// ----------- Allocation Info ----------
+namespace {
+struct AAAllocationInfoImpl : public AAAllocationInfo {
+ AAAllocationInfoImpl(const IRPosition &IRP, Attributor &A)
+ : AAAllocationInfo(IRP, A) {}
+
+ std::optional<TypeSize> getAllocatedSize() const override {
+ assert(isValidState() && "the AA is invalid");
+ return AssumedAllocatedSize;
+ }
+
+ std::optional<TypeSize> findInitialAllocationSize(Instruction *I,
+ const DataLayout &DL) {
+
+ // TODO: implement case for malloc like instructions
+ switch (I->getOpcode()) {
+ case Instruction::Alloca: {
+ AllocaInst *AI = cast<AllocaInst>(I);
+ return AI->getAllocationSize(DL);
+ break;
----------------
shiltian wrote:
No need to have a break here
https://github.com/llvm/llvm-project/pull/66148
More information about the llvm-commits
mailing list