[PATCH] D128726: [RISCV][NFC] Move static global variables into static variable in function.

Kito Cheng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 29 06:50:08 PDT 2022


kito-cheng added a comment.

My understanding is the reason why no global variable is because 1. the initialization order and 2. might increase the launch time of programs, moving that into function scope could resolve both issue: 1. initialized in deterministic order[1], 2. Initialized that when the first time used.

[1] https://stackoverflow.com/questions/49856152/static-function-variable-initialization-order-in-the-same-function
[2] https://en.cppreference.com/w/cpp/language/storage_duration#Static_local_variables

- stackoverflow and cppreference might not formal source, but should be enough here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128726



More information about the cfe-commits mailing list