Skip to content

Conversation

tambry
Copy link
Contributor

@tambry tambry commented Oct 21, 2025

Implementation files using the Intel syntax explicitly specify it. Do the same for the few files using AT&T syntax.

This also enables building LLVM with -mllvm -x86-asm-syntax=intel in one's Clang config files (i.e. a global preference for Intel syntax).

No functional change intended.

Implementation files using the Intel syntax explicitly specify it.
Do the same for the few files using AT&T syntax.

This also enables building LLVM with `-mllvm -x86-asm-syntax=intel` in one's Clang config files
(i.e. a global preference for Intel syntax).

No functional change intended.
@tambry tambry requested a review from echristo October 21, 2025 16:07
@tambry tambry self-assigned this Oct 21, 2025
@tambry tambry requested a review from a team as a code owner October 21, 2025 16:07
@llvmbot
Copy link
Member

llvmbot commented Oct 21, 2025

@llvm/pr-subscribers-libunwind

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Raul Tambre (tambry)

Changes

Implementation files using the Intel syntax explicitly specify it. Do the same for the few files using AT&T syntax.

This also enables building LLVM with -mllvm -x86-asm-syntax=intel in one's Clang config files (i.e. a global preference for Intel syntax).

No functional change intended.


Full diff: https://github.com/llvm/llvm-project/pull/164453.diff

11 Files Affected:

  • (modified) compiler-rt/lib/asan/asan_rtl_x86_64.S (+1)
  • (modified) compiler-rt/lib/builtins/assembly.h (+4)
  • (modified) compiler-rt/lib/hwasan/hwasan_setjmp_x86_64.S (+1)
  • (modified) compiler-rt/lib/orc/elfnix_tls.x86-64.S (+1)
  • (modified) compiler-rt/lib/orc/sysv_reenter.x86-64.S (+1)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S (+2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S (+2)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S (+2)
  • (modified) libunwind/src/UnwindRegistersRestore.S (+3)
  • (modified) libunwind/src/UnwindRegistersSave.S (+2)
  • (modified) openmp/runtime/src/z_Linux_asm.S (+1)
diff --git a/compiler-rt/lib/asan/asan_rtl_x86_64.S b/compiler-rt/lib/asan/asan_rtl_x86_64.S
index 9c5289856d8ae..5ee830d3afc5e 100644
--- a/compiler-rt/lib/asan/asan_rtl_x86_64.S
+++ b/compiler-rt/lib/asan/asan_rtl_x86_64.S
@@ -5,6 +5,7 @@
 #include "sanitizer_common/sanitizer_platform.h"
 
 .file "asan_rtl_x86_64.S"
+.att_syntax
 
 #define NAME(n, reg, op, s, i) n##_##op##_##i##_##s##_##reg
 
diff --git a/compiler-rt/lib/builtins/assembly.h b/compiler-rt/lib/builtins/assembly.h
index d1e532813aa24..79a45d9143b40 100644
--- a/compiler-rt/lib/builtins/assembly.h
+++ b/compiler-rt/lib/builtins/assembly.h
@@ -337,4 +337,8 @@
 #endif
 #endif
 
+#if defined(__i386__) || defined(__amd64__)
+.att_syntax
+#endif
+
 #endif // COMPILERRT_ASSEMBLY_H
diff --git a/compiler-rt/lib/hwasan/hwasan_setjmp_x86_64.S b/compiler-rt/lib/hwasan/hwasan_setjmp_x86_64.S
index 9804e8d7cecaa..a5379d39c6e79 100644
--- a/compiler-rt/lib/hwasan/hwasan_setjmp_x86_64.S
+++ b/compiler-rt/lib/hwasan/hwasan_setjmp_x86_64.S
@@ -30,6 +30,7 @@
 
 .section .text
 .file "hwasan_setjmp_x86_64.S"
+.att_syntax
 
 .global ASM_WRAPPER_NAME(setjmp)
 ASM_TYPE_FUNCTION(ASM_WRAPPER_NAME(setjmp))
diff --git a/compiler-rt/lib/orc/elfnix_tls.x86-64.S b/compiler-rt/lib/orc/elfnix_tls.x86-64.S
index b3e0bef008674..da202127bdbf3 100644
--- a/compiler-rt/lib/orc/elfnix_tls.x86-64.S
+++ b/compiler-rt/lib/orc/elfnix_tls.x86-64.S
@@ -13,6 +13,7 @@
 
 // The content of this file is x86_64-only
 #if defined(__x86_64__)
+.att_syntax
 
 #define REGISTER_SAVE_SPACE_SIZE        512
 
diff --git a/compiler-rt/lib/orc/sysv_reenter.x86-64.S b/compiler-rt/lib/orc/sysv_reenter.x86-64.S
index 0a36280f1d1f8..99615c0468b9a 100644
--- a/compiler-rt/lib/orc/sysv_reenter.x86-64.S
+++ b/compiler-rt/lib/orc/sysv_reenter.x86-64.S
@@ -12,6 +12,7 @@
 
 // The content of this file is x86_64-only
 #if defined(__x86_64__)
+.att_syntax
 
 // Save all GRPS except %rsp.
 // This value is also subtracted from %rsp below, despite the fact that %rbp
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S
index c633014e2daa8..5ef090c003dc5 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S
@@ -2,6 +2,8 @@
 
 #include "sanitizer_common/sanitizer_asm.h"
 
+.att_syntax
+
 .comm _ZN14__interception10real_vforkE,4,4
 .globl ASM_WRAPPER_NAME(vfork)
 ASM_TYPE_FUNCTION(ASM_WRAPPER_NAME(vfork))
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S
index 5500f817aec58..9c85407fe022b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S
@@ -2,6 +2,8 @@
 
 #include "sanitizer_common/sanitizer_asm.h"
 
+.att_syntax
+
 .comm _ZN14__interception10real_vforkE,8,8
 .globl ASM_WRAPPER_NAME(vfork)
 ASM_TYPE_FUNCTION(ASM_WRAPPER_NAME(vfork))
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S b/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S
index f848be9dd46c3..8b9b706a822df 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S
@@ -3,6 +3,8 @@
 
 #include "sanitizer_common/sanitizer_asm.h"
 
+.att_syntax
+
 #if !defined(__APPLE__)
 .section .text
 #else
diff --git a/libunwind/src/UnwindRegistersRestore.S b/libunwind/src/UnwindRegistersRestore.S
index 5d71d2cf61ad9..1ab4c43b673b4 100644
--- a/libunwind/src/UnwindRegistersRestore.S
+++ b/libunwind/src/UnwindRegistersRestore.S
@@ -25,6 +25,8 @@
 #if !defined(__USING_SJLJ_EXCEPTIONS__)
 
 #if defined(__i386__)
+.att_syntax
+
 DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_x86_jumpto)
 #
 # extern "C" void __libunwind_Registers_x86_jumpto(Registers_x86 *);
@@ -69,6 +71,7 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_x86_jumpto)
   # skip gs
 
 #elif defined(__x86_64__) && !defined(__arm64ec__)
+.att_syntax
 
 DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_x86_64_jumpto)
 #
diff --git a/libunwind/src/UnwindRegistersSave.S b/libunwind/src/UnwindRegistersSave.S
index fe3ba7842619f..31a177f4a0df4 100644
--- a/libunwind/src/UnwindRegistersSave.S
+++ b/libunwind/src/UnwindRegistersSave.S
@@ -25,6 +25,7 @@
 #if !defined(__USING_SJLJ_EXCEPTIONS__)
 
 #if defined(__i386__)
+.att_syntax
 
 #
 # extern int __unw_getcontext(unw_context_t* thread_state)
@@ -109,6 +110,7 @@ DEFINE_LIBUNWIND_FUNCTION("#__unw_getcontext")
   .text
 
 #elif defined(__x86_64__)
+.att_syntax
 
 #
 # extern int __unw_getcontext(unw_context_t* thread_state)
diff --git a/openmp/runtime/src/z_Linux_asm.S b/openmp/runtime/src/z_Linux_asm.S
index ec4d762742a53..89359759fcb42 100644
--- a/openmp/runtime/src/z_Linux_asm.S
+++ b/openmp/runtime/src/z_Linux_asm.S
@@ -18,6 +18,7 @@
 #include "kmp_config.h"
 
 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
+.att_syntax
 
 # if defined(__ELF__) && defined(__CET__) && defined(__has_include)
 # if __has_include(<cet.h>)

Copy link
Member

@MaskRay MaskRay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libunwind changes look good. Please wait for approval from a sanitizer maintainer

You can use clang -masm=intel instead of -mllvm -x86-asm-syntax=intel

@tambry
Copy link
Contributor Author

tambry commented Oct 21, 2025

@MaskRay -masm=intel switches the asm() blocks to Intel syntax too. That breaks a lot more code – f.e. updating every asm() occurrence in the LLVM codebase to explicitly use AT&T syntax is rather unworkable. My main interest has been in getting assembly output from Clang for debugging performance issues so -mllvm -x86-asm-syntax=intel is more suitable.

Copy link
Contributor

@thurstond thurstond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sanitizer changes LGTM

@tambry tambry merged commit c208a23 into llvm:main Oct 21, 2025
79 of 82 checks passed
@PiJoules
Copy link
Contributor

I believe this patch is leading to this build error on our builders (https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8700376349587788321/overview):

FAILED: CMakeFiles/clang_rt.atomic-dynamic-i386.dir/atomic.c.o 
/b/s/w/ir/x/w/llvm_build/./bin/clang --target=i386-unknown-linux-gnu --sysroot=/b/s/w/ir/x/w/cipd/linux -DCOMPILER_RT_SHARED_LIB -D_LIBATOMIC_USE_PTHREAD -Dclang_rt_atomic_dynamic_i386_EXPORTS -I/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/../../../third-party/siphash/include --target=i386-unknown-linux-gnu -O2 -g -DNDEBUG -fPIC -fno-lto -MD -MT CMakeFiles/clang_rt.atomic-dynamic-i386.dir/atomic.c.o -MF CMakeFiles/clang_rt.atomic-dynamic-i386.dir/atomic.c.o.d -o CMakeFiles/clang_rt.atomic-dynamic-i386.dir/atomic.c.o -c /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/atomic.c
In file included from /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/atomic.c:30:
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/assembly.h:341:1: error: expected identifier or '('
  341 | .att_syntax
      | ^
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/atomic.c:132:25: error: use of undeclared identifier 'SPINLOCK_MASK'
  132 |   intptr_t low = hash & SPINLOCK_MASK;
      |                         ^~~~~~~~~~~~~
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/atomic.c:138:26: error: use of undeclared identifier 'SPINLOCK_MASK'
  138 |   return locks + (hash & SPINLOCK_MASK);
      |                          ^~~~~~~~~~~~~
3 errors generated.

Not sure where the SPINLOCK_MASK error comes from, but I think since assembly.h is included in this C file the .att_syntax needs a #ifdef __ASSEMBLER__ wrapper.

googlewalt added a commit to googlewalt/llvm-project that referenced this pull request Oct 22, 2025
googlewalt added a commit that referenced this pull request Oct 22, 2025
@tambry tambry deleted the att branch October 22, 2025 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants