Skip to content

InlineEntryPointsPass: ignore null pointers when checking for generic AS - #1676

Merged
dneto0 merged 1 commit into
google:mainfrom
rjodinchr:ineline-entryptrs-generic-as
Oct 16, 2026
Merged

dneto0 merged 1 commit into
google:mainfrom
rjodinchr:ineline-entryptrs-generic-as

Conversation

@rjodinchr

Copy link
Copy Markdown
Collaborator

Clang materializes non-generic null pointers via an addrspacecast from generic address space (addrspacecast (ptr addrspace(4) null to ptr)). When RemoveCstExprFromFunction expanded this constant expression, InlineEntryPointsPass::RequiresInlining saw the generic ConstantPointerNull operand and falsely triggered exhaustive inlining of the entire module even when generic address space was not used.

Fold addrspacecast of ConstantPointerNull to ConstantPointerNull in the destination address space in RemoveCstExprFromFunction, and ignore ConstantPointerNull operands in RequiresInlining.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request avoids converting null pointer address space casts into instructions in BitcastUtils.cpp and ignores null pointer constants when checking for generic address spaces in InlineEntryPointsPass.cpp. The review feedback suggests using Constant::getNullValue to simplify the null pointer retrieval and avoid an explicit cast.

Comment thread lib/BitcastUtils.cpp
Comment on lines +898 to +899
I->setOperand(OperandId, ConstantPointerNull::get(
cast<PointerType>(CstExpr->getType())));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using Constant::getNullValue is more idiomatic and cleaner than explicitly casting the type to PointerType and calling ConstantPointerNull::get. It simplifies the code and avoids the explicit cast.

        I->setOperand(OperandId, Constant::getNullValue(CstExpr->getType()));

@dneto0 dneto0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code LGTM. I'd like a test as well.

Clang materializes non-generic null pointers via an addrspacecast from
generic address space (addrspacecast (ptr addrspace(4) null to ptr)).
When RemoveCstExprFromFunction expanded this constant expression,
InlineEntryPointsPass::RequiresInlining saw the generic ConstantPointerNull
operand and falsely triggered exhaustive inlining of the entire module
even when generic address space was not used.

Fold addrspacecast of ConstantPointerNull to ConstantPointerNull in the
destination address space in RemoveCstExprFromFunction, and ignore
ConstantPointerNull operands in RequiresInlining.
@rjodinchr
rjodinchr force-pushed the ineline-entryptrs-generic-as branch from f3aa841 to 76d70a2 Compare October 16, 2026 07:15
@rjodinchr
rjodinchr requested a review from dneto0 October 16, 2026 07:15

@dneto0 dneto0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks!

@dneto0
dneto0 merged commit 0e1fd53 into google:main Oct 16, 2026
18 checks passed
@rjodinchr
rjodinchr deleted the ineline-entryptrs-generic-as branch October 17, 2026 13:35
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.

2 participants