[all-commits] [llvm/llvm-project] 26ebcd: [Clang][CodeGen] Avoid emitting poison immargs for...
jpwang via All-commits
all-commits at lists.llvm.org
Mon Jun 8 15:18:33 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 26ebcddb8f886640b20a8643d5ff212f95f7bbd8
https://github.com/llvm/llvm-project/commit/26ebcddb8f886640b20a8643d5ff212f95f7bbd8
Author: jpwang <jpwang at smail.nju.edu.cn>
Date: 2026-06-08 (Mon, 08 Jun 2026)
Changed paths:
M clang/lib/CodeGen/CGBuiltin.cpp
A clang/test/CodeGen/prefetch-poison-arg.c
Log Message:
-----------
[Clang][CodeGen] Avoid emitting poison immargs for __builtin_prefetch (#201623)
Fixes #201448
This PR fixes invalid clang CodeGen when lowering `__builtin_prefetch`
that is called with a constant expression that produces a poison value.
The code currently assumes that the immediate operands are
`ConstantInt`s. This is not always true as poison values may come from
UB expressions (e.g., `__builtin_prefetch(0, 2 >> 32)`) due to the use
of `EmitScalarExpr`. This would cause the subsequent downcast
`cast<ConstantInt>` in `SelectionDAGBuilder` to fail.
This PR replaces `EmitScalarExpr` with `EmitScalarOrConstFoldImmArg` to
obtain an integer constant instead of emitting a poison value for the
corresponding arguments of `llvm.prefetch`.
A regression test is also added to cover the poison immediate argument
case.
I used GPT-5.5 while working on this PR for understanding the issue and
drafting the PR description / test plan. The actual code changes and
tests are written by me, and I have noted the AI tool usage in the PR
description.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list