[all-commits] [llvm/llvm-project] 0e890c: [ConstantFolding] Always return something from Con...

Nikita Popov via All-commits all-commits at lists.llvm.org
Wed Mar 4 09:25:06 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 0e890cd4d42644eb42bc30b24101c7659ec324aa
      https://github.com/llvm/llvm-project/commit/0e890cd4d42644eb42bc30b24101c7659ec324aa
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2020-03-04 (Wed, 04 Mar 2020)

  Changed paths:
    M llvm/include/llvm/Analysis/ConstantFolding.h
    M llvm/include/llvm/Analysis/TargetFolder.h
    M llvm/lib/Analysis/ConstantFolding.cpp
    M llvm/lib/Analysis/InstructionSimplify.cpp
    M llvm/lib/Analysis/Lint.cpp
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    M llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
    M llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
    M llvm/lib/Transforms/IPO/GlobalOpt.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    M llvm/lib/Transforms/Utils/Evaluator.cpp
    M llvm/lib/Transforms/Utils/VNCoercion.cpp

  Log Message:
  -----------
  [ConstantFolding] Always return something from ConstantFoldConstant

Spin-off from D75407. As described there, ConstantFoldConstant()
currently returns null for non-ConstantExpr/ConstantVector inputs,
but otherwise always returns non-null, independently of whether
any folding has happened or not.

This is confusing and makes consumer code more complicated.
I would expect either that ConstantFoldConstant() returns only if
it actually folded something, or that it always returns non-null.
I'm going to the latter possibility here, which appears to be more
useful considering existing usage.

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




More information about the All-commits mailing list