Skip to content

[SandboxIR] Implement AllocaInst #102027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2024
Merged

[SandboxIR] Implement AllocaInst #102027

merged 1 commit into from
Aug 6, 2024

Conversation

vporpo
Copy link
Contributor

@vporpo vporpo commented Aug 5, 2024

This patch implements sandboxir::AllocaInst which mirrors llvm::AllocaInst.

auto &Tracker = Ctx.getTracker();
if (Tracker.isTracking())
Tracker.track(std::make_unique<AllocaSetAllocatedType>(
cast<AllocaInst>(this), Tracker));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be blind, but why is this not a AllocaInst?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, yes, this is redundant.

Use getOperandUseInternal(unsigned OpIdx, bool Verify) const final {
return getOperandUseDefault(OpIdx, Verify);
}
SmallVector<llvm::Instruction *, 1> getLLVMInstrs() const final {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we should have a helper SingleLLVMInstructionImpl helper class for these that you can inherit from

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's a good point, let me give it a try.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would also help with a couple more functions that repeat in a similar way, like getOpreandUseInteral(), getUseOperandNo() and getNumOfIRInstrs().

I will upload a separate patch for this.

}

public:
AllocaInst(llvm::AllocaInst *AI, Context &Ctx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this was supposed to be private

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, yes this should be private.

}
/// Return true if this alloca is used as an inalloca argument to a call. Such
/// allocas are never considered static even if they are in the entry block.
bool isUsedWithInAlloca() const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personally I wouldn't add inalloca/swifterror methods unless somebody specifically requests those, but I guess up to you.

swifterror is extremely swift-specific, and inalloca is extremely windows-specific

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall having to add some special casing for inalloca in the scheduler's DAG, because of some instruction ordering issue related to it. So I would rather keep it.

Yeah I can drop the swifterror one.

This patch implements sandboxir::AllocaInst which mirrors llvm::AllocaInst.
@vporpo vporpo merged commit 36f0d64 into llvm:main Aug 6, 2024
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants