Adds support for this flag. There is also another piece for llvm (separate review). More info: https://bugs.llvm.org/show_bug.cgi?id=36221
Related: D43107
Differential D43108
Support for the mno-stack-arg-probe flag nruslan on Feb 8 2018, 6:00 PM. Authored by
Details
Adds support for this flag. There is also another piece for llvm (separate review). More info: https://bugs.llvm.org/show_bug.cgi?id=36221 Related: D43107
Diff Detail
Event TimelineComment Actions I see in the PR that matches a MinGW flag, but I'm curious to the motivation here. In what scenario would the user want to use this, i.e. how do they know it's safe to drop the probes?
Comment Actions
Comment Actions @hans: One real-world example is when it is used to compile UEFI code using PE/COFF targets natively. Obviously, UEFI uses ABI which is basically almost the same as MS ABI, except that chkstk is not used. It mostly works (I actually was able to get it running) except the cases when the code contains variable-sized arrays allocated on stacks. Unfortunately, stack-probe-size will only help with fixed sized array but will not help to solve the problem described in the bug description since stack usage is unknown at compile time. MinGW does not have this problem because it provides this flag. @MatzeB : there is a test on LLVM side (related review). Do you think the test is needed for clang side? If so, please let me know, what kind of test it is supposed to be. Comment Actions I see, interesting. Might be worth mentioning in the commit message for others wondering what the flag is useful for.
Yes please, I think think there should be on in test/Driver/ to check that forwarding the flag to cc1 (and if we have a -mno-foo, there should maybe be a -mfoo variant too?), and a test in test/CodeGen/ to check that the attribute gets put on the functions correctly. Perhaps r321992 is a good example to look at. Comment Actions Added mstack-arg-probe, tests, and changes related to other comments of the reviewers
Comment Actions @hans, @craig.topper, @MatzeB: Can someone commit D43108 (this) and D43107 on my behalf? I do not think, I have commit access. Comment Actions Can we clarify the meaning of this option a bit. The doc you've added here is saying that -mno-stack-arg-probe disables stack probes. Then what does -mstack-arg-probe mean specifically? Does it mean that only stack probes for ABI required reasons are enabled, or probes are done even in cases where the ABI doesn't require them? Either way, the doc needs to be clearer on the exact purpose. I'm currently working on enabling stack probes for reasons other than ABI, and so if the answer is that this option is only concerned with ABI, we will need another option like -fstack-check. Comment Actions @aemerson : I am not 100% sure, but I think you are talking about different flag. This commit is for supporting a flag to disable stack probes (identical flag can be found in MinGW), it basically only applies to PE/COFF (Windows) targets. It can be useful to compile UEFI code. By default, Windows will use check probes of 4K in x86. A related stack-probe-size allows to vary the size of stack probes. This one completely disables them. By default, stack probes are enabled (i.e., -mstack-arg-probe is the default behavior) and have the size of 4K in x86. Comment Actions This part what I wanted to clarify, -mstack-probe-arg is enabling stack probes if the ABI requires it only, not for other reasons like security. |
I'd suggest perhaps "addStackProbeTargetAttributes" as a name instead, since I'm not sure what Params is for.