[llvm-branch-commits] [llvm] AMDGPU: Replace some test i32 undef uses with poison (PR #131092)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Mar 13 00:50:52 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {undef deprecator}-->


:warning: undef deprecator found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git diff -U0 --pickaxe-regex -S '([^a-zA-Z0-9#_-]undef[^a-zA-Z0-9_-]|UndefValue::get)' 4ed51855d45fb3b94f4cdcd04adb69f4a430037d 8d6e244811b467787ccadf639f856714dc3bac82 llvm/test/CodeGen/AMDGPU/cgp-addressing-modes.ll llvm/test/CodeGen/AMDGPU/commute-shifts.ll llvm/test/CodeGen/AMDGPU/constant-address-space-32bit.ll llvm/test/CodeGen/AMDGPU/dagcombine-fma-fmad.ll llvm/test/CodeGen/AMDGPU/extract_subvector_vec4_vec3.ll llvm/test/CodeGen/AMDGPU/img-nouse-adjust.ll llvm/test/CodeGen/AMDGPU/indirect-call-known-callees.ll llvm/test/CodeGen/AMDGPU/ipra-return-address-save-restore.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp.prim.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp.row.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.struct.buffer.load.format.v3f16.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.struct.ptr.buffer.load.format.v3f16.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.wqm.ll llvm/test/CodeGen/AMDGPU/loop_exit_with_xor.ll llvm/test/CodeGen/AMDGPU/mubuf-shader-vgpr-non-ptr-intrinsics.ll llvm/test/CodeGen/AMDGPU/mubuf-shader-vgpr.ll llvm/test/CodeGen/AMDGPU/partial-regcopy-and-spill-missed-at-regalloc.ll llvm/test/CodeGen/AMDGPU/scheduler-subrange-crash.ll llvm/test/CodeGen/AMDGPU/sdwa-peephole.ll llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll llvm/test/CodeGen/AMDGPU/splitkit-getsubrangeformask.ll llvm/test/CodeGen/AMDGPU/vgpr-descriptor-waterfall-loop-idom-update.ll llvm/test/CodeGen/AMDGPU/wqm.ll
``````````

</details>


The following files introduce new uses of undef:
 - llvm/test/CodeGen/AMDGPU/dagcombine-fma-fmad.ll
 - llvm/test/CodeGen/AMDGPU/img-nouse-adjust.ll
 - llvm/test/CodeGen/AMDGPU/ipra-return-address-save-restore.ll
 - llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp.prim.ll
 - llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp.row.ll
 - llvm/test/CodeGen/AMDGPU/mubuf-shader-vgpr-non-ptr-intrinsics.ll
 - llvm/test/CodeGen/AMDGPU/mubuf-shader-vgpr.ll
 - llvm/test/CodeGen/AMDGPU/splitkit-getsubrangeformask.ll

[Undef](https://llvm.org/docs/LangRef.html#undefined-values) is now deprecated and should only be used in the rare cases where no replacement is possible. For example, a load of uninitialized memory yields `undef`. You should use `poison` values for placeholders instead.

In tests, avoid using `undef` and having tests that trigger undefined behavior. If you need an operand with some unimportant value, you can add a new argument to the function and use that instead.

For example, this is considered a bad practice:
```llvm
define void @fn() {
  ...
  br i1 undef, ...
}
```

Please use the following instead:
```llvm
define void @fn(i1 %cond) {
  ...
  br i1 %cond, ...
}
```

Please refer to the [Undefined Behavior Manual](https://llvm.org/docs/UndefinedBehavior.html) for more information.



https://github.com/llvm/llvm-project/pull/131092


More information about the llvm-branch-commits mailing list