[all-commits] [llvm/llvm-project] 7c0445: [ArgPromotion][Attributor] Update min-legal-vector...

Phoebe Wang via All-commits all-commits at lists.llvm.org
Sun May 1 23:15:12 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7c04454227f5c6bd3f515783950a815970c90558
      https://github.com/llvm/llvm-project/commit/7c04454227f5c6bd3f515783950a815970c90558
  Author: Phoebe Wang <phoebe.wang at intel.com>
  Date:   2022-05-02 (Mon, 02 May 2022)

  Changed paths:
    M llvm/docs/LangRef.rst
    M llvm/include/llvm/IR/Attributes.h
    M llvm/lib/IR/Attributes.cpp
    M llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
    M llvm/lib/Transforms/IPO/Attributor.cpp
    A llvm/test/Transforms/ArgumentPromotion/min-legal-vector-width.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/X86/min-legal-vector-width.ll

  Log Message:
  -----------
  [ArgPromotion][Attributor] Update min-legal-vector-width when do promotion

X86 codegen uses function attribute `min-legal-vector-width` to select the proper ABI. The intention of the attribute is to reflect user's requirement when they passing or returning vector arguments. So Clang front-end will iterate the vector arguments and set `min-legal-vector-width` to the width of the maximum for both caller and callee.

It is assumed any middle end optimizations won't care of the attribute expect inlining and argument promotion.
- For inlining, we will propagate the attribute of inlined functions because the inlining functions become the newer caller.
- For argument promotion, we check the `min-legal-vector-width` of the caller and callee and refuse to promote when they don't match.

The problem comes from the optimizations' combination, as shown by https://godbolt.org/z/zo3hba8xW. The caller `foo` has two callees `bar` and `baz`. When doing argument promotion, both `foo` and `bar` has the same `min-legal-vector-width`. So the argument was promoted to vector. Then the inlining inlines `baz` to `foo` and updates `min-legal-vector-width`, which results in ABI mismatch between `foo` and `bar`.

This patch fixes the problem by expanding the concept of `min-legal-vector-width` to indicator of functions arguments. That says, any passes touch functions arguments have to set `min-legal-vector-width` to the value reflects the width of vector arguments. It makes sense to me because any arguments modifications are ABI related and should response for the ABI compatibility.

Differential Revision: https://reviews.llvm.org/D123284




More information about the All-commits mailing list