[flang] move getKindMapping() calls out of FIROpBuilder ctor calls
authorJean Perier <jperier@nvidia.com>
Tue, 12 Jul 2022 07:22:13 +0000 (09:22 +0200)
committerJean Perier <jperier@nvidia.com>
Tue, 12 Jul 2022 07:22:59 +0000 (09:22 +0200)
commit906784a399069f0829b28273c027fbe36be40ce9
tree060287fe07d208fb75fcffda8b8462a0089c417b
parent0fbb0ca81009d97b87ba536a674495e26630a9aa
[flang] move getKindMapping() calls out of FIROpBuilder ctor calls

FirOpBuilder takes a fir::KindMapping reference. When the getKindMapping()
call is made inside the ctor call, the lifetime of this reference may
be as short as the ctor call (at least with when building flang in
release mode with clang 8). This can cause segfaults when later using
the FirOpBuilder.

Ensure the kindMap passed to the FirOpBuilder ctor is the same as the
FirOpBuilder.

Differential Revision: https://reviews.llvm.org/D129494
flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp
flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp