mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-04-30 15:10:59 +03:00
Add basic clang-like support for XRay, through -fxray-instrument
and -fxray-instruction-threshold=
. (#2465)
Currently only fully working on Linux. See https://llvm.org/docs/XRay.html
This commit is contained in:
parent
43c02cecc0
commit
1da088330d
10 changed files with 148 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "statement.h"
|
||||
#include "template.h"
|
||||
#include "driver/cl_options.h"
|
||||
#include "driver/cl_options_instrumentation.h"
|
||||
#include "driver/cl_options_sanitizers.h"
|
||||
#include "gen/abi.h"
|
||||
#include "gen/arrays.h"
|
||||
|
@ -463,6 +464,18 @@ void applyTargetMachineAttributes(llvm::Function &func,
|
|||
willEliminateFramePointer() ? "false" : "true");
|
||||
}
|
||||
|
||||
void applyXRayAttributes(FuncDeclaration &fdecl, llvm::Function &func) {
|
||||
if (!opts::fXRayInstrument)
|
||||
return;
|
||||
|
||||
if (!fdecl.emitInstrumentation) {
|
||||
func.addFnAttr("function-instrument", "xray-never");
|
||||
} else {
|
||||
func.addFnAttr("xray-instruction-threshold",
|
||||
opts::getXRayInstructionThresholdString());
|
||||
}
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1010,6 +1023,7 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
|
|||
func->addFnAttr(LLAttribute::SanitizeThread);
|
||||
}
|
||||
}
|
||||
applyXRayAttributes(*fd, *func);
|
||||
|
||||
llvm::BasicBlock *beginbb =
|
||||
llvm::BasicBlock::Create(gIR->context(), "", func);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue