[llvm] c31af7c - [MC][BOLT] Add setter for AllowAtInName

Amir Ayupov via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 13:04:33 PDT 2022


Author: Amir Ayupov
Date: 2022-03-30T13:04:28-07:00
New Revision: c31af7cfe3b923b30d8929159366c670348fa5d3

URL: https://github.com/llvm/llvm-project/commit/c31af7cfe3b923b30d8929159366c670348fa5d3
DIFF: https://github.com/llvm/llvm-project/commit/c31af7cfe3b923b30d8929159366c670348fa5d3.diff

LOG: [MC][BOLT] Add setter for AllowAtInName

Use the setter in BOLT to allow printing names with variant kind in the name
(e.g. "func at PLT").
Fixes BOLT buildbot tests that broke after D122516:
https://lab.llvm.org/buildbot/#/builders/215/builds/3595

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D122694

Added: 
    

Modified: 
    bolt/lib/Core/BinaryContext.cpp
    llvm/include/llvm/MC/MCAsmInfo.h

Removed: 
    


################################################################################
diff  --git a/bolt/lib/Core/BinaryContext.cpp b/bolt/lib/Core/BinaryContext.cpp
index bcae159ddc393..8a9835db8d76c 100644
--- a/bolt/lib/Core/BinaryContext.cpp
+++ b/bolt/lib/Core/BinaryContext.cpp
@@ -155,12 +155,17 @@ BinaryContext::createBinaryContext(const ObjectFile *File, bool IsPIC,
         Twine("BOLT-ERROR: no register info for target ", TripleName));
 
   // Set up disassembler.
-  std::unique_ptr<const MCAsmInfo> AsmInfo(
+  std::unique_ptr<MCAsmInfo> AsmInfo(
       TheTarget->createMCAsmInfo(*MRI, TripleName, MCTargetOptions()));
   if (!AsmInfo)
     return createStringError(
         make_error_code(std::errc::not_supported),
         Twine("BOLT-ERROR: no assembly info for target ", TripleName));
+  // BOLT creates "func at PLT" symbols for PLT entries. In function assembly dump
+  // we want to emit such names as using @PLT without double quotes to convey
+  // variant kind to the assembler. BOLT doesn't rely on the linker so we can
+  // override the default AsmInfo behavior to emit names the way we want.
+  AsmInfo->setAllowAtInName(true);
 
   std::unique_ptr<const MCSubtargetInfo> STI(
       TheTarget->createMCSubtargetInfo(TripleName, "", FeaturesStr));

diff  --git a/llvm/include/llvm/MC/MCAsmInfo.h b/llvm/include/llvm/MC/MCAsmInfo.h
index 355f569861d8c..1be65a77610b3 100644
--- a/llvm/include/llvm/MC/MCAsmInfo.h
+++ b/llvm/include/llvm/MC/MCAsmInfo.h
@@ -671,6 +671,7 @@ class MCAsmInfo {
   const char *getCode64Directive() const { return Code64Directive; }
   unsigned getAssemblerDialect() const { return AssemblerDialect; }
   bool doesAllowAtInName() const { return AllowAtInName; }
+  void setAllowAtInName(bool V) { AllowAtInName = V; }
   bool doesAllowQuestionAtStartOfIdentifier() const {
     return AllowQuestionAtStartOfIdentifier;
   }


        


More information about the llvm-commits mailing list