[PATCH] D79775: [AsmPrinter] Handle foldable FP constant exprs in initializers.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 13 10:50:43 PDT 2020


fhahn added a comment.

In D79775#2034437 <https://reviews.llvm.org/D79775#2034437>, @efriedma wrote:

> needsRelocation() includes both actual references to globals, and arbitrary constantexprs that can't be emitted in any straightforward manner.


Hm, the version I am looking at seems to only return true for GlobalValues & block addresses in functions needing relocations. https://github.com/llvm/llvm-project/blob/master/llvm/lib/IR/Constants.cpp#L553

> Granted, in theory, if a constant expression doesn't refer to any globals, it should theoretically be possible to fold it down to a form the asmprinter can emit: there isn't anything that can vary, so there's only one possible result.  And maybe our constant folder is in fact powerful enough to do that? But I'd rather be conservative, and not assume that.  So I'd rather just restrict the form of the input to the backend: no ConstantExprs, except for a few specific forms of expressions involving pointers which we know the AsmPrinter supports.

Sounds good to me!  D79775 <https://reviews.llvm.org/D79775> specifically rejects floating point constant expressions in AArch64PromoteConstant. I think rejecting expressions requiring relocations/other complex exprs would be best done as follow-ups.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79775/new/

https://reviews.llvm.org/D79775





More information about the llvm-commits mailing list