Added debug flag to enable LLVM debug output.

This commit is contained in:
Elliott Slaughter 2012-07-25 12:06:03 -07:00
parent 0b3dba42cf
commit 987814f11e
5 changed files with 16 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import io::{reader_util, writer_util};
import getopts::{optopt, optmulti, optflag, optflagopt, opt_present};
import back::{x86, x86_64};
import std::map::hashmap;
import lib::llvm::llvm;
enum pp_mode {ppm_normal, ppm_expanded, ppm_typed, ppm_identified,
ppm_expanded_identified }
@ -440,6 +441,9 @@ fn build_session_options(match: getopts::match,
}
debugging_opts |= this_bit;
}
if debugging_opts & session::debug_llvm != 0 {
llvm::LLVMSetDebug(1);
}
let output_type =
if parse_only || no_trans {

View File

@ -40,6 +40,7 @@ const borrowck_stats: uint = 1024u;
const borrowck_note_pure: uint = 2048;
const borrowck_note_loan: uint = 4096;
const no_landing_pads: uint = 8192;
const debug_llvm: uint = 16384;
fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
~[(~"ppregions", ~"prettyprint regions with \
@ -61,7 +62,8 @@ fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
(~"borrowck-note-loan", ~"note where loans are req'd",
borrowck_note_loan),
(~"no-landing-pads", ~"omit landing pads for unwinding",
no_landing_pads)
no_landing_pads),
(~"debug-llvm", ~"enable debug output from LLVM", debug_llvm)
]
}

View File

@ -969,6 +969,9 @@ extern mod llvm {
fn LLVMConstNamedStruct(S: TypeRef, ConstantVals: *ValueRef,
Count: c_uint) -> ValueRef;
/** Enables LLVM debug output. */
fn LLVMSetDebug(Enabled: c_int);
}
fn SetInstructionCallConv(Instr: ValueRef, CC: CallConv) {

View File

@ -27,6 +27,7 @@
#include "llvm/Support/SourceMgr.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/Debug.h"
#include "llvm-c/Core.h"
#include "llvm-c/BitReader.h"
#include "llvm-c/Object.h"
@ -185,3 +186,7 @@ extern "C" LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,
unwrap(target), unwrap(source),
order));
}
extern "C" void LLVMSetDebug(int Enabled) {
DebugFlag = Enabled;
}

View File

@ -528,6 +528,7 @@ LLVMSetAlignment
LLVMSetCleanup
LLVMSetCurrentDebugLocation
LLVMSetDataLayout
LLVMSetDebug
LLVMSetFunctionCallConv
LLVMSetGC
LLVMSetGlobalConstant