[LLVMdev] Testing canaries
Duncan Sands
baldrick at free.fr
Sat Jan 26 08:47:03 PST 2013
Hi Izabela,
On 21/01/13 18:37, Izabela Maffra wrote:
> Dear LLVMers,
>
> I am trying to measure the performance overhead (if any) of the canaries
> that clang inserts in the code. I would like to do this automatically, using the
> LLVM test infra-structure. However, I am not sure if that is possible. Could
> someone tell me which flags in the TEST.nightly.Makefile script, (or any other
> script) I must change to have this done? Usually I insert canaries with the
> following command line:
>
> $> clang -S -fstack-protector hello.c
>
> But I would like to know which part of LLVM calls the pass that inserts the
> canaries. It seems it is llc, as the pass that inserts the canaries is in
> /lib/CodeGen/StackProtector.cpp. Yet, I cannot see 'fstack-protector' in the llc
> --help list, although I can see 'stack-protector-buffer-size' in llc --help.
the -fstack-protector option is processed by the clang front-end. If you grep
for stack-protector in the clang source, you will discover that the action is
happening in clang/lib/Driver/Tools.cpp, here:
if (StackProtectorLevel) {
CmdArgs.push_back("-stack-protector");
CmdArgs.push_back(Args.MakeArgString(Twine(StackProtectorLevel)));
}
The argument -stack-protector is for the code generators, and you should find
that llc has the same argument. However if you look for it it doesn't seem to
exist:
$ llc -help | grep stack-protector
-stack-protector-buffer-size=<uint> - Lower bound for a buffer to be
considered for stack protection
What is going on? Some options aren't considered generally useful and are
hidden. If you use -help-hidden you get to see all options:
$ llc -help-hidden | grep stack-protector
=stack-protector - Insert stack protectors
=stack-protector - Insert stack protectors
-stack-protector-buffer-size=<uint> - Lower bound for a buffer to be
considered for stack protection
There it is! It's not clear to me why -stack-protector is hidden away like
that. Hidden options work just the same as visible options: just pass
-stack-protector to llc.
Ciao, Duncan.
More information about the llvm-dev
mailing list