[LLVMdev] Let's get rid of neverHasSideEffects

Jim Grosbach grosbach at apple.com
Tue Aug 21 14:49:07 PDT 2012


On Aug 21, 2012, at 2:02 PM, Jakob Stoklund Olesen <stoklund at 2pi.dk> wrote:

> All,
> 
> TableGen likes to infer the MCID::UnmodeledSideEffects flag from an instruction's pattern. When an instruction doesn't have a pattern, it is assumed to have side effects.
> 
> It's possible to override this behavior by setting neverHasSideEffects = 1.
> 
> It was originally the intention that most instructions have patterns, but that's not the way it worked out. It is often more convenient to use def : Pat<>, and sometimes custom instruction selection is required.
> 
> As a result, many instructions are defined without a pattern, and we often forget to set neverHasSideEffects = 1.
> 
> $ grep -c UnmodeledSideEffects lib/Target/*/*GenInstrInfo.inc
> lib/Target/ARM/ARMGenInstrInfo.inc:727
> lib/Target/X86/X86GenInstrInfo.inc:920
> 
> I don't think more than half of those UnmodeledSideEffects flags should be there.
> 
> 
> I want to stop inferring instruction properties from patterns in TableGen. It has become very hard to read instruction definitions when some properties are inferred, but only half the time.

Yes, please. This does get a bit more complicated for properties like mayLoad, mayStore and such, but I still like requiring them to be explicit, personally. When there's a pattern on the instruction, we can check for semantic mismatches and throw an error if we find one.

> 
> We can still use any patterns to emit TableGen warnings. If an instruction has a sideeffecting pattern, but hasSideEffects isn't set, TableGen should complain.
> 
> I can't just kill off the neverHasSideEffects flag, that could cause miscompilations by clearing the UnmodeledSideEffects bit on instructions that should have it.
> 
> Any suggestions for a clean transition? I was thinking about first adding a -Winfer flag that warns whenever TableGen infers a property that wasn't already set in the .td file.
> 
I like that. Possibly with the addition that we can filter by a specific property. -Winfer=neverHasSideEffects, e.g., would only show when that specific property is inferred.

Beyond that, I don't see an alternative to an audit of the instructions that get flagged by such a warning. :(

-Jim

> /jakob
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list