[Bug middle-end/113921] Output register of an "asm volatile goto" is incorrectly clobbered/discarded
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Feb 14 18:21:45 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113921
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Bisection in the other direction doesn't make much sense, since asm goto with
output operands is only supported in GCC 11 and later.
Anyway, with gcc 11, I can see something fishy already during expansion:
(jump_insn 927 926 1285 191 (parallel [
(set (reg:DI 385 [ value ])
(asm_operands/v:DI ("1: vmread %1, %0
jna %l2
.pushsection "__ex_table","a"
.balign 4
.long (1b) - .
.long (%l3) - .
.long 1
.popsection
") ("=r") 0 [
(reg:DI 386)
]
[
(asm_input:DI ("r")
/home/sean/go/src/kernel.org/linux/arch/x86/kvm/vmx/vmx_ops.h:97)
]
[
(label_ref:DI 959)
(label_ref:DI 965)
]
/home/sean/go/src/kernel.org/linux/arch/x86/kvm/vmx/vmx_ops.h:97))
(clobber (reg:CC 17 flags))
]) "/home/sean/go/src/kernel.org/linux/arch/x86/kvm/vmx/vmx_ops.h":97:2
-1
(insn_list:REG_LABEL_TARGET 1253 (insn_list:REG_LABEL_TARGET 959 (nil)))
-> 965)
;; succ: 197 count:99052688 (estimated locally)
;; 198 count:99052688 (estimated locally)
;; 192 count:99052688 (estimated locally) (FALLTHRU)
;; basic block 192, loop depth 0, count 99052688 (estimated locally), maybe hot
;; prev block 191, next block 193, flags: (NEW, REACHABLE, RTL, MODIFIED)
;; pred: 191 count:99052688 (estimated locally) (FALLTHRU)
(note 1285 927 931 192 [bb 192] NOTE_INSN_BASIC_BLOCK)
(jump_insn 931 1285 932 192 (set (pc)
(label_ref:DI 1253))
"/home/sean/go/src/kernel.org/linux/arch/x86/kvm/vmx/vmx_ops.h":97:2 807 {jump}
(nil)
-> 1253)
;; succ: 199 [always] count:99052688 (estimated locally)
...
(code_label 1253 1251 1252 199 1127 (nil) [1 uses])
(note 1252 1253 49 199 [bb 199] NOTE_INSN_BASIC_BLOCK)
(insn 49 1252 930 199 (set (reg:DI 152 [ _241 ])
(reg/v:DI 151 [ value ]))
"/home/sean/go/src/kernel.org/linux/arch/x86/kvm/vmx/vmx_ops.h":107:9 -1
(nil))
(insn 930 49 968 199 (set (reg/v:DI 151 [ value ])
(reg:DI 385 [ value ]))
"/home/sean/go/src/kernel.org/linux/arch/x86/kvm/vmx/vmx_ops.h":97:2 -1
(nil))
;; succ: 200 [always] count:16508781 (estimated locally) (FALLTHRU)
(code_label 968 930 969 200 1083 (nil) [5 uses])
(note 969 968 970 200 [bb 200] NOTE_INSN_BASIC_BLOCK)
(insn 970 969 971 200 (set (mem:DI (plus:DI (reg/v/f:DI 283 [ vmcs12 ])
(const_int 240 [0xf0])) [19 vmcs12_30(D)->guest_pdptr3+0 S8
A8])
(reg:DI 152 [ _241 ]))
"/home/sean/go/src/kernel.org/linux/arch/x86/kvm/vmx/nested.c":4422:25 -1
(nil))
;; succ: 201 [always] count:55029271 (estimated locally) (FALLTHRU)
So, the asm goto sets pseudo 385 and in case it doesn't jump anywhere, it then
goes
into the 2 pseudo moves but they'd need to be reversed in order to store the
asm goto
output into gues_pdptr3.
More information about the Gcc-bugs
mailing list