From patchwork Mon Jan 29 08:54:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Coplan X-Patchwork-Id: 193350 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp440204dyb; Mon, 29 Jan 2024 01:02:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IHsQl2S8tXSDSa+4v98bbROWvu4q1fN3QWuJpinb336PfVMrte/rZcXOoaF6Iv162wpfX2z X-Received: by 2002:a05:622a:1910:b0:42a:2205:d6eb with SMTP id w16-20020a05622a191000b0042a2205d6ebmr5842702qtc.55.1706518938652; Mon, 29 Jan 2024 01:02:18 -0800 (PST) ARC-Seal: i=4; a=rsa-sha256; t=1706518938; cv=pass; d=google.com; s=arc-20160816; b=Vkn+Jx/pnaeOSkLi+B3uRWkgJKkrwCDmArMgpCUFsPE8byHRj6Hzmepnwnoq5ocwIO +JU6AN2Sbw2MJgK0u5v4wU0SbxStvYBXzzT1Tzl6dHubajHUM1T1vIDpOdgCSxwW4NnD ZEOFYiqIvvgkstf/fn7b1cgn+9veEdzZN0FY7XRsny+Ge4mvimyAmpQEUmsKT+AvVHVW EfJAjbjip6eEnR27eUpA7jui7W1d/FitvEMXaKcAC27tNPJMo6NbWlAnq+6/TfR66+fd clZohto5ytFXittYbBBSIYamq2z8htU3mjvc1x/Hi1yWB8GhbVVY9tns9pUlTr31IP/K hZPA== ARC-Message-Signature: i=4; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:original-authentication-results :nodisclaimer:mime-version:content-disposition:message-id:subject:cc :to:from:date:authentication-results-original:dkim-signature :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=w/Q+du7qHHmOtqu2BNn5PsJ3fTM2IzppQ7E3D5/vKMQ=; fh=B1a4w0PRsEPJCXJekrVstAjRZ6EaFV3M/osyyteoUbw=; b=mWPTolYTf/tOg3LhgSF1tKofkZsnAZVov3JSTKWa0mCBXIkOe9ofSdikHEvgTHhquA aW01tNNkYJl6zH3onWjYbKTeKP14f0ZI0jvZzTkjPjl2bgjgNwG1IX6PLfWrg9YSGR1s DhFF40fX2dFO2myBYU4NxHFlhAPQMwqJpOBk0PYlsuk5QtQOPIjshbzU+UzhqcujAy0+ eaFX/sfLmLxQ2RBkb5aMQJJDhafaO846fxyIiAxcf5vFQ24iWKc1H6GxMdS+7JKOCvoz 2CA2HKCWpOfNctMTxEWB50oZjn3KPlpfPnj8CMzWm7Fpgza2QNKpzmTV8qU/EEYjFCMA /snA== ARC-Authentication-Results: i=4; mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=S7P2OSpi; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=S7P2OSpi; arc=pass (i=3); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id l6-20020a05622a050600b0042a2e1312a0si7131305qtx.216.2024.01.29.01.02.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 01:02:18 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=S7P2OSpi; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=S7P2OSpi; arc=pass (i=3); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2C7CF385829D for ; Mon, 29 Jan 2024 09:02:18 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2060.outbound.protection.outlook.com [40.107.21.60]) by sourceware.org (Postfix) with ESMTPS id CD231385842C for ; Mon, 29 Jan 2024 08:54:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD231385842C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CD231385842C Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.21.60 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1706518484; cv=pass; b=FhJBicgSrqbFfIEfL1O7YUwibh1bPvfpTf7bTHMe5nx2lX1XeQY5YF1zXZAmIrJ4qEKXJt5TXfTqsn3G/fovmDVI+Z4gzIb9Hae4enMuXLK/Qr98569WX5zhstVn0WF+Dn5ApscvR2UJbSD0lCUZmJ78rIw/Lmw8PTQYhc2tKwY= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1706518484; c=relaxed/simple; bh=9Ayvf0Bsmvbps5FJ8TPwOfVoFNO+vKRMOROTpapLpas=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=ubFQlZ6JvHLSGnt1EGho7po7PxLc8PDNJ4ZddfAsIEDJqRRCLbPjNwrKC3sizbknioopMuV75/O3/Qe5HpiKQSwZYqLi6NlywQ0Oc+jYvz6WNHkypN4PKis/rRbmpCtn2rLaDOtCqtHLXuouHT+6y/eZOjiTVR0T2i0vgDnHwMI= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=OmJj5NPiSvXbJI3OwC1ewqCimW5bo7CAsaKAsLeXYiH9Vv4WRZPfWSknKQte4rXbUpOeQP09LrEg9pGeSpB7DHIFnCIFobhkzv1S8cWLgX3ahKvdSxCysICpJ4h1Nd3q+wTiPRTf4eCFfuPPupnCnCYxlf3MTWc91XPgGSQdlRWHtayr7dKiUHmkSWIJSk75q+XIBsKmm7Fx7mMsXhYEoU5AuqiQT4pnl/l3D+9TfVEO4hRYhW0kNUICVVtX5feJCI7XRU3JRZ/Db5/nD0QXaY/KSsOf0bumTHaKV9PhJP2b0Oh6hbFgFcEaT183T2FM8TsIkj0wMdAo2MHWuQDu+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=w/Q+du7qHHmOtqu2BNn5PsJ3fTM2IzppQ7E3D5/vKMQ=; b=l7unJa79xMWQvzRGaJ1bHukaaVxzBP0b1VONh8XIBu3T7XuSLlp3QEyBUmz7afDJLOBiF0IpUmIlFrVdxBbEDG8E3feTRdwE0S+TCmsKCxtvQ+CjzxC2CVaOOSR064/ZjBFuorWfgcnX608AuzB3WbDTzjrAAtpZxVu6dxCmSawTCp537eaKPohBnrsbpt0X61zP9Wyc6vB5n5M0UthMS0/AlAFYeA8aEhhPxWsWLaOl1db4XZLSGXVCg5pbtNSbnuwY5KZfdOyQ4jKh8/fAL0658oKSBiSaLWBtMP2dsNyJ3tPdwpl4nxkgSe575VA9mh0MTk9Vy4Qq1nJknSIVzA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w/Q+du7qHHmOtqu2BNn5PsJ3fTM2IzppQ7E3D5/vKMQ=; b=S7P2OSpidW4ATiZPsRud8qN0jUWddyQLqxiQn/S8nW/AqA6Pdc29/3tFCmhbdbPwsgn8uGDX0LrcKQwerYBP7NsegccR8BJ3Ekjq6DRF1uHrWRfDf9ag9iYWvETyYOvfGFzWHvn/wa7pWzOdd0NEoLaEN2z19lYMhG0QWwfFkHs= Received: from AS8PR04CA0102.eurprd04.prod.outlook.com (2603:10a6:20b:31e::17) by GV1PR08MB10479.eurprd08.prod.outlook.com (2603:10a6:150:16b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.32; Mon, 29 Jan 2024 08:54:30 +0000 Received: from AM2PEPF0001C716.eurprd05.prod.outlook.com (2603:10a6:20b:31e:cafe::be) by AS8PR04CA0102.outlook.office365.com (2603:10a6:20b:31e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.32 via Frontend Transport; Mon, 29 Jan 2024 08:54:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM2PEPF0001C716.mail.protection.outlook.com (10.167.16.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Mon, 29 Jan 2024 08:54:29 +0000 Received: ("Tessian outbound 1076c872ecc6:v228"); Mon, 29 Jan 2024 08:54:29 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f5e8fb833ce68a83 X-CR-MTA-TID: 64aa7808 Received: from 6e2844f682bf.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D82AFFAD-3D28-4C89-9952-E378FF0F4C3D.1; Mon, 29 Jan 2024 08:54:22 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6e2844f682bf.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 29 Jan 2024 08:54:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fwNYgJ6Iut/myKobnHPM2lTFvQxwrWpC7TO11VFl/rA921q5dvcM89ivsMwEO2WjG6/vLpcOB4vBHTv/X4BpW02BP42oJSYLvx1Fptxyw2ZAmELo9kNQPnOVesNixSqfd+5oYspaWEoTmfAjeWLm5k4AEEWDFNLNJllOkB2DD+PmNp1T4IEdBz6yfmmyykCeJJ76+a0PVo3e8B4z1f3fMBYs2QettGyDDhIle6DWcUSvqCeJNYp42KnjmrOtsihb2iMYWoIC51KQmsZGdqsE4goXLUSnzgkLrosrn4/LIUo5PfqV80RPE0R0jxqwo7JWurSMvB63Wwhsf/e3vrrylg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=w/Q+du7qHHmOtqu2BNn5PsJ3fTM2IzppQ7E3D5/vKMQ=; b=EW9xErITJaqnLJw/tpfNUROoRnK7jV9JcJbQZMb8IfQFLHTpEO+3yAtrqdIogoNeJCa/QRUXwiG7ql56AjeA6BvNstt6UjgQNFz6bmu7TugMbEbuoNJRWf4sph6oZ/epR8uxBIfiAWP8pYtsYAS4iTaqQxkNNdiePiSI6+HRQBmT3Y94vNT57lSO0d5Zf7z5l7V01uMmSCIo/5G4kNtW5Q945Y0+mWbO9RNwtQXJLZ+M5NN+dUdqBgZLjxUc8HLYEVyKvOalp+YzCSv7IPJp4kwkGiS0mqM4okC1QFrIQ2spoeHNOvnB3cAOhb6/tMKYyLXsjI19TDbXIVw7lsVg0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w/Q+du7qHHmOtqu2BNn5PsJ3fTM2IzppQ7E3D5/vKMQ=; b=S7P2OSpidW4ATiZPsRud8qN0jUWddyQLqxiQn/S8nW/AqA6Pdc29/3tFCmhbdbPwsgn8uGDX0LrcKQwerYBP7NsegccR8BJ3Ekjq6DRF1uHrWRfDf9ag9iYWvETyYOvfGFzWHvn/wa7pWzOdd0NEoLaEN2z19lYMhG0QWwfFkHs= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) by GV2PR08MB8655.eurprd08.prod.outlook.com (2603:10a6:150:b3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.32; Mon, 29 Jan 2024 08:54:18 +0000 Received: from PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::48ca:fbcb:84bf:ed17]) by PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::48ca:fbcb:84bf:ed17%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 08:54:18 +0000 Date: Mon, 29 Jan 2024 08:54:16 +0000 From: Alex Coplan To: gcc-patches@gcc.gnu.org Cc: Richard Earnshaw , Richard Sandiford , Kyrylo Tkachov Subject: [PATCH] aarch64: Ensure iterator validity when updating debug uses [PR113616] Message-ID: Content-Disposition: inline X-ClientProxiedBy: LO4P123CA0552.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:319::14) To PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAWPR08MB8958:EE_|GV2PR08MB8655:EE_|AM2PEPF0001C716:EE_|GV1PR08MB10479:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e1e1430-fe17-4fe8-a164-08dc20a7e7ad x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: NYeEUSpQ99Hdlo5E26el0KP78/9i4sOh5SarlDLFqgiDKXhoe75TbMe2/tyGFxYaHftrZB6tGgBH9ToV52P+ImWBtMFVTTx19bFATFyO65S3z6aCOd/3UrWLXc9NaV6CD+4s3X9wvoaITEr3HgDl+94+pRtve/fBhvfY9XeSQwSrHNGFgglcY8yLIJJrt+dBnwZC0Y+jX8ZoPsKtLd1LLSG3EGBc4ZR8ueVAK5M9wAr0KrHEswyDOagtKQXZIXETWXZ0rT2vUtzAYL4Xow8F9c1T2G7aTByYDGzLDQe8njuCq4XsrRf4EUQwy8wFSCEHpFMXL+3YUuJxJArGUCvzLVRoU0Hy3FpYkzKy2t4CFDPFIiVNEnpz4P/kU63NLhEBF5/hSyzPJlXYox3wbox/n7olM1RR9zNcKXtshVff9JxjFnuUdJCMv5ZdjAkGnfbBp3OycByyoiYfvhmLaXEDPrnkWt0/xM+ASKeDqNwY82l/TMlXRxPJpoEOK1PYvuoAeZNL1N5f8oJGGHwFIEOHPvvKKjHbq2RyDVF5JAIM6+rYzNO8XyHfyf5gx/fu5mzwu50c1aZ7q3Yt0SAa63MZCJBPKcw5s7c3wynM7Gs1mADazfl6oIXiFCSOqg7qHPtf X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAWPR08MB8958.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(346002)(396003)(39860400002)(376002)(136003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(86362001)(38100700002)(21480400003)(83380400001)(26005)(2616005)(6512007)(478600001)(6506007)(44144004)(33964004)(6486002)(316002)(6916009)(54906003)(66476007)(66556008)(66946007)(8676002)(8936002)(4326008)(44832011)(235185007)(2906002)(5660300002)(36756003)(41300700001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8655 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM2PEPF0001C716.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: f11469bf-cc09-4349-dfa3-08dc20a7e0cd X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jZf0mbI1oX1FkH+RclOKbRu4GINktINoAl9VGw5eGo+t7nM7vOBuxNypdKLESfz8cILSR9qpvUlwatI+plrM6/mHUA7Z9T61ySs6h6L0q2Vzc0ubjdrp+BUfYxMk6lb1nYlXpXEnYI6C5RfhrTziRwve3vbx8iZXy9wH31vseiApQRvZRLhW97OWvVvlUyrr3/CkICWU9J3Xzrz+VRFi40a2ZY5vtUZW+6xFr9CLvP2yMBFhUXnY1cTeXzfHcFSNFM/Jk1uhpshAN00iZBIL95jQvbyouNiOrB2pdtw6A+s1moUs05FV22jKagP90sZSO5fnMeb5ih1pxtZdZa+nNZEjUNeApSkTFxxsOLhOtgqsAbCqX26k6GFimnr7eTB0kYlhpL2ohU2w9NFssVRMnr2hAqErdfdYYwDGh00gkKyqq4/NT8uow347LgTZpN/4kFj34ASzY1x7gVrOpWMJnvk6LvTQ17YuI62JII9GmsRxsIzAHo+qNZuRoV/Wgz9EE1CNd9POV4nDEnQ6NPnlKSNh544ISmovuzf1PwXh1OfG7qwOcMt512askn9tKaj27FsiNteIgx7GdWPuvSZbX2wobYHQqUmbrCz5JPS/p7E3fOnzRJQ/VN9ohG/7SpFuJ5GInv3FNfPwRv7CAlte8pD5FXJjhq8ALM/9i/DILUmpUUM1BnIWsUpNGawRWM5H9Y8pOCM6LxPMU95B0oHrj/j23HJgO4kbSyZacsS1IcDeWdra0XXm9winuZ0bzjLAVdqKaNxATOi/N8Qwkk+09A== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230031)(4636009)(346002)(376002)(396003)(136003)(39860400002)(230922051799003)(64100799003)(186009)(82310400011)(451199024)(1800799012)(36840700001)(46966006)(40470700004)(41300700001)(82740400003)(81166007)(356005)(40460700003)(40480700001)(36860700001)(44144004)(70586007)(6506007)(33964004)(54906003)(70206006)(316002)(6916009)(86362001)(6486002)(8676002)(8936002)(47076005)(44832011)(336012)(235185007)(5660300002)(2616005)(6512007)(21480400003)(478600001)(2906002)(4326008)(26005)(83380400001)(36756003)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 08:54:29.7529 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e1e1430-fe17-4fe8-a164-08dc20a7e7ad X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM2PEPF0001C716.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB10479 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789414802745989396 X-GMAIL-MSGID: 1789414802745989396 Hi, The fix for PR113089 introduced range-based for loops over the debug_insn_uses of an RTL-SSA set_info, but in the case that we reset a debug insn, the use would get removed from the use list, and thus we would end up using an invalidated iterator in the next iteration of the loop. In practice this means we end up terminating the loop prematurely, and hence ICE as in PR113089 since there are debug uses that we failed to fix up. This patch fixes that by introducing a general mechanism to avoid this sort of problem. We introduce a safe_iterator to iterator-utils.h which wraps an iterator, and also holds the end iterator value. It then pre-computes the next iterator value at all iterations, so it doesn't matter if the original iterator got invalidated during the loop body, we can still move safely to the next iteration. We introduce an iterate_safely helper which effectively adapts a container such as iterator_range into a container of safe_iterators over the original iterator type. We then use iterate_safely around all loops over debug_insn_uses () in the aarch64 ldp/stp pass to fix PR113616. While doing this, I remembered that cleanup_tombstones () had the same problem. I previously worked around this locally by manually maintaining the next nondebug insn, so this patch also refactors that loop to use the new iterate_safely helper. While doing that I noticed that a couple of cases in cleanup_tombstones could be converted from using dyn_cast to as_a, which should be safe because there are no clobbers of mem in RTL-SSA, so all defs of memory should be set_infos. Bootstrapped/regtested on aarch64-linux-gnu, OK for trunk? Thanks, Alex gcc/ChangeLog: PR target/113616 * config/aarch64/aarch64-ldp-fusion.cc (fixup_debug_uses_trailing_add): Use iterate_safely when iterating over debug uses. (fixup_debug_uses): Likewise. (ldp_bb_info::cleanup_tombstones): Use iterate_safely to iterate over nondebug insns instead of manually maintaining the next insn. * iterator-utils.h (class safe_iterator): New. (iterate_safely): New. gcc/testsuite/ChangeLog: PR target/113616 * gcc.c-torture/compile/pr113616.c: New test. diff --git a/gcc/config/aarch64/aarch64-ldp-fusion.cc b/gcc/config/aarch64/aarch64-ldp-fusion.cc index 932a6398ae3..22ed95eb743 100644 --- a/gcc/config/aarch64/aarch64-ldp-fusion.cc +++ b/gcc/config/aarch64/aarch64-ldp-fusion.cc @@ -1480,7 +1480,7 @@ fixup_debug_uses_trailing_add (obstack_watermark &attempt, def_info *def = defs[0]; if (auto set = safe_dyn_cast (def->prev_def ())) - for (auto use : set->debug_insn_uses ()) + for (auto use : iterate_safely (set->debug_insn_uses ())) if (*use->insn () > *pair_dst) // DEF is getting re-ordered above USE, fix up USE accordingly. fixup_debug_use (attempt, use, def, base, wb_offset); @@ -1544,13 +1544,16 @@ fixup_debug_uses (obstack_watermark &attempt, auto def = memory_access (insns[0]->defs ()); auto last_def = memory_access (insns[1]->defs ()); for (; def != last_def; def = def->next_def ()) - for (auto use : as_a (def)->debug_insn_uses ()) - { - if (dump_file) - fprintf (dump_file, " i%d: resetting debug use of mem\n", - use->insn ()->uid ()); - reset_debug_use (use); - } + { + auto set = as_a (def); + for (auto use : iterate_safely (set->debug_insn_uses ())) + { + if (dump_file) + fprintf (dump_file, " i%d: resetting debug use of mem\n", + use->insn ()->uid ()); + reset_debug_use (use); + } + } } // Now let's take care of register uses, starting with debug uses @@ -1577,7 +1580,7 @@ fixup_debug_uses (obstack_watermark &attempt, // Now that we've characterized the defs involved, go through the // debug uses and determine how to update them (if needed). - for (auto use : set->debug_insn_uses ()) + for (auto use : iterate_safely (set->debug_insn_uses ())) { if (*pair_dst < *use->insn () && defs[1]) // We're re-ordering defs[1] above a previous use of the @@ -1609,7 +1612,7 @@ fixup_debug_uses (obstack_watermark &attempt, // We have a def in insns[1] which isn't def'd by the first insn. // Look to the previous def and see if it has any debug uses. - for (auto use : prev_set->debug_insn_uses ()) + for (auto use : iterate_safely (prev_set->debug_insn_uses ())) if (*pair_dst < *use->insn ()) // We're ordering DEF above a previous use of the same register. update_debug_use (use, def, writeback_pat); @@ -1622,7 +1625,8 @@ fixup_debug_uses (obstack_watermark &attempt, // second writeback def which need re-parenting: do that. auto def = find_access (insns[1]->defs (), base_regno); gcc_assert (def); - for (auto use : as_a (def)->debug_insn_uses ()) + auto set = as_a (def); + for (auto use : iterate_safely (set->debug_insn_uses ())) { insn_change change (use->insn ()); change.new_uses = check_remove_regno_access (attempt, @@ -2921,26 +2925,16 @@ ldp_bb_info::cleanup_tombstones () if (!m_emitted_tombstone) return; - insn_info *insn = m_bb->head_insn (); - while (insn) + for (auto insn : iterate_safely (m_bb->nondebug_insns ())) { - insn_info *next = insn->next_nondebug_insn (); if (!insn->is_real () || !bitmap_bit_p (&m_tombstone_bitmap, insn->uid ())) - { - insn = next; - continue; - } + continue; - auto def = memory_access (insn->defs ()); - auto set = dyn_cast (def); - if (set && set->has_any_uses ()) + auto set = as_a (memory_access (insn->defs ())); + if (set->has_any_uses ()) { - def_info *prev_def = def->prev_def (); - auto prev_set = dyn_cast (prev_def); - if (!prev_set) - gcc_unreachable (); - + auto prev_set = as_a (set->prev_def ()); while (set->first_use ()) crtl->ssa->reparent_use (set->first_use (), prev_set); } @@ -2948,7 +2942,6 @@ ldp_bb_info::cleanup_tombstones () // Now set has no uses, we can delete it. insn_change change (insn, insn_change::DELETE); crtl->ssa->change_insn (change); - insn = next; } } diff --git a/gcc/iterator-utils.h b/gcc/iterator-utils.h index a3f7dd5384d..af1463b0cfb 100644 --- a/gcc/iterator-utils.h +++ b/gcc/iterator-utils.h @@ -200,4 +200,77 @@ list_iterator::operator++ (int) return ret; } +// An iterator that pre-computes the next value if we haven't already got to the +// end. This is useful in cases where a standard iterator would get invalidated +// (e.g. elements getting removed from a container) during the body of a loop. +template +class safe_iterator +{ + T m_current; + const T m_end; + T m_next; + + T get_next () + { + if (m_current != m_end) + { + // FIXME: we should use std::next here but that would mean having + // #include everywhere that iterator-utils.h is included. + // + // For now we just implement it directly. + T iter = m_current; + return ++iter; + } + return m_end; + } + + void advance () + { + m_current = m_next; + if (m_next != m_end) + ++m_next; + } + +public: + bool operator== (const safe_iterator &other) const + { + return m_current == other.m_current; + } + + bool operator!= (const safe_iterator &other) const + { + return m_current != other.m_current; + } + + typename T::value_type operator*() const { return *m_current; } + + safe_iterator &operator++ () + { + advance (); + return *this; + } + + safe_iterator operator++ (int) + { + auto ret = *this; + advance (); + return ret; + } + + safe_iterator (T iter, T end) + : m_current (iter), m_end (end), m_next (get_next ()) {} +}; + +// Convert a container RANGE into a container of safe_iterators. +template +inline +iterator_range> +iterate_safely (Container range) +{ + return { + { range.begin (), range.end () }, + { range.end (), range.end () } + }; +} + #endif diff --git a/gcc/testsuite/gcc.c-torture/compile/pr113616.c b/gcc/testsuite/gcc.c-torture/compile/pr113616.c new file mode 100644 index 00000000000..04c38eadffb --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr113616.c @@ -0,0 +1,19 @@ +// { dg-do compile } +// { dg-options "-g" } +struct A { struct A *a; } foo (); +struct B { long b; }; +struct C { struct B c; struct A d; } *e; + +void +bar (void) +{ + int f; + struct C *g; + struct A *h; + for (g = 0, g = e ? (void *) e - (char) (__SIZE_TYPE__) &g->d : 0, h = g ? (&g->d)->a : 0; g; + g = 0, g = h ? (void *) h - (char) (__SIZE_TYPE__) &g->d : 0, h = h ? h->a : 0) + { + f = (int) (__SIZE_TYPE__) g; + foo (((struct B *) g)->b); + } +}