C++ movb引发了坏的猜测
我正在研究一个并行树实现。在分析过程中,我认识到对C++ movb引发了坏的猜测,c++,assembly,x86-64,clang++,mov,C++,Assembly,X86 64,Clang++,Mov,我正在研究一个并行树实现。在分析过程中,我认识到对movb操作的高度错误推测 我的数据结构如下所示: struct data { enum annotation_type : std::uint8_t { none, core, region, tree_node }; // Specifies the value in the union access_pattern _access_pattern = writing; enum priority _priority
movb
操作的高度错误推测
我的数据结构如下所示:
struct data {
enum annotation_type : std::uint8_t { none, core, region, tree_node }; // Specifies the value in the union
access_pattern _access_pattern = writing;
enum priority _priority = priority::normal;
annotation_type _annotation_type = annotation_type::none;
union {
std::uint16_t _core;
std::uint8_t _region;
std::pair<node*, std::uint16_t> _tree_node = {nullptr,0};
};
};
通过clang-10
,将annotate
方法编译为
movb $0x3, 0x12(%r14) // Set _annotation_type
movq %rax, 0x14(%r14) // Set the pointer part of tree_node
movw $0x200, 0x1c(%r14) // Set the size part of tree_node, in this case it is called with annotate(node*, 512)
使用“英特尔VTune分析器”,我可以确定movb
指令movb$0x3,0x12(%r14)
的CPI率为4.550
,错误推测为movb
指令movb$0x3,0x12(%r14)
,该指令将\u注释类型
属性更新为0x3
(树节点)
但是一条mov
指令怎么会得到如此高的错误推测,这是基于分支错误预测的,不是吗 您在任何时候都在阅读非活动工会会员的信息吗?什么是非活动工会?唯一知道在联合体中存储什么值的是\u注释\u类型
。如果在\u树\u节点
中存储某物,则是\u核心
和\u区域
。对
存储节点*
,但注释
(成员?)函数尝试存储常量节点*/code>。那是编译吗?@TedLyngmo啊,不,我没有访问任何一个不活跃的工会成员。你在任何时候都在阅读一个不活跃的工会成员的文章吗?什么是不活跃的工会?唯一知道在联合体中存储什么值的是\u注释\u类型
。如果在\u树\u节点
中存储某物,则是\u核心
和\u区域
。对
存储节点*
,但注释
(成员?)函数尝试存储常量节点*/code>。那还可以编译吗?@TedLyngmo啊,不,我没有访问一个不活跃的工会成员。
movb $0x3, 0x12(%r14) // Set _annotation_type
movq %rax, 0x14(%r14) // Set the pointer part of tree_node
movw $0x200, 0x1c(%r14) // Set the size part of tree_node, in this case it is called with annotate(node*, 512)