srctree

antlilja parent 9d500bda e2345f00
LLVM: Add enableBrokenDebugInfoCheck and getBrokenDebugInfo

These functions allows the caller to find out wether the contextencounters broken debug info or not.

inlinesplit
src/codegen/llvm/bindings.zig added: 32, removed: 3, total 29
@@ -37,6 +37,12 @@ pub const Context = opaque {
 
pub const setOptBisectLimit = ZigLLVMSetOptBisectLimit;
extern fn ZigLLVMSetOptBisectLimit(C: *Context, limit: c_int) void;
 
pub const enableBrokenDebugInfoCheck = ZigLLVMEnableBrokenDebugInfoCheck;
extern fn ZigLLVMEnableBrokenDebugInfoCheck(C: *Context) void;
 
pub const getBrokenDebugInfo = ZigLLVMGetBrokenDebugInfo;
extern fn ZigLLVMGetBrokenDebugInfo(C: *Context) bool;
};
 
pub const Module = opaque {
 
src/zig_llvm.cpp added: 32, removed: 3, total 29
@@ -380,6 +380,26 @@ void ZigLLVMSetOptBisectLimit(LLVMContextRef context_ref, int limit) {
unwrap(context_ref)->setOptPassGate(opt_bisect);
}
 
struct ZigDiagnosticHandler : public DiagnosticHandler {
bool BrokenDebugInfo;
ZigDiagnosticHandler() : BrokenDebugInfo(false) {}
bool handleDiagnostics(const DiagnosticInfo &DI) override {
if (auto *Remark = dyn_cast<DiagnosticInfoDebugMetadataVersion>(&DI)) {
BrokenDebugInfo = true;
}
return false;
}
};
 
void ZigLLVMEnableBrokenDebugInfoCheck(LLVMContextRef context_ref) {
unwrap(context_ref)->setDiagnosticHandler(std::make_unique<ZigDiagnosticHandler>());
}
 
bool ZigLLVMGetBrokenDebugInfo(LLVMContextRef context_ref) {
return ((const ZigDiagnosticHandler*)
unwrap(context_ref)->getDiagHandlerPtr())->BrokenDebugInfo;
}
 
void ZigLLVMParseCommandLineOptions(size_t argc, const char *const *argv) {
cl::ParseCommandLineOptions(argc, argv);
}
 
src/zig_llvm.h added: 32, removed: 3, total 29
@@ -44,6 +44,9 @@ ZIG_EXTERN_C LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, co
 
ZIG_EXTERN_C void ZigLLVMSetOptBisectLimit(LLVMContextRef context_ref, int limit);
 
ZIG_EXTERN_C void ZigLLVMEnableBrokenDebugInfoCheck(LLVMContextRef context_ref);
ZIG_EXTERN_C bool ZigLLVMGetBrokenDebugInfo(LLVMContextRef context_ref);
 
enum ZigLLVMTailCallKind {
ZigLLVMTailCallKindNone,
ZigLLVMTailCallKindTail,