r187617 - Use function attributes to indicate if we don't want to realign the stack.

Bill Wendling isanbard at gmail.com
Mon Aug 5 11:29:03 PDT 2013


On Aug 2, 2013, at 3:22 PM, Nick Lewycky <nlewycky at google.com> wrote:

> On 2 August 2013 13:57, Bill Wendling <isanbard at gmail.com> wrote:
> On Aug 2, 2013, at 12:57 PM, Nick Lewycky <nlewycky at google.com> wrote:
> 
> > On 1 August 2013 14:41, Bill Wendling <isanbard at gmail.com> wrote:
> > Author: void
> > Date: Thu Aug  1 16:41:02 2013
> > New Revision: 187617
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=187617&view=rev
> > Log:
> > Use function attributes to indicate if we don't want to realign the stack.
> >
> > Modified:
> >     cfe/trunk/lib/CodeGen/BackendUtil.cpp
> >     cfe/trunk/lib/CodeGen/CGCall.cpp
> >
> > Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=187617&r1=187616&r2=187617&view=diff
> > ==============================================================================
> > --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Aug  1 16:41:02 2013
> > @@ -451,7 +451,6 @@ TargetMachine *EmitAssemblyHelper::Creat
> >    Options.UnsafeFPMath = CodeGenOpts.UnsafeFPMath;
> >    Options.UseSoftFloat = CodeGenOpts.SoftFloat;
> >    Options.StackAlignmentOverride = CodeGenOpts.StackAlignment;
> > -  Options.RealignStack = CodeGenOpts.StackRealignment;
> >    Options.DisableTailCalls = CodeGenOpts.DisableTailCalls;
> >    Options.TrapFuncName = CodeGenOpts.TrapFuncName;
> >    Options.PositionIndependentExecutable = LangOpts.PIELevel != 0;
> >
> > Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=187617&r1=187616&r2=187617&view=diff
> > ==============================================================================
> > --- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Aug  1 16:41:02 2013
> > @@ -1084,6 +1084,9 @@ void CodeGenModule::ConstructAttributeLi
> >
> >      FuncAttrs.addAttribute("no-frame-pointer-elim-non-leaf",
> >                             llvm::toStringRef(NoFramePointerElimNonLeaf));
> > +
> > +    if (!CodeGenOpts.StackRealignment)
> > +      FuncAttrs.addAttribute("no-realign-stack");
> >    }
> >
> > This is not what mstackrealign does. There are three stack realignment modes, on off and forced. -mstackrealign forces a stack alignment to occur on entry to every function. no-realign-stack (off) forbids realigning stack even if you put a stack object on the stack which requires a higher alignment than the stack provides.
> >
> The flag that I replaced was a boolean flag (see r187618). It was turned on by default and only turned off when the CodeGenOpts.StackRealignment value was turned `false.' From what I can tell, it didn't have a third state. However, I may have uncovered a bug of some sort. Send me a test case and I can adjust this for you. :)
> 
> Understood. At the driver level there's -mstackrealign/[nothing]/-mno-stackrealign which maps to the cc1 flags "-mstackrealign -force-align-stack"/"-mstackrealign"/[nothing] respectively. Each of those cc1 flags is indeed a boolean.
> 
> After much analysis, we've determined that our stack misalignment bug is actually in libstdc++ and not triggered by your change at all, despite showing up at the exactly the same time. Sorry Bill! I owe you a beer!
> 
I'm never one to refuse a free beer! But it's understandable why you thought it was my patch, and I'm not at all upset about it. So no worries. :-)

-bw






More information about the cfe-commits mailing list