This is a step towards the upcoming KMSAN implementation patch.
KMSAN is going to prepend a special basic block containing tool-specific calls to each function. Because we still want to instrument the original entry block, we'll need to store it in ActualFnStart.
For MSan this will still be F.getEntryBlock(), whereas for KMSAN it'll contain the second BB.
Details
- Reviewers
vitalybuka dvyukov eugenis
Diff Detail
- Repository
- rL LLVM
Event Timeline
What kind of code will this basic block contain? Can it be created later, at the end of instrumentation pass?
This basic block will contain a runtime call, which provides addresses of TLS structs used later in the instrumentation.
If we insert the call late, we'll have to fix all the users of its return values, which is trickier than inserting the call in advance.
lib/Transforms/Instrumentation/MemorySanitizer.cpp | ||
---|---|---|
741 | can you initialize ActualFnStart here? |
lib/Transforms/Instrumentation/MemorySanitizer.cpp | ||
---|---|---|
741 | Note that this code will finally look like: if (MS.CompileKernel) ActualFnStart = insertKmsanPrologue(F); else ActualFnStart = &F.getEntryBlock(); , so we'll be basically performing some instrumentation in the constructor instead of runOnFunction(). |
I've moved the initialization of ActualFnStart and callbacks to the end of the constructor and landed r328697.
can you initialize ActualFnStart here?