[llvm] [Codegen][X86] Fix /hotpatch with clang-cl and inline asm (PR #87639)

via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 5 07:37:34 PDT 2024


================
@@ -193,3 +193,20 @@ do.body:                                          ; preds = %do.body, %entry
 do.end:                                           ; preds = %do.body
   ret void
 }
+
+
+; Test that inline asm is properly hotpatched. We currently don't examine the
+; asm instruction when printing it, thus we always emit patching NOPs.
+
+; 64: inline_asm:
+; 64-NEXT: # %bb.0:
+; 64-NEXT: xchgw   %ax, %ax                        # encoding: [0x66,0x90]
+; 64-NEXT: #APP
+; 64-NEXT: nop                                     # encoding: [0x90]
+; 64-NEXT: #NO_APP
+
+define dso_local void @inline_asm() "patchable-function"="prologue-short-redirect" {
+entry:
+  call void asm sideeffect "nop", "~{dirflag},~{fpsr},~{flags}"()
----------------
sylvain-audi wrote:

Emitting a nop can be confusing in this particular example, where hotpatch is supposed to generate a 2-byte nop.
Could you change the inline asm to generate something else, e.g. "xor eax, eax"?

https://github.com/llvm/llvm-project/pull/87639


More information about the llvm-commits mailing list