pub(crate) module: &'m mut dyn Module,
pub(crate) tcx: TyCtxt<'tcx>,
pub(crate) pointer_type: Type, // Cached from module
- pub(crate) vtables: FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), DataId>,
pub(crate) constants_cx: ConstantCx,
pub(crate) instance: Instance<'tcx>,
self.module.isa().triple()
}
- pub(crate) fn anonymous_str(&mut self, prefix: &str, msg: &str) -> Value {
- use std::collections::hash_map::DefaultHasher;
- use std::hash::{Hash, Hasher};
-
- let mut hasher = DefaultHasher::new();
- msg.hash(&mut hasher);
- let msg_hash = hasher.finish();
+ pub(crate) fn anonymous_str(&mut self, msg: &str) -> Value {
let mut data_ctx = DataContext::new();
data_ctx.define(msg.as_bytes().to_vec().into_boxed_slice());
- let msg_id = self
- .module
- .declare_data(&format!("__{}_{:08x}", prefix, msg_hash), Linkage::Local, false, false)
- .unwrap();
+ let msg_id = self.module.declare_anonymous_data(false, false).unwrap();
// Ignore DuplicateDefinition error, as the data will be the same
let _ = self.module.define_data(msg_id, &data_ctx);