25
25
#include " WebAssemblyRegisterInfo.h"
26
26
#include " WebAssemblyRuntimeLibcallSignatures.h"
27
27
#include " WebAssemblyTargetMachine.h"
28
+ #include " llvm/ADT/MapVector.h"
28
29
#include " llvm/ADT/SmallSet.h"
29
30
#include " llvm/ADT/StringExtras.h"
30
- #include " llvm/ADT/StringMap.h"
31
31
#include " llvm/Analysis/ValueTracking.h"
32
32
#include " llvm/BinaryFormat/Wasm.h"
33
33
#include " llvm/CodeGen/Analysis.h"
@@ -565,7 +565,7 @@ void WebAssemblyAsmPrinter::EmitFunctionAttributes(Module &M) {
565
565
return ;
566
566
567
567
// Group all the custom attributes by name.
568
- StringMap< SmallVector<MCSymbol *, 4 >> CustomSections;
568
+ MapVector<StringRef, SmallVector<MCSymbol *, 4 >> CustomSections;
569
569
const ConstantArray *CA = cast<ConstantArray>(V->getOperand (0 ));
570
570
for (Value *Op : CA->operands ()) {
571
571
auto *CS = cast<ConstantStruct>(Op);
@@ -580,15 +580,14 @@ void WebAssemblyAsmPrinter::EmitFunctionAttributes(Module &M) {
580
580
auto *GV = cast<GlobalVariable>(CS->getOperand (1 )->stripPointerCasts ());
581
581
StringRef AnnotationString;
582
582
getConstantStringInfo (GV, AnnotationString);
583
- std::string Name = " annotate." + AnnotationString.str ();
584
583
auto *Sym = cast<MCSymbolWasm>(getSymbol (F));
585
- CustomSections[Name ].push_back (Sym);
584
+ CustomSections[AnnotationString ].push_back (Sym);
586
585
}
587
586
588
587
// Emit a custom section for each unique attribute.
589
588
for (const auto &[Name, Symbols] : CustomSections) {
590
589
MCSectionWasm *CustomSection = OutContext.getWasmSection (
591
- " .custom_section.llvm.func_attr." + Name, SectionKind::getMetadata ());
590
+ " .custom_section.llvm.func_attr.annotate. " + Name, SectionKind::getMetadata ());
592
591
OutStreamer->pushSection ();
593
592
OutStreamer->switchSection (CustomSection);
594
593
0 commit comments