From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8F988385C32C; Wed, 14 Feb 2024 18:21:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F988385C32C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707934906; bh=75FZS1gFsy9lmzKRI2wM4mfltSKOsPXoIS2h04BuANk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jMrq+DkYhry+Wx1YkYnc/qefKfXXIMmvtFx5p/OsXdFfc2iJPxF0myBqUFUU3CMAx Cd+PMWdN0gmSSI72QFsGOjPduGHeZpbUgnZryph6eOvYAykXX7whlVt+8ROm2TIFdB 8lcmcpGTht2PVENDNfm93/Ir4ciYZbp/4cDmuH0E= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/113921] Output register of an "asm volatile goto" is incorrectly clobbered/discarded Date: Wed, 14 Feb 2024 18:21:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.4.0 X-Bugzilla-Keywords: inline-asm X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113921 --- Comment #4 from Jakub Jelinek --- Bisection in the other direction doesn't make much sense, since asm goto wi= th 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 ") ("=3Dr") 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)=20=20=20=20=20=20=20=20=20=20=20=20=20 ;; 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 {j= ump} (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 t= hen goes into the 2 pseudo moves but they'd need to be reversed in order to store the asm goto output into gues_pdptr3.=