[all-commits] [llvm/llvm-project] 1228be: [FuncAttrs] Deduce `noundef` attributes for return...

Yingwei Zheng via All-commits all-commits at lists.llvm.org
Sun Dec 31 04:45:02 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1228becf7df28c68579f2b9b390b74aa41149a0a
      https://github.com/llvm/llvm-project/commit/1228becf7df28c68579f2b9b390b74aa41149a0a
  Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
  Date:   2023-12-31 (Sun, 31 Dec 2023)

  Changed paths:
    M clang/test/CodeGen/X86/ms-x86-intrinsics.c
    M clang/test/CodeGen/arm-bf16-params-returns.c
    M clang/test/CodeGen/arm-vector_type-params-returns.c
    M clang/test/CodeGen/ifunc.c
    M clang/test/CodeGen/isfpclass.c
    M clang/test/CodeGen/ms-mixed-ptr-sizes.c
    M clang/test/CodeGenCUDA/link-builtin-bitcode-denormal-fp-mode.cu
    M clang/test/CodeGenOpenCL/as_type.cl
    M lld/test/COFF/savetemps.ll
    M lld/test/ELF/lto/devirt_validate_vtable_typeinfos.ll
    M lld/test/ELF/lto/devirt_validate_vtable_typeinfos_mixed_lto.ll
    M lld/test/ELF/lto/devirt_validate_vtable_typeinfos_no_rtti.ll
    M lld/test/ELF/lto/devirt_vcall_vis_export_dynamic.ll
    M lld/test/ELF/lto/devirt_vcall_vis_public.ll
    M llvm/lib/Transforms/IPO/FunctionAttrs.cpp
    M llvm/test/CodeGen/BPF/loop-exit-cond.ll
    M llvm/test/CodeGen/NVPTX/nvvm-reflect-opaque.ll
    M llvm/test/CodeGen/NVPTX/nvvm-reflect.ll
    M llvm/test/DebugInfo/X86/array2.ll
    M llvm/test/ThinLTO/X86/devirt.ll
    M llvm/test/ThinLTO/X86/devirt2.ll
    M llvm/test/ThinLTO/X86/devirt_check.ll
    M llvm/test/ThinLTO/X86/devirt_promote.ll
    M llvm/test/ThinLTO/X86/devirt_promote_legacy.ll
    M llvm/test/ThinLTO/X86/devirt_pure_virtual_base.ll
    M llvm/test/ThinLTO/X86/devirt_single_hybrid.ll
    M llvm/test/ThinLTO/X86/devirt_vcall_vis_hidden.ll
    M llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
    M llvm/test/ThinLTO/X86/funcimport.ll
    M llvm/test/ThinLTO/X86/globals-import-const-fold.ll
    M llvm/test/ThinLTO/X86/import-constant.ll
    M llvm/test/ThinLTO/X86/index-const-prop-alias.ll
    M llvm/test/ThinLTO/X86/index-const-prop.ll
    M llvm/test/Transforms/FunctionAttrs/nocapture.ll
    M llvm/test/Transforms/FunctionAttrs/nonnull.ll
    A llvm/test/Transforms/FunctionAttrs/noundef.ll
    M llvm/test/Transforms/FunctionAttrs/out-of-bounds-iterator-bug.ll
    M llvm/test/Transforms/Inline/devirtualize-3.ll
    M llvm/test/Transforms/Inline/devirtualize-5.ll
    M llvm/test/Transforms/Inline/launder.invariant.group.ll
    M llvm/test/Transforms/PhaseOrdering/AArch64/constraint-elimination-placement.ll
    M llvm/test/Transforms/PhaseOrdering/X86/merge-functions.ll
    M llvm/test/Transforms/PhaseOrdering/bitcast-store-branch.ll
    M llvm/test/Transforms/PhaseOrdering/dce-after-argument-promotion-loads.ll
    M llvm/test/Transforms/PhaseOrdering/early-arg-attrs-inference.ll
    M llvm/test/Transforms/PhaseOrdering/gep-null-compare-in-loop.ll
    M llvm/test/Transforms/SampleProfile/ctxsplit.ll

  Log Message:
  -----------
  [FuncAttrs] Deduce `noundef` attributes for return values (#76553)

This patch deduces `noundef` attributes for return values.
IIUC, a function returns `noundef` values iff all of its return values
are guaranteed not to be `undef` or `poison`.
Definition of `noundef` from LangRef:
```
noundef
This attribute applies to parameters and return values. If the value representation contains any 
undefined or poison bits, the behavior is undefined. Note that this does not refer to padding 
introduced by the type’s storage representation.
```
Alive2: https://alive2.llvm.org/ce/z/g8Eis6

Compile-time impact: http://llvm-compile-time-tracker.com/compare.php?from=30dcc33c4ea3ab50397a7adbe85fe977d4a400bd&to=c5e8738d4bfbf1e97e3f455fded90b791f223d74&stat=instructions:u
|stage1-O3|stage1-ReleaseThinLTO|stage1-ReleaseLTO-g|stage1-O0-g|stage2-O3|stage2-O0-g|stage2-clang|
|--|--|--|--|--|--|--|
|+0.01%|+0.01%|-0.01%|+0.01%|+0.03%|-0.04%|+0.01%|

The motivation of this patch is to reduce the number of `freeze` insts
and enable more optimizations.




More information about the All-commits mailing list