[all-commits] [llvm/llvm-project] 0f8c62: [BuildLibCalls] Introduce getOrInsertLibFunc() for...

Jonas Paulsson via All-commits all-commits at lists.llvm.org
Tue Apr 19 12:24:27 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0f8c626723d2bbd547e78dcab5ab260dfbc437e1
      https://github.com/llvm/llvm-project/commit/0f8c626723d2bbd547e78dcab5ab260dfbc437e1
  Author: Jonas Paulsson <paulsson at linux.vnet.ibm.com>
  Date:   2022-04-19 (Tue, 19 Apr 2022)

  Changed paths:
    M llvm/include/llvm/IR/Module.h
    M llvm/include/llvm/Transforms/Utils/BuildLibCalls.h
    M llvm/lib/Transforms/IPO/InferFunctionAttrs.cpp
    M llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
    M llvm/lib/Transforms/Utils/BuildLibCalls.cpp
    M llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
    M llvm/test/Transforms/InferFunctionAttrs/annotate.ll
    A llvm/test/Transforms/InstCombine/SystemZ/libcall-arg-exts.ll
    M llvm/test/Transforms/InstCombine/double-float-shrink-1.ll

  Log Message:
  -----------
  [BuildLibCalls] Introduce getOrInsertLibFunc() for use when building libcalls.

A new set of overloaded functions named getOrInsertLibFunc() are now supposed
to be used instead of getOrInsertFunction() when building a libcall from
within an LLVM optimizer(). The idea is that this new function also makes
sure that any mandatory argument attributes are added to the function
prototype (after calling getOrInsertFunction()).

inferLibFuncAttributes() is renamed to inferNonMandatoryLibFuncAttrs() as it
only adds attributes that are not necessary for correctness but merely
helping with later optimizations.

Generally, the front end is responsible for building a correct function
prototype with the needed argument attributes. If the middle end however is
the one creating the call, e.g. when replacing one libcall with another, it
then must take this responsibility.

This continues the work of properly handling argument extension if required
by the target ABI when building a lib call. getOrInsertLibFunc() now does
this for all libcalls currently built by any LLVM optimizer. It is expected
that when in the future a new optimization builds a new libcall with an
integer argument it is to be added to getOrInsertLibFunc() with the proper
handling. Note that not all targets have it in their ABI to sign/zero extend
integer arguments to the full register width, but this will be done
selectively as determined by getExtAttrForI32Param().

Review: Eli Friedman, Nikita Popov, Dávid Bolvanský

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




More information about the All-commits mailing list