From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3182 invoked by alias); 30 Aug 2018 07:06:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 3172 invoked by uid 89); 30 Aug 2018 07:06:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=HX-Received:Thu, friend X-HELO: mail-wm0-f66.google.com Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Aug 2018 07:06:21 +0000 Received: by mail-wm0-f66.google.com with SMTP id c14-v6so805515wmb.4 for ; Thu, 30 Aug 2018 00:06:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lrN+oh+MY34Uag8Nz365RWiuVxoTHee2emwOnqLX8lw=; b=m0hejU1H84FxD9irqgEpBdJFRIvIvpHPlv1UOCP3Ik+VJHWgyfHycF7bvxmxI7GLRb 3rwzU/fogjyv0jjGpq0vie+LIeQeiw9M11XuGxxpQJ4foUHMKwbHeo0OSlvabI1yRXZJ Owg9TdV//vU578EKOMywEmCSE3hp80VCxP7qjIe+ePNfNg2LKx5sS1uSE4x7AqnJvU6Z RpU0dPGwKx953lMpJ+auni6TFJX/GtnIe59JPohoUUjafcrM20G9KNNzEWEUK8rTKUuz MuLTVHRFlMhGqjP+vwRiRRXzI/M/EY2kCMwhgRO8FNM2URMzjKJVFo5iHNsk6hZjf6FH IjDg== MIME-Version: 1.0 References: <20180829180259.2718-1-andrew.burgess@embecosm.com> <87in3svb54.fsf@tromey.com> In-Reply-To: <87in3svb54.fsf@tromey.com> From: Ruslan Kabatsayev Date: Thu, 30 Aug 2018 07:06:00 -0000 Message-ID: Subject: Re: [PATCH] gdb: Ensure compiler doesn't optimise variable out in test To: tom@tromey.com Cc: palmer@sifive.com, Andrew Burgess , gdb-patches@sourceware.org Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00815.txt.bz2 On Thu, 30 Aug 2018 at 05:31, Tom Tromey wrote: > > >>>>> "Palmer" == Palmer Dabbelt writes: > > Palmer> Isn't the compiler still free to kill "a" here because it can see into > Palmer> use_a() and therefor inline it? I'd expected it to choose to inline > Palmer> use_a(), as doing nothing is always cheaper than calling a function. > > It is but in practice gdb compiles without optimization in most cases > and compilers generally don't bother in that situation. Though if > there's a readily available, more principled fix, that would be fine > too. volatile is your friend when trying to make the compiler believe it doesn't know something :) volatile SVAL use_a=a; > > Tom