introduce flag -fsanitize-address-detect-stack-use-after-return-mode. No functional change.
for issue: https://github.com/google/sanitizers/issues/1394
Details
- Reviewers
vitalybuka
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This review doesn't make sense to me. Why add a flag that isn't affecting anything? Why add a flag that isn't even tested?
I'm new here.
I was told to take small steps.
This will eventually effect compiler-rt and llvm.
I took the smallest possible step.
What I had previously: https://reviews.llvm.org/D99630
And was told it was too large.
There are two approaches that work for reviewing: starting from clang and going down or starting from compiler-rt and going up the layers. I'd prefer to do the latter as it means meaningful testing can be done easier. There are two natural steps here: clang flag+IR generation is one, llvm codegen and compiler-rt is the other. The clang step should include tests that ensure that proper IR is generated for the different flag combination (including documentation for the IR changes). The LLVM step should ensure that the different attributes (either function or module scope) are correctly lowered in the instrumentation pass and unit tests on the compiler-rt side to do functional testing. The unit testing might also be done as a third step if it goes the full way from C to binary code.
Today on chat I advised to start with clang, but now I agree with Joerg. More precisely you can go with following 4 patches:
- LLVM Detailed IR tests of effect of this flag on transformation
- compiler-rt (tests will have to uses -mllvm -<internal asan copt>)
- clang
- driver tests
- basic IR tests to see that flag makes a difference of generated code. see llvm-project/clang/test/CodeGen/asan-*.cpp
- compiler-rt: replace -mllvm copt from patch2 with with clang flag from patch3.
clang/include/clang/Basic/CodeGenOptions.def | ||
---|---|---|
225 | Mode->Kind to be consistent with the file | |
225–228 | I believe for consistency we need:
BTW. @delcypher -fsanitize-address-destructor-kind was not consistent with the rest of file, but I am not sure it's worth of fixing now. | |
clang/include/clang/Driver/Options.td | ||
1555 | same order as enum | |
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h | ||
29 | Could you order them in acceding order by "strictness", this will make Never == 0, and the current default == 1. |
Thank you for delineating the steps.
Unfortunately, I don't know where to even start looking for the tests you mention in step 1. Are you looking for something like this: https://reviews.llvm.org/differential/changeset/?ref=2496958
For the 3 files I have here, which step are they in? (Step 1?)
clang/include/clang/Basic/CodeGenOptions.def | ||
---|---|---|
225–228 | @vitalybuka It's not too late to fix this because the -fsanitize-address-destructor-kind= flag hasn't been adopted yet AFAIK. Am I right in understanding that what I landed doesn't match points 1 and 3 above? If you can confirm that's what you'd like to be changed I can put up some patches to fix this. |
clang/include/clang/Basic/CodeGenOptions.def | ||
---|---|---|
225–228 | Correct ENUM_CODEGENOPT(SanitizeAddressDtor, llvm::AsanDtorKind, 2, llvm::AsanDtorKind::Global) and def sanitize_address_destructor_EQ : Joined<["-"], "fsanitize-address-destructor=">, MetaVarName<"<kind>">, Flags<[CC1Option]>, HelpText<"Set destructor type used in ASan instrumentation">, Group<f_clang_Group>, Values<"none,global">, NormalizedValuesScope<"llvm::AsanDtorKind">, NormalizedValues<["None", "Global"]>, MarshallingInfoEnum<CodeGenOpts<"SanitizeAddressDtor">, "Global">; And one more thing, probably not very important, and matter of personal preferences. |
clang/include/clang/Basic/CodeGenOptions.def | ||
---|---|---|
225–228 | @vitalybuka I put up the following patches for review https://reviews.llvm.org/D101490 |
Mode->Kind to be consistent with the file