Skip to content

Feature: Type deduction struct field ptr inst - #823

Open
LindonAliu wants to merge 2 commits into
mainfrom
type-deduction-StructFieldPtrInst
Open

LindonAliu wants to merge 2 commits into
mainfrom
type-deduction-StructFieldPtrInst

Conversation

@LindonAliu

Copy link
Copy Markdown
Member

fix #435

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Not ready to approve

There’s a mismatch between the stated #435 goal (target-aware pointer size/alignment deduction) and what the current changes demonstrably implement, plus a small but actionable assert-message improvement is needed.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR aims to improve/lock in correct type deduction for StructFieldPtrInst results (referenced as fixing #435) by ensuring the instruction’s result type is a pointer to the accessed field type and adding a regression test around that behavior.

Changes:

  • Added a GILGen unit test asserting StructFieldPtrInst result types point to the member field type.
  • Refactored buildStructFieldPtr to use getASTContext() when allocating the PointerTy.
  • Added an invariant check in StructFieldPtrInst verifying the provided pointer type’s pointee matches the member type.
File summaries
File Description
test/GILGen/GILGenStmt.cpp Adds a regression test that validates StructFieldPtrInst result type pointee matches the field type.
include/GILGen/Context.hpp Refactors pointer type allocation to go through getASTContext() when building StructFieldPtrInst.
include/GIL/Instructions/Aggregates/StructFieldPtrInst.hpp Adds a pointee-type invariant assert and required include for PointerTy.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment on lines +36 to +37
auto *ptrType = llvm::cast<types::PointerTy>(pointerType);
assert(ptrType->getPointee() == member.getType());
Comment on lines +414 to 418
auto *fieldPtrType = getASTContext()
->getTypesMemoryArena()
.create<glu::types::PointerTy>(member.getType()
.create<glu::types::PointerTy>(
member.getType()
);
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.

Implement Proper Pointer Type Deduction in StructFieldPtrInst Constructor

2 participants