Hi Ard,
Sorry for my late response. Thank you help to sync the improvement to other GCC 
X64 toolchains, especial for the MS VA intrinsics one. I once mentioned I could 
sync them as below, and I'm glad you already done it. :)

http://thread.gmane.org/gmane.comp.bios.edk2.devel/13751/focus=14015 


Steven Shi
Intel\SSG\STO\UEFI Firmware

Tel: +86 021-61166522
iNet: 821-6522


> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> Sent: Saturday, July 16, 2016 6:16 AM
> To: edk2-devel@lists.01.org; ler...@redhat.com; af...@apple.com; Gao,
> Liming <liming....@intel.com>; Shi, Steven <steven....@intel.com>; Zhu,
> Yonghong <yonghong....@intel.com>; Kinney, Michael D
> <michael.d.kin...@intel.com>; Justen, Jordan L <jordan.l.jus...@intel.com>
> Cc: br...@cran.org.uk; pbonz...@redhat.com; Ard Biesheuvel
> <ard.biesheu...@linaro.org>
> Subject: [PATCH v2 0/5] MdePkg BaseTools: GCC optimization for X64
> 
> This is v2 of the series to enable compiler optimization under GCC for builds
> targetting X64. It includes a patch from Steven Shi, taken from his series to
> introduce support for GCC 5.x and Clang 3.8/X64 to EDK2.
> 
> The first patch fixes the issue that __builtin_unreachable() is not
> implemented by GCC 4.4 or earlier.
> 
> Patch #2 is Steven's patch to switch to the flavor of VA_LIST that is
> explicitly modeled after the MS implementation. This by itself is an
> improvement, since the open coded implementation that performs
> arithmetic
> on the address of explicit arguments to obtain the variadic arguments is
> fragile and difficult to maintain, and should be best avoided.
> 
> Patch #3 enables -Os optimization for X64/RELEASE and X86/DEBUG all the
> way
> back to GCC44. This aligns X64 with IA32, which is already built using -Os
> for both DEBUG and RELEASE.
> 
> Note that the reported breakage regarding the use of -Os [0] is likely caused
> by the poor man's __builtin_ms_va_list (NO_BUILTIN_VA_FUNCS) that we
> used for
> GCC/X64 before Steven's patch above switches us to a properly defined
> builtin
> type. (The poor man's implementation uses pointer arithmetic involving the
> address of the last named argument to calculate pointers to the variadic
> arguments and dereferences them to obtain the argument values. I'm quite
> surprised it works as well as it does at -O0, to be honest)
> 
> I tested this change with both Ovmf and EmulatorPkg built in various ways
> and with various versions, with the caveat that I did not always use a
> matching
> binutils (i.e., of the same era). Since the issues this series deal with are
> all code generation issues, I think this is reasonable, but more testing would
> be appreciated. (v2: this still applies, I have tested DEBUG and RELEASE 
> builds
> using GCC44, GCC46, GCC47 and GCC48, but all on the same Ubuntu 14.04
> system,
> which means they all use the same ld version 2.24.90)
> 
> [0] http://thread.gmane.org/gmane.comp.bios.tianocore.devel/10963
> 
> Patch #4 applies the visibility 'hidden' GCC pragma globally. Please refer to
> the commit log for the motivation.
> 
> Patch #5 switches GCC/X64 to the PIC small code model, which results in
> smaller
> code.
> 
> Changes in v2:
> - Switch to -Os optimization, both for DEBUG and RELEASE builds. This turns
> out
> to work fine (as far as I could establish) and gives the best results in terms
> of code size. The following numbers were produced with the following
> invocation
> 
> build -a X64 -t GCC44 -t GCC46 -t GCC47 -t GCC48 -p
> OvmfPkg/OvmfPkgX64.dsc \
>   -D SECURE_BOOT_ENABLE  -b DEBUG -b RELEASE
> 
> DEBUG_GCC44
> 
> SECFV [14%Full] 212992 total, 31632 used, 181360 free
> FVMAIN_COMPACT [74%Full] 1753088 total, 1300904 used, 452184 free
> DXEFV [50%Full] 10485760 total, 5272464 used, 5213296 free
> PEIFV [25%Full] 917504 total, 231496 used, 686008 free
> 
> DEBUG_GCC46
> 
> SECFV [14%Full] 212992 total, 31728 used, 181264 free
> FVMAIN_COMPACT [73%Full] 1753088 total, 1291672 used, 461416 free
> DXEFV [50%Full] 10485760 total, 5263888 used, 5221872 free
> PEIFV [25%Full] 917504 total, 231656 used, 685848 free
> 
> DEBUG_GCC47
> 
> SECFV [14%Full] 212992 total, 31440 used, 181552 free
> FVMAIN_COMPACT [73%Full] 1753088 total, 1290584 used, 462504 free
> DXEFV [49%Full] 10485760 total, 5234224 used, 5251536 free
> PEIFV [25%Full] 917504 total, 230152 used, 687352 free
> 
> DEBUG_GCC48
> 
> SECFV [14%Full] 212992 total, 31280 used, 181712 free
> FVMAIN_COMPACT [73%Full] 1753088 total, 1296208 used, 456880 free
> DXEFV [49%Full] 10485760 total, 5229424 used, 5256336 free
> PEIFV [25%Full] 917504 total, 229512 used, 687992 free
> 
> RELEASE_GCC44
> 
> SECFV [6%Full] 212992 total, 14320 used, 198672 free
> FVMAIN_COMPACT [56%Full] 1753088 total, 997184 used, 755904 free
> DXEFV [33%Full] 10485760 total, 3508336 used, 6977424 free
> PEIFV [11%Full] 917504 total, 109896 used, 807608 free
> 
> RELEASE_GCC46
> 
> SECFV [6%Full] 212992 total, 13936 used, 199056 free
> FVMAIN_COMPACT [56%Full] 1753088 total, 987632 used, 765456 free
> DXEFV [33%Full] 10485760 total, 3468304 used, 7017456 free
> PEIFV [11%Full] 917504 total, 107784 used, 809720 free
> 
> RELEASE_GCC47
> 
> SECFV [6%Full] 212992 total, 13808 used, 199184 free
> FVMAIN_COMPACT [56%Full] 1753088 total, 988072 used, 765016 free
> DXEFV [32%Full] 10485760 total, 3449936 used, 7035824 free
> PEIFV [11%Full] 917504 total, 106984 used, 810520 free
> 
> RELEASE_GCC48
> 
> SECFV [6%Full] 212992 total, 13744 used, 199248 free
> FVMAIN_COMPACT [56%Full] 1753088 total, 992800 used, 760288 free
> DXEFV [32%Full] 10485760 total, 3453456 used, 7032304 free
> PEIFV [11%Full] 917504 total, 107464 used, 810040 free
> 
> For comparison, the baseline RELEASE_GCC48 (i.e., using -0O and the large
> code
> model) is
> 
> SECFV [11%Full] 212992 total, 25392 used, 187600 free
> FVMAIN_COMPACT [61%Full] 1753088 total, 1076488 used, 676600 free
> DXEFV [54%Full] 10485760 total, 5743440 used, 4742320 free
> PEIFV [21%Full] 917504 total, 200328 used, 717176 free
> 
> Ard Biesheuvel (4):
>   MdePkg: avoid __builtin_unreachable() on GCC v4.4
>   BaseTools/tools_def: enable Os optimization for GCC X64 builds
>   MdePkg X64: force 'hidden' visibility when building with -fpic
>   BaseTools/tools_def: switch GCC/X64 to the PIC small model
> 
> Shi, Steven (1):
>   MdePkg: Enable new MS VA intrinsics for GNUC x86 64bits build
> 
>  BaseTools/Conf/tools_def.template  |  2 +-
>  MdePkg/Include/Base.h              | 29 +++++++++++++++++++-
>  MdePkg/Include/X64/ProcessorBind.h | 10 +++++++
>  3 files changed, 39 insertions(+), 2 deletions(-)
> 
> --
> 1.9.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to