This is an archive of the discontinued LLVM Phabricator instance.

Implement command line options for stack probe space
ClosedPublic

Authored by AndrewH on Dec 16 2014, 11:20 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

AndrewH updated this revision to Diff 17345.Dec 16 2014, 11:20 AM
AndrewH retitled this revision from to Implement command line options for stack probe space.
AndrewH updated this object.
AndrewH edited the test plan for this revision. (Show Details)
AndrewH set the repository for this revision to rL LLVM.
AndrewH added a subscriber: Unknown Object (MLST).

Like the bug this bug depends on: I took the liberty to add some reviewers based on the commit history. Is anything blocking this? I would be happy to help.

hans added a subscriber: hans.Dec 19 2014, 10:17 AM

Thanks! I think this looks good. Please also add a test for the /Gs alias in test/Driver/cl-options.c, and remove it from the "Unsupported but parsed" section.

AndrewH updated this revision to Diff 17622.Dec 24 2014, 1:08 AM

Added some management code to make the special case -mstack-probe-size=0 work. Current behavior is that when -mstack-probe-size is omitted, the X86 target will choose the default stack probe size (which is currently 4096 bytes, but I did not want to expose such internal technicalities to the driver). When -mstack-probe-size=n is used, the X86 target will use a stack probing size of n bytes. Note that in contrast to the stack alignment parameter, n=0 is a valid value for the stack probing size.

Added the test cases to cl-options.c.

AndrewH updated this revision to Diff 17635.Dec 25 2014, 9:41 PM

Update revision due to changes in dependency D6684.

AndrewH updated this revision to Diff 17642.Dec 26 2014, 2:52 PM

Again: Update revision due to changes in dependency D6684.

AndrewH updated this revision to Diff 17661.Dec 28 2014, 3:24 PM

Fixed handling in case of x86_64-pc-windows-msvc target.

AndrewH updated this revision to Diff 17852.Jan 7 2015, 4:14 AM

Again: Update revision due to changes in dependency D6685.

majnemer added inline comments.
include/clang/Frontend/CodeGenOptions.def
144–145 ↗(On Diff #17852)

Why not just make StackProbeSize default to 4096 and get rid of IsStackProbeSizeOverridden. Then you can get rid of IsStackProbeSizeOverridden.

After all that, only add the "stack-probe-size" attribute to the function if the StackProbeSize is not equal to 4096.

lib/CodeGen/TargetInfo.cpp
1637 ↗(On Diff #17852)

This should start with a lower case letter and be marked as static.

1638–1640 ↗(On Diff #17852)

This doesn't look correctly formatted for the coding style.

1644 ↗(On Diff #17852)

This looks unused.

1646 ↗(On Diff #17852)

I don't think we can use std::to_string. IIRC, some platforms don't have it yet.

Please use llvm::utostr instead. It is in "llvm/ADT/StringExtras.h"

1654 ↗(On Diff #17852)

Please do the same for the X86_64 side so nothing mysterious happens if somebody adds an implementation of SetTargetAttributes.

lib/Driver/Tools.cpp
3723 ↗(On Diff #17852)

Size should be capitalized.

3725 ↗(On Diff #17852)

Space between the if and the (

lib/Frontend/CompilerInvocation.cpp
518–520 ↗(On Diff #17852)

Braces should be right next to the else.

AndrewH updated this revision to Diff 17925.Jan 9 2015, 6:41 AM

Why not just make StackProbeSize default to 4096 and get rid of IsStackProbeSizeOverridden. Then you can get rid of IsStackProbeSizeOverridden.
After all that, only add the "stack-probe-size" attribute to the function if the StackProbeSize is not equal to 4096.

I could see the problem that this would expose a (somewhat) magic constant to the frontend, whereas only the backend knows what sane default size should be used. StackAlignment has the same problem, but it can use 0 to indicate the usage of the default value, thus it does not need an Is...Overridden code gen option.

So the question is whether we should duplicate that magic value of 4096 for both frontend and backend. You can make that decision; I have no preference and I am very pragmatic on that issue.

Please do the same for the X86_64 side so nothing mysterious happens if somebody adds an implementation of SetTargetAttributes.

Please be aware that WinX86_32TargetCodeGenInfo inherits from X86_32TargetCodeGenInfo (which in turn inherits from TargetCodeGenInfo), whereas WinX86_64TargetCodeGenInfo directly inherits from TargetCodeGenInfo. Thus I have added a call to TargetCodeGenInfo::SetTargetAttributes.

AndrewH updated this revision to Diff 18254.EditedJan 15 2015, 1:46 PM

And this is the version without IsStackProbeSizeOverridden but with 4096 as a somewhat magic number in clang.

The two revisions that can be considered for submission are:
Diff 17925: No 4096, but with IsStackProbeSizeOverridden.
Diff 18254: With 4096, but no IsStackProbeSizeOverridden.

Could please some look over these revisions and decide which one could be applied to the trunk?

majnemer accepted this revision.Jan 15 2015, 1:55 PM
majnemer added a reviewer: majnemer.

LGTM with nits fixed.

include/clang/Driver/CLCompatOptions.td
65 ↗(On Diff #18254)

Please remove trailing whitespace here.

include/clang/Frontend/CodeGenOptions.def
141 ↗(On Diff #18254)

Please remove trailing whitespace here.

lib/CodeGen/TargetInfo.cpp
1639 ↗(On Diff #18254)

You don't actually use the result of the dyn_cast, please use isa instead.

This revision is now accepted and ready to land.Jan 15 2015, 1:55 PM
hans accepted this revision.Jan 15 2015, 2:03 PM
hans added a reviewer: hans.

lgtm too

AndrewH updated this revision to Diff 18257.Jan 15 2015, 2:29 PM
AndrewH edited edge metadata.

Fixed.

To majnemer or hans: Could you push the last revision to trunk? I do not have any commit rights. Thanks!

This revision was automatically updated to reflect the committed changes.