gpt4 book ai didi

c++ - 在使用 llvm 生成代码期间更喜欢 llvm::StringMap 还是 std::map

转载 作者:行者123 更新时间:2023-11-28 01:36:34 30 4
gpt4 key购买 nike

我目前正在做一个项目,我必须使用符号表来跟踪不同的变量。类似于万花筒 tutorial出现在 LLVM 主页上。

在示例代码中,他们使用 std::map 来实现此功能。

static std::map<std::string, AllocaInst*> NamedValues;

在类似于教程的实际场景中 llvm::StringMap

llvm::StringMap< ValueTy, AllocatorTy > 

优于 std::map 方法?

最佳答案

我不确定,但我真的没有看到 llvm::StringMap 比 std::map 更受青睐的原因。基于on these slides (幻灯片 23,24)对于插入和查找,llvm::StringMap 似乎比 std::map 和 std::unordered_map 慢。

此外,如前所述here :

StringMap iteration order, however, is not guaranteed to be deterministic, so any uses which require that should instead use a std::map.

因此,请记住这一点,以防您最终使用 llvm::StringMap 而不是 std::map。

关于c++ - 在使用 llvm 生成代码期间更喜欢 llvm::StringMap 还是 std::map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49031588/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com