diff options
author | Serge Guelton <sguelton@redhat.com> | 2022-01-03 13:32:19 -0500 |
---|---|---|
committer | serge-sans-paille <sguelton@redhat.com> | 2022-01-10 14:49:53 +0100 |
commit | d2cc6c2d0c2f8a6e272110416a3fd579ed5a3ac1 (patch) | |
tree | 37a792a98dc78783341b383ac0808ac227327511 /llvm/lib/CodeGen/CommandFlags.cpp | |
parent | 2c0fb96254fef2509b66d75290fedafd4adede95 (diff) | |
download | llvm-d2cc6c2d0c2f8a6e272110416a3fd579ed5a3ac1.zip llvm-d2cc6c2d0c2f8a6e272110416a3fd579ed5a3ac1.tar.gz llvm-d2cc6c2d0c2f8a6e272110416a3fd579ed5a3ac1.tar.bz2 |
Use a sorted array instead of a map to store AttrBuilder string attributes
Using and std::map<SmallString, SmallString> for target dependent attributes is
inefficient: it makes its constructor slightly heavier, and involves extra
allocation for each new string attribute. Storing the attribute key/value as
strings implies extra allocation/copy step.
Use a sorted vector instead. Given the low number of attributes generally
involved, this is cheaper, as showcased by
https://llvm-compile-time-tracker.com/compare.php?from=5de322295f4ade692dc4f1823ae4450ad3c48af2&to=05bc480bf641a9e3b466619af43a2d123ee3f71d&stat=instructions
Differential Revision: https://reviews.llvm.org/D116599
Diffstat (limited to 'llvm/lib/CodeGen/CommandFlags.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CommandFlags.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp index 3bed81d..4543a88 100644 --- a/llvm/lib/CodeGen/CommandFlags.cpp +++ b/llvm/lib/CodeGen/CommandFlags.cpp @@ -620,7 +620,7 @@ void codegen::setFunctionAttributes(StringRef CPU, StringRef Features, Function &F) { auto &Ctx = F.getContext(); AttributeList Attrs = F.getAttributes(); - AttrBuilder NewAttrs; + AttrBuilder NewAttrs(Ctx); if (!CPU.empty() && !F.hasFnAttribute("target-cpu")) NewAttrs.addAttribute("target-cpu", CPU); |