From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by sourceware.org (Postfix) with ESMTPS id 00E373858C78 for ; Fri, 29 Sep 2023 15:49:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 00E373858C78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-5033918c09eso22353953e87.2 for ; Fri, 29 Sep 2023 08:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696002586; x=1696607386; darn=gcc.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=0MbS/eY/XkzpnQi5i9aKN+BrWXvQBKN6cbigEzRGKNo=; b=S7dcYCLNNTENlr1BQ1k2Npr8o5j49ddEm8LtNHOzE4Cts/xWPZyxgkHJcnb0GtJnrb PNSFsk9CQdQflu4aMZdk1TbLYceUCkOw6+b6ETravwQMGN3V9XAnmQfAUZnDgD+76pKl rk4+49AOveyW3q8/VWrgL7RN+WdolfegYVW2z+001UDYxh/udmfrIjP3yxaoGur6avI1 NjsiUk6FpvtZSy1xTsFAkojCHSmRFgXb3RVqQCIOW1K3hTll30Q0LzpFRlfD2JdXItve NjWYPzGQNy+E+1mPWAa87IUbK+JDutwHBVv7XVA4xdeE30+zi0L49B/B1ACWA/F2zusy HSgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696002586; x=1696607386; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=0MbS/eY/XkzpnQi5i9aKN+BrWXvQBKN6cbigEzRGKNo=; b=TdRJ/ldf6nt4vPhXl3LNtuSU4Pu/jccoQ6eoqhyrtQrvpkK5Fi/w5VwQ8cy9y1s2ff gXOAxREl1hcfMpX7XQgrZYC2msZEXe/u37VhfEXiBLN8oK8tg+u8AvLG3ZmP9c+bIx6Y Gwt1hbDCO1aoRdMj3LwpLhcBJAgjOEgk/iIV+gO3LpdoEmGTu3Q9QAML/MeN7Gu/oudi pzM5D0Qj7xRU19pyykaIvQccWkNnIgNHvdXwExlRgNJ1gSIFcWmuzFm+yj1Z10HuBmU/ bIn4rIPaTxputXemJutsuxoPDIychhGz1j1NpSIwClhPvNwhRT6C6jR3ZGn/anOTyeKe zgpg== X-Gm-Message-State: AOJu0YwhA8Zb429D51hPsIgk4BVIWjzDb2hVTLda0d4doZF0/2RoASDg aMNgQytUbf4ZYA0nPK3I0laqpKVFJhf3WOqV1jAZXlb3AvrJzQ== X-Google-Smtp-Source: AGHT+IE5+SIQssLOUOlStQGC0nrhJ1THhZw6YRhK2qNnvv4/wdkoNwpITJnEbMR23/zrK7PNlltPaXjZp9GxXpV/db4= X-Received: by 2002:ac2:58e1:0:b0:503:35af:3058 with SMTP id v1-20020ac258e1000000b0050335af3058mr3401744lfo.52.1696002585701; Fri, 29 Sep 2023 08:49:45 -0700 (PDT) MIME-Version: 1.0 From: Hanke Zhang Date: Fri, 29 Sep 2023 23:49:34 +0800 Message-ID: Subject: Check whether the global variable has been modified in a function or some blocks To: gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi, I have recently been working on issues related to the changing values of global variables. That is, I was trying to develop a gimple pass, which needs to check whether the value of a global variable is modified in the a function or some blocks. Some of the more tricky cases are as follows: int type; // global variable void foo() { int tmp; tmp = type; // store type in tmp type = 0; // do other things // type will be used or changed // ... type = tmp; return; } Obviously, this function does not modify the value of type, but from the compiler's point of view, it seems not so obvious. I'd like to ask is there any good way to solve it? Or does gcc provide some ready-made implementations to use already?