Segher Boessenkool <seg...@kernel.crashing.org> writes: > Hi! > > On Tue, Oct 15, 2019 at 05:15:07PM +0800, Jiufu Guo wrote: >> And another issue: Behavior is still inconsistent between "-mno-vsx >> -flto" and "-mno-vsx" for user code. Previous patch makes it consistent >> between "-mvsx -flto" and "-mvsx". > >> $GCC_BUILD/gcc/xgcc -B$GCC_BUILD/gcc novsx.c -O2 -mno-vsx >> /home/guojiufu/temp/novsx.c: In function 'main': >> /home/guojiufu/temp/novsx.c:6:1: error: inlining failed in call to >> 'always_inline' 'foo': target specific option mismatch > > So what should we do about this? There are arguments for *both* > behaviours, and apparently with LTO we do not know which flags are > explicit? With LTO, rs6000_isa_flags_explicit and rs6000_isa_flags are also checkable. rs6000_isa_flags indicates effective features; bits of rs6000_isa_flags_explicit indicate if it is specified explicitly.
The difference between 'with LTO' and 'without LTO' is: Wit LTO, if a function does not have target attribute in source code, then using option attribute from command line(e.g. -mcpu=xxx) as isa_flags; and if features (e.g. -mno-vsx, -mvsx) are specified on command line, isa_flags_explicit is also set. If a function has target attribute in source code explicitly, then isa_flags_explicit is set to reflect feature is specified explicitly besides explicit features from command line; and isa_flags is set as the effective features. Without LTO, if a function does not have target attribute in source code, then it's isa_flags_explicit and isa_flags are as NULL (target_options == NULL). If a function has target attribute in source code, it is same as 'with LTO'. > >> + /* Propogate global flags to caller. */ >> + HOST_WIDE_INT caller_isa = rs6000_isa_flags; > > I don't think that is right, or, I don't see why, anyway? Propogating global flags is exiting behavior for function during LTO compiling; and global flags are also used to caculate isa_flags/isa_flags_explicit for function which has target attribute in source code. So, it would make sense to using global flags for caller here. One more exmaple to explain this: For example a function "int foo () {xxxxx;}", to compile it using command "gcc -mcpu=power8 -mno-vsx"; we should using power8+no-vsx instructions for this function. > >> + >> + if (((caller_isa & callee_isa) == callee_isa) >> + && (caller_isa & explicit_isa) == (callee_isa & explicit_isa)) >> + ret = true; >> + } > > > Segher