Skip to content

Commit e1fbef7

Browse files
committed
fix the issue that vtables are created twice, fix the debug issue
1 parent 3dd0ee8 commit e1fbef7

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

compiler/plc_driver/src/pipelines/participant.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ impl PipelineParticipantMut for VTableIndexer {
341341
let vtable = Self::create_vtable(pou.get_name(), methods, pou.get_location().clone());
342342
vtables.push(vtable);
343343
}
344-
345344
project.units.first_mut().unwrap().user_types.extend(vtables);
346345
project.index(self.id_provider.clone())
347346
}

src/codegen/debug.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ use plc_source::source_location::SourceLocation;
2020

2121
use crate::{
2222
index::{Index, PouIndexEntry, VariableIndexEntry},
23-
typesystem::{DataType, DataTypeInformation, Dimension, StringEncoding, CHAR_TYPE, WCHAR_TYPE},
23+
typesystem::{
24+
DataType, DataTypeInformation, Dimension, StringEncoding, CHAR_TYPE, VOID_INTERNAL_NAME, WCHAR_TYPE,
25+
},
2426
DebugLevel, OptimizationLevel,
2527
};
2628

@@ -455,7 +457,21 @@ impl<'ink> DebugBuilder<'ink> {
455457
types_index: &LlvmTypedIndex,
456458
) -> Result<(), Diagnostic> {
457459
let inner_type = index.get_type(inner_type)?;
458-
let inner_type = self.get_or_create_debug_type(inner_type, index, types_index)?;
460+
//Skip void pointers debug info
461+
let inner_type = if inner_type.is_void() {
462+
DebugType::Basic(
463+
self.debug_info
464+
.create_basic_type(
465+
VOID_INTERNAL_NAME,
466+
0,
467+
DebugEncoding::DW_ATE_unsigned as u32,
468+
DIFlagsConstants::PUBLIC,
469+
)
470+
.map_err(|err| Diagnostic::codegen_error(err, SourceLocation::undefined()))?,
471+
)
472+
} else {
473+
self.get_or_create_debug_type(inner_type, index, types_index)?
474+
};
459475
let llvm_type = types_index.get_associated_type(name)?;
460476
let align_bits = self.target_data.get_preferred_alignment(&llvm_type) * 8;
461477
let pointer_type = self.debug_info.create_pointer_type(

src/codegen/generators/data_type_generator.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,14 @@ pub fn generate_data_types<'ink>(
7474
types.push((dep.get_name(), datatype))
7575
}
7676
}
77-
78-
if let Some(datatype) = dep.get_vtable(index) {
79-
if !datatype.get_type_information().is_generic(index) {
80-
types.push((datatype.get_name(), datatype))
81-
}
82-
}
8377
}
8478

8579
let mut generator =
8680
DataTypeGenerator { llvm, debug, index, annotations, types_index: LlvmTypedIndex::default() };
8781

88-
// dbg!(&types);
8982
// first create all STUBs for struct types (empty structs)
9083
// and associate them in the llvm index
9184
for (name, user_type) in &types {
92-
if *name == "__vtable_fb" {
93-
eprintln!("hi")
94-
}
9585
if let DataTypeInformation::Struct { name: struct_name, .. } = user_type.get_type_information() {
9686
generator.types_index.associate_type(name, llvm.create_struct_stub(struct_name).into())?;
9787
}
@@ -201,7 +191,6 @@ impl<'ink> DataTypeGenerator<'ink, '_> {
201191
.map(BasicTypeEnum::into_struct_type)?;
202192

203193
struct_type.set_body(members.as_slice(), false);
204-
dbg!(&struct_type);
205194
}
206195
Ok(())
207196
}
@@ -318,7 +307,6 @@ impl<'ink> DataTypeGenerator<'ink, '_> {
318307
}?
319308
.into_struct_type();
320309

321-
eprintln!("Init for : {}", data_type.get_name());
322310
Ok(Some(struct_type.const_named_struct(&member_values).as_basic_value_enum()))
323311
}
324312
DataTypeInformation::Array { .. } => self.generate_array_initializer(

0 commit comments

Comments
 (0)