[PATCH] D130513: [Flang] Add -fconvert option to swap endianness for unformatted files

Jonathon Penix via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 2 12:00:04 PDT 2022


jpenix-quic added inline comments.


================
Comment at: flang/test/Driver/emit-mlir.f90:16
 ! CHECK-NEXT: }
+! CHECK-NEXT: fir.global @_QQEnvironmentDefaults constant : !fir.ref<tuple<i[[int_size:.*]], !fir.ref<!fir.array<0xtuple<!fir.ref<i8>, !fir.ref<i8>>>>>> {
+! CHECK-NEXT:  %[[VAL_0:.*]] = fir.zero_bits !fir.ref<tuple<i[[int_size]], !fir.ref<!fir.array<0xtuple<!fir.ref<i8>, !fir.ref<i8>>>>>>
----------------
peixin wrote:
> Is it possible not to generated this global variable if `fconvert=` is not specified?
I'm not entirely sure--the issue I was running into was how to handle this in Fortran_main.c in a way which worked for all of GCC/Clang/Visual Studio (and maybe others?). I was originally thinking of doing this by using a weak definition of _QQEnvironmentDefaults set to nullptr so fconvert, etc. could override this definition without explicitly generating the fallback case. For GCC/clang, I think I could use __attribute__((weak)), but I wasn't sure how to handle this if someone tried to build with Visual Studio (or maybe another toolchain). I saw a few workarounds (ex: https://devblogs.microsoft.com/oldnewthing/20200731-00/?p=104024) but I shied away from this since it seems to be an undocumented feature (and presumably only helps with Visual Studio). 

Do you know of a better or more general way I could do this? (Or, is there non-weak symbol approach that might be better that I'm missing?)


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

https://reviews.llvm.org/D130513



More information about the cfe-commits mailing list