Re: LLVM 16 (opaque pointers) - Mailing list pgsql-hackers

From Andres Freund
Subject Re: LLVM 16 (opaque pointers)
Date
Msg-id 20231013145510.aq3qiqig6rw5x72v@awork3.anarazel.de
Whole thread Raw
In response to Re: LLVM 16 (opaque pointers)  (Dmitry Dolgov <9erthalion6@gmail.com>)
List pgsql-hackers
Hi,

On 2023-10-13 11:06:21 +0200, Dmitry Dolgov wrote:
> > On Thu, Oct 12, 2023 at 04:31:20PM -0700, Andres Freund wrote:
> > I also don't think we should add the mem2reg pass outside of -O0 - running it
> > after a real optimization pipeline doesn't seem useful and might even make the
> > code worse? mem2reg is included in default<O1> (and obviously also in O3).
> 
> My understanding was that while mem2reg is included everywhere above
> -O0, this set of passes won't hurt. But yeah, if you say it could
> degrade the final result, it's better to not do this. I'll update this
> part.

It's indeed included anywhere above that, but adding it explicitly to the
schedule means it's excuted twice:

echo 'int foo(int a) { return a / 343; }' | clang-16 -emit-llvm -x c -c -o - -S -|sed -e 's/optnone//'|opt-17
-debug-pass-manager-passes='default<O1>,mem2reg' -o /dev/null 2>&1|grep Promote
 
Running pass: PromotePass on foo (2 instructions)
Running pass: PromotePass on foo (2 instructions)

The second one is in a point in the pipeline where it doesn't help. It also
requires another analysis pass to be executed unnecessarily.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Dmitry Dolgov
Date:
Subject: Re: LLVM 16 (opaque pointers)
Next
From: Andres Freund
Date:
Subject: Re: LLVM 16 (opaque pointers)