在 2024-11-08 23:06, LIU Hao 写道:
From 2b3f564d1933acadc3a0b0358591ee30ecebd120 Mon Sep 17 00:00:00 2001 From: LIU Hao <lh_mo...@126.com> Date: Fri, 8 Nov 2024 23:02:15 +0800 Subject: [PATCH] headers/intrin-impl: Fix segment accessors First, these intrins read from and write to thread-local memory. The TEB contains a pointer to itself in the DS segment, known as the `Self` field of `struct _NT_TIB`, which means the TEB is semantically in the same address space as other objects, so these asm statements must clobber "memory".
Trivia:The asm statements that are produced by `__buildwriteseg()` have no output and are implicitly `volatile`: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile
Those that are produced by `__buildreadseg()`, however, are not. If their outputs are unused, GCC can optimize out those asm statements as a whole: https://gcc.godbolt.org/z/63c59r8rn
-- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public