llvm.org GIT mirror llvm / 040ff9f
Save several std::string constructions using llvm::Twine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255535 91177308-0d34-0410-b5e6-96231b3b80d8 Yaron Keren 4 years ago
1 changed file(s) with 6 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
117117
118118 bool IsSmallMemAccess(unsigned AccessSize) { return AccessSize < 8; }
119119
120 std::string FuncName(unsigned AccessSize, bool IsWrite) {
121 return std::string("__asan_report_") + (IsWrite ? "store" : "load") +
122 utostr(AccessSize);
123 }
124
125120 class X86AddressSanitizer : public X86AsmInstrumentation {
126121 public:
127122 struct RegisterContext {
611606 EmitInstruction(
612607 Out, MCInstBuilder(X86::PUSH32r).addReg(RegCtx.AddressReg(MVT::i32)));
613608
614 const std::string &Fn = FuncName(AccessSize, IsWrite);
615 MCSymbol *FnSym = Ctx.getOrCreateSymbol(StringRef(Fn));
609 MCSymbol *FnSym = Ctx.getOrCreateSymbol(llvm::Twine("__asan_report_") +
610 (IsWrite ? "store" : "load") +
611 llvm::Twine(AccessSize));
616612 const MCSymbolRefExpr *FnExpr =
617613 MCSymbolRefExpr::create(FnSym, MCSymbolRefExpr::VK_PLT, Ctx);
618614 EmitInstruction(Out, MCInstBuilder(X86::CALLpcrel32).addExpr(FnExpr));
881877 EmitInstruction(Out, MCInstBuilder(X86::MOV64rr).addReg(X86::RDI).addReg(
882878 RegCtx.AddressReg(MVT::i64)));
883879 }
884 const std::string &Fn = FuncName(AccessSize, IsWrite);
885 MCSymbol *FnSym = Ctx.getOrCreateSymbol(StringRef(Fn));
880 MCSymbol *FnSym = Ctx.getOrCreateSymbol(llvm::Twine("__asan_report_") +
881 (IsWrite ? "store" : "load") +
882 llvm::Twine(AccessSize));
886883 const MCSymbolRefExpr *FnExpr =
887884 MCSymbolRefExpr::create(FnSym, MCSymbolRefExpr::VK_PLT, Ctx);
888885 EmitInstruction(Out, MCInstBuilder(X86::CALL64pcrel32).addExpr(FnExpr));