Created MCTargetOptions structure which affects instrumentation of inline assembly. Currently MCTargetOptions contains only type of assembly instrumentation (address for now) and is exposed to target asm parsers.
Blacklist needs to live somewhere with a longer lifetime.
Also, we need a "more global" place anyway to pass down -fsanitize=(address|memory|thread) setting for top-level assembly.
I suggest looking at EmitAssemblyHelper::CreateTargetMachine() in clang.
We could add a field (or several fields) to llvm::TargetOptions to pass through the sanitizer to run (if any) and, potentially, all the information that is currently passes through *SanitizerPass constructor arguments, like blacklist pass, MSanTrackOrigins, etc.
MCCodeGenInfo also looks like a good place for blacklist to live in.
/// CodeGenInfo - Low level target information such as relocation model. /// Non-const to allow resetting optimization level per-function.
This would enable not yet well tested asm instrumentation by default.
I think it's better to keep the flag name positive, and off by default (for now).
This would read and parse the blacklist anew for every machine function.
The whole AsmParser is created from scratch for every inline asm instruction, so it's not a good owner for the blacklist.
- Updating D3106: MachineFunction is exposed to X86AsmParser. #
- Enter a brief description of the changes included in this update.
- The first line is used as subject, next lines as comment. #
- If you intended to create a new revision, use:
- $ arc diff --create
Added const attribute to STI.
I still think that bitfields work better here, even though there may be incompatible instrumentation modes.
Where is the definition of this constructor?
What happens to MCTargetOptions without the corresponding clang patch. They should default to no instrumentation.
|111 ↗||(On Diff #8298)|
Why? Options is a public member.
Investigating why compilation of llvm-c-test fails.
Sorry, I forget to upload a source file. Fixed.
|111 ↗||(On Diff #8298)|
Deleted, thanks. This class don't have an internal state now, so it's ok to omit void copy ctor and copy operator.
|13 ↗||(On Diff #8310)|
Please move it back.
|386 ↗||(On Diff #8310)|
Looks like we need a setter method to support -fsanitize-backlist= in clang.
So, this change now does 2 things:
- adds SanitizeAddress flag to TargetOptions (wrapped in MCTargetOptions)
- passes current MachineFunction to X86AsmInstrumentation
This effectively lets us take into account sanitize_address function attribute when instrumenting inline asm.
This also lets us apply blacklist when instrumenting .s files by runnning SpecialCaseList in cc1as and setting the bit in TargetOptions. That would be done in a future patch.
This patch looks OK to me.
Does anyone have any objections to the TargetOptions/MCTargetAsmParser changes?
Can this go on the asm streamer?
Do you expect this class to grow? Why have a class with only one field?
We normally don't want to have command line options showing up in a binary just because it it links with MC. Can this be added to just llc and llvm-mc? Maybe add the option to CommandFlags.h or create another similar file for MC?
Rafael, Eugene, could you please take another look?
Yes, we're expecting that this class will grow. For instance, for memory sanitizer there will be additional bit about whether we need to track origins or not. Another reason is that in tools like llvm-mc this class is initialized independently from other TargetOptions's options.
Done, I've created a separate header with flag and function for initialization from command line.
The class small and would be easy to copy. The existence of the onMCTargetOptionSet also suggests value semantics, don't you want to store just a "MCTargetOptions MCOptions"?
This can be private. Even better, can't you also just remove setMCTargetOptions method completely and add an argument to createMCAsmParser?
The phabricator login doesn't seem to be working, so I will just put
the comments on the email.
setMCTargetOptions is now unused, please delete it.
onMCTargetOptionsSet is also unused, please delete it.
AsmPrinterInlineAsm.cpp:147 is now just a white space change now.
/// Current MCTargetOptions.
Without a set method the comment is out of date.
Nit: maybe even better than a copy would be a const reference if that
LGTM with that.