[all-commits] [llvm/llvm-project] c8b110: [SelectionDAG] Handling Oversized Alloca Types und...

Qiongsi Wu via All-commits all-commits at lists.llvm.org
Tue Nov 14 07:53:05 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c8b11091e832503f5440e9128fbd61ffa9ff86fd
      https://github.com/llvm/llvm-project/commit/c8b11091e832503f5440e9128fbd61ffa9ff86fd
  Author: Qiongsi Wu <274595+qiongsiwu at users.noreply.github.com>
  Date:   2023-11-14 (Tue, 14 Nov 2023)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    A llvm/test/CodeGen/AArch64/alloca-oversized.ll
    A llvm/test/CodeGen/PowerPC/alloca-oversized.ll

  Log Message:
  -----------
  [SelectionDAG] Handling Oversized Alloca Types under 32 bit Mode to Avoid Code Generator Crash (#71472)

Situations may arise leading to negative `NumElements` argument of an
`alloca` instruction. In this case the `NumElements` is treated as a
large unsigned value. Such large arrays may cause the size constant to
overflow during code generation under 32 bit mode, leading to a crash.
This PR limits the constant's bit width to the width of the pointer on
the target. With this fix,
```
alloca i32, i32 -1
```
and
```
alloca [4294967295 x i32], i32 1
```
generates the exact same PowerPC assembly code under 32 bit mode.




More information about the All-commits mailing list