Make debug information work
This commit is contained in:
parent
b169e67ca4
commit
92f12e90eb
@ -8,7 +8,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use llvm_sys::{
|
use llvm_sys::{
|
||||||
LLVMIntPredicate, LLVMLinkage,
|
LLVMIntPredicate, LLVMLinkage, LLVMValueKind,
|
||||||
analysis::LLVMVerifyModule,
|
analysis::LLVMVerifyModule,
|
||||||
core::*,
|
core::*,
|
||||||
debuginfo::*,
|
debuginfo::*,
|
||||||
@ -813,16 +813,24 @@ impl InstructionHolder {
|
|||||||
};
|
};
|
||||||
if let Some(location) = &self.data.location {
|
if let Some(location) = &self.data.location {
|
||||||
unsafe {
|
unsafe {
|
||||||
// LLVMInstructionSetDebugLoc(
|
match LLVMGetValueKind(val) {
|
||||||
// val,
|
LLVMValueKind::LLVMInstructionValueKind
|
||||||
// *module
|
| LLVMValueKind::LLVMMemoryDefValueKind
|
||||||
// .debug
|
| LLVMValueKind::LLVMMemoryUseValueKind
|
||||||
// .as_ref()
|
| LLVMValueKind::LLVMMemoryPhiValueKind => {
|
||||||
// .unwrap()
|
LLVMInstructionSetDebugLoc(
|
||||||
// .locations
|
val,
|
||||||
// .get(&location)
|
*module
|
||||||
// .unwrap(),
|
.debug
|
||||||
// );
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.locations
|
||||||
|
.get(&location)
|
||||||
|
.unwrap(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LLVMValue {
|
LLVMValue {
|
||||||
|
@ -364,7 +364,13 @@ impl mir::Block {
|
|||||||
state: &State,
|
state: &State,
|
||||||
) -> Option<InstructionValue> {
|
) -> Option<InstructionValue> {
|
||||||
for stmt in &self.statements {
|
for stmt in &self.statements {
|
||||||
stmt.codegen(&mut scope, state);
|
stmt.codegen(&mut scope, state).map(|s| {
|
||||||
|
if let Some(debug) = &scope.debug {
|
||||||
|
let location = stmt.1.into_debug(scope.tokens).unwrap();
|
||||||
|
let loc_val = debug.info.location(&debug.scope, location);
|
||||||
|
s.with_location(&mut scope.block, loc_val);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some((kind, expr)) = &self.return_expression {
|
if let Some((kind, expr)) = &self.return_expression {
|
||||||
@ -484,10 +490,7 @@ impl mir::Expression {
|
|||||||
_ => panic!("Found an unknown-mutable variable!"),
|
_ => panic!("Found an unknown-mutable variable!"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
mir::ExprKind::Literal(lit) => Some(
|
mir::ExprKind::Literal(lit) => Some(lit.as_const(&mut scope.block)),
|
||||||
lit.as_const(&mut scope.block)
|
|
||||||
.maybe_location(&mut scope.block, location),
|
|
||||||
),
|
|
||||||
mir::ExprKind::BinOp(binop, lhs_exp, rhs_exp) => {
|
mir::ExprKind::BinOp(binop, lhs_exp, rhs_exp) => {
|
||||||
lhs_exp
|
lhs_exp
|
||||||
.return_type()
|
.return_type()
|
||||||
@ -667,6 +670,7 @@ impl mir::Expression {
|
|||||||
Some(struct_ptr)
|
Some(struct_ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.map(|i| i.maybe_location(&mut scope.block, location))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,10 +95,10 @@ impl<'map> Pass for LinkerPass<'map> {
|
|||||||
modules.insert(module.name.clone(), Rc::new(RefCell::new((module, tokens))));
|
modules.insert(module.name.clone(), Rc::new(RefCell::new((module, tokens))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// modules.insert(
|
modules.insert(
|
||||||
// "std".to_owned(),
|
"std".to_owned(),
|
||||||
// Rc::new(RefCell::new(compile_std(&mut self.module_map))),
|
Rc::new(RefCell::new(compile_std(&mut self.module_map))),
|
||||||
// );
|
);
|
||||||
|
|
||||||
let mut modules_to_process: Vec<Rc<RefCell<(Module, Vec<FullToken>)>>> =
|
let mut modules_to_process: Vec<Rc<RefCell<(Module, Vec<FullToken>)>>> =
|
||||||
modules.values().cloned().collect();
|
modules.values().cloned().collect();
|
||||||
|
Loading…
Reference in New Issue
Block a user