Skip to content

Commit 987814f

Browse files
author
Elliott Slaughter
committed
Added debug flag to enable LLVM debug output.
1 parent 0b3dba4 commit 987814f

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed

src/rustc/driver/driver.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import io::{reader_util, writer_util};
1414
import getopts::{optopt, optmulti, optflag, optflagopt, opt_present};
1515
import back::{x86, x86_64};
1616
import std::map::hashmap;
17+
import lib::llvm::llvm;
1718

1819
enum pp_mode {ppm_normal, ppm_expanded, ppm_typed, ppm_identified,
1920
ppm_expanded_identified }
@@ -440,6 +441,9 @@ fn build_session_options(match: getopts::match,
440441
}
441442
debugging_opts |= this_bit;
442443
}
444+
if debugging_opts & session::debug_llvm != 0 {
445+
llvm::LLVMSetDebug(1);
446+
}
443447

444448
let output_type =
445449
if parse_only || no_trans {

src/rustc/driver/session.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const borrowck_stats: uint = 1024u;
4040
const borrowck_note_pure: uint = 2048;
4141
const borrowck_note_loan: uint = 4096;
4242
const no_landing_pads: uint = 8192;
43+
const debug_llvm: uint = 16384;
4344

4445
fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
4546
~[(~"ppregions", ~"prettyprint regions with \
@@ -61,7 +62,8 @@ fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
6162
(~"borrowck-note-loan", ~"note where loans are req'd",
6263
borrowck_note_loan),
6364
(~"no-landing-pads", ~"omit landing pads for unwinding",
64-
no_landing_pads)
65+
no_landing_pads),
66+
(~"debug-llvm", ~"enable debug output from LLVM", debug_llvm)
6567
]
6668
}
6769

src/rustc/lib/llvm.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,9 @@ extern mod llvm {
969969

970970
fn LLVMConstNamedStruct(S: TypeRef, ConstantVals: *ValueRef,
971971
Count: c_uint) -> ValueRef;
972+
973+
/** Enables LLVM debug output. */
974+
fn LLVMSetDebug(Enabled: c_int);
972975
}
973976

974977
fn SetInstructionCallConv(Instr: ValueRef, CC: CallConv) {

src/rustllvm/RustWrapper.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "llvm/Support/SourceMgr.h"
2828
#include "llvm/Target/TargetOptions.h"
2929
#include "llvm/Support/Host.h"
30+
#include "llvm/Support/Debug.h"
3031
#include "llvm-c/Core.h"
3132
#include "llvm-c/BitReader.h"
3233
#include "llvm-c/Object.h"
@@ -185,3 +186,7 @@ extern "C" LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,
185186
unwrap(target), unwrap(source),
186187
order));
187188
}
189+
190+
extern "C" void LLVMSetDebug(int Enabled) {
191+
DebugFlag = Enabled;
192+
}

src/rustllvm/rustllvm.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ LLVMSetAlignment
528528
LLVMSetCleanup
529529
LLVMSetCurrentDebugLocation
530530
LLVMSetDataLayout
531+
LLVMSetDebug
531532
LLVMSetFunctionCallConv
532533
LLVMSetGC
533534
LLVMSetGlobalConstant

0 commit comments

Comments
 (0)