[PATCH] D118297: [clang] add Diag -Wasm-volatile for implied volatile asm stmts

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 26 16:52:57 PST 2022


nickdesaulniers created this revision.
Herald added subscribers: frasercrmck, luismarques, apazos, sameer.abuasal, pengfei, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, sunfish, simoncook, johnrusso, rbar, asb, dylanmckay.
nickdesaulniers requested review of this revision.
Herald added subscribers: Sanitizers, cfe-commits, pcwang-thead, aheejin.
Herald added projects: clang, Sanitizers.

According to the GCC docs on inline asm
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile

> asm statements that have no output operands and asm goto statements,
> are implicitly volatile.

We tend to see the volatile qualifier tacked on to asm statements "just
to be safe" when in reality it makes no difference in IR for `asm goto`
statements or output-less `asm`.

Really the `volatile` asm-qualifier exists only to signal that an asm
statement should not be DCE'd (when it has outputs but they are unused),
CSE'd, or LICM'd. It is not a general compiler barrier.

Create a new warning, `-Wasm-volatile` and warn in either cases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118297

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Headers/x86gprintrin.h
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/test/CodeGen/X86/amx_inline_asm.c
  clang/test/CodeGen/X86/x86-64-inline-asm.c
  clang/test/CodeGen/X86/x86_32-inline-asm.c
  clang/test/CodeGen/avr-unsupported-inline-asm-constraints.c
  clang/test/PCH/asm.h
  clang/test/Parser/asm-goto.c
  clang/test/Parser/asm-goto.cpp
  clang/test/Parser/asm-qualifiers.c
  clang/test/Parser/cxx-stmt.cpp
  clang/test/Sema/arm-asm.c
  clang/test/Sema/arm64-inline-asm.c
  clang/test/Sema/asm-goto.cpp
  clang/test/Sema/inline-asm-validate-riscv.c
  clang/test/Sema/inline-asm-validate-x86.c
  clang/test/Sema/riscv-asm.c
  compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang.h
  compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang_x86.h
  compiler-rt/lib/sanitizer_common/sanitizer_common.h
  compiler-rt/lib/sanitizer_common/tests/sanitizer_test_utils.h
  compiler-rt/lib/scudo/standalone/common.h
  compiler-rt/lib/scudo/standalone/tests/wrappers_cpp_test.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118297.403444.patch
Type: text/x-patch
Size: 32904 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220127/26cb98f9/attachment-0001.bin>


More information about the cfe-commits mailing list