[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 08:38:14 PDT 2020
fhahn added a comment.
In D79775#2032401 <https://reviews.llvm.org/D79775#2032401>, @efriedma wrote:
> > the constant actually comes from aarch64-promote-const
>
> That looks like a bug: aarch64-promote-constant is sticking constants in global variables without checking whether we can actually lower them. Probably it should be calling Constant::needsRelocation() or something like that.
For the constants causing the crash here, relocations are not a problem, just the fact that AsmPrinter does not support emitting ConstantFP in ConstantExprs. I've put up D79775 <https://reviews.llvm.org/D79775>, which skips promoting such constants. As a next step, it might make sense to use ConstantFoldConstant there to allow promoting constantexpr that can be completely folded. What do you think? I think it might be still reasonable to support emitting fold-able ConstantExprs in AsmPrinter, but it's a more invasive change and we should probably first go with the fix in AArch64PromoteConstant.
With respect to relocations, that might be an independent issue. For example, the IR below will result in emitting references to constants `_g` without relocations.
@g = external global i64
define [2 x i64] @test3() {
ret [2 x i64] [i64 add (i64 ptrtoint (i64* @g to i64), i64 ptrtoint (i64* @g to i64)), i64 ptrtoint (i64* @g to i64)]
}
; %bb.0:
Lloh4:
adrp x8, __PromotedConst at PAGE
Lloh5:
add x8, x8, __PromotedConst at PAGEOFF
ldp x0, x1, [x8]
ret
.loh AdrpAdd Lloh4, Lloh5
.cfi_endproc
; -- End function
.section __DATA,__const
.p2align 3 ; @_PromotedConst
__PromotedConst:
.quad _g+_g
.quad _g
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