Update prebuilt Clang to r416183b from Android.
https://android.googlesource.com/platform/prebuilts/clang/host/
linux-x86/+/06a71ddac05c22edb2d10b590e1769b3f8619bef
clang 12.0.5 (based on r416183b) from build 7284624.
Change-Id: I277a316abcf47307562d8b748b84870f31a72866
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/linux-x64/clang/include/llvm/MC/MCContext.h b/linux-x64/clang/include/llvm/MC/MCContext.h
index c40cd7c..49ab0ce 100644
--- a/linux-x64/clang/include/llvm/MC/MCContext.h
+++ b/linux-x64/clang/include/llvm/MC/MCContext.h
@@ -18,10 +18,13 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/BinaryFormat/Dwarf.h"
+#include "llvm/BinaryFormat/ELF.h"
#include "llvm/BinaryFormat/XCOFF.h"
#include "llvm/MC/MCAsmMacro.h"
#include "llvm/MC/MCDwarf.h"
+#include "llvm/MC/MCPseudoProbe.h"
#include "llvm/MC/MCSubtargetInfo.h"
+#include "llvm/MC/MCTargetOptions.h"
#include "llvm/MC/SectionKind.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Compiler.h"
@@ -55,6 +58,7 @@
class MCSymbol;
class MCSymbolELF;
class MCSymbolWasm;
+ class MCSymbolXCOFF;
class SMLoc;
class SourceMgr;
@@ -94,6 +98,7 @@
SpecificBumpPtrAllocator<MCSectionMachO> MachOAllocator;
SpecificBumpPtrAllocator<MCSectionWasm> WasmAllocator;
SpecificBumpPtrAllocator<MCSectionXCOFF> XCOFFAllocator;
+ SpecificBumpPtrAllocator<MCInst> MCInstAllocator;
/// Bindings of names to symbols.
SymbolTable Symbols;
@@ -183,30 +188,42 @@
/// The maximum version of dwarf that we should emit.
uint16_t DwarfVersion = 4;
+ /// The format of dwarf that we emit.
+ dwarf::DwarfFormat DwarfFormat = dwarf::DWARF32;
+
/// Honor temporary labels, this is useful for debugging semantic
/// differences between temporary and non-temporary labels (primarily on
/// Darwin).
bool AllowTemporaryLabels = true;
- bool UseNamesOnTempLabels = true;
+ bool UseNamesOnTempLabels = false;
/// The Compile Unit ID that we are currently processing.
unsigned DwarfCompileUnitID = 0;
+ /// A collection of MCPseudoProbe in the current module
+ MCPseudoProbeTable PseudoProbeTable;
+
+ // Sections are differentiated by the quadruple (section_name, group_name,
+ // unique_id, link_to_symbol_name). Sections sharing the same quadruple are
+ // combined into one section.
struct ELFSectionKey {
std::string SectionName;
StringRef GroupName;
+ StringRef LinkedToName;
unsigned UniqueID;
ELFSectionKey(StringRef SectionName, StringRef GroupName,
- unsigned UniqueID)
- : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {
- }
+ StringRef LinkedToName, unsigned UniqueID)
+ : SectionName(SectionName), GroupName(GroupName),
+ LinkedToName(LinkedToName), UniqueID(UniqueID) {}
bool operator<(const ELFSectionKey &Other) const {
if (SectionName != Other.SectionName)
return SectionName < Other.SectionName;
if (GroupName != Other.GroupName)
return GroupName < Other.GroupName;
+ if (int O = LinkedToName.compare(Other.LinkedToName))
+ return O < 0;
return UniqueID < Other.UniqueID;
}
};
@@ -278,6 +295,8 @@
/// Do automatic reset in destructor
bool AutoReset;
+ MCTargetOptions const *TargetOptions;
+
bool HadError = false;
MCSymbol *createSymbolImpl(const StringMapEntry<bool> *Name,
@@ -293,15 +312,51 @@
unsigned EntrySize,
const MCSymbolELF *Group,
unsigned UniqueID,
- const MCSymbolELF *Associated);
+ const MCSymbolELF *LinkedToSym);
+
+ MCSymbolXCOFF *createXCOFFSymbolImpl(const StringMapEntry<bool> *Name,
+ bool IsTemporary);
/// Map of currently defined macros.
StringMap<MCAsmMacro> MacroMap;
+ struct ELFEntrySizeKey {
+ std::string SectionName;
+ unsigned Flags;
+ unsigned EntrySize;
+
+ ELFEntrySizeKey(StringRef SectionName, unsigned Flags, unsigned EntrySize)
+ : SectionName(SectionName), Flags(Flags), EntrySize(EntrySize) {}
+
+ bool operator<(const ELFEntrySizeKey &Other) const {
+ if (SectionName != Other.SectionName)
+ return SectionName < Other.SectionName;
+ if ((Flags & ELF::SHF_STRINGS) != (Other.Flags & ELF::SHF_STRINGS))
+ return Other.Flags & ELF::SHF_STRINGS;
+ return EntrySize < Other.EntrySize;
+ }
+ };
+
+ // Symbols must be assigned to a section with a compatible entry
+ // size. This map is used to assign unique IDs to sections to
+ // distinguish between sections with identical names but incompatible entry
+ // sizes. This can occur when a symbol is explicitly assigned to a
+ // section, e.g. via __attribute__((section("myname"))).
+ std::map<ELFEntrySizeKey, unsigned> ELFEntrySizeMap;
+
+ // This set is used to record the generic mergeable section names seen.
+ // These are sections that are created as mergeable e.g. .debug_str. We need
+ // to avoid assigning non-mergeable symbols to these sections. It is used
+ // to prevent non-mergeable symbols being explicitly assigned to mergeable
+ // sections (e.g. via _attribute_((section("myname")))).
+ DenseSet<StringRef> ELFSeenGenericMergeableSections;
+
public:
explicit MCContext(const MCAsmInfo *MAI, const MCRegisterInfo *MRI,
const MCObjectFileInfo *MOFI,
- const SourceMgr *Mgr = nullptr, bool DoAutoReset = true);
+ const SourceMgr *Mgr = nullptr,
+ MCTargetOptions const *TargetOpts = nullptr,
+ bool DoAutoReset = true);
MCContext(const MCContext &) = delete;
MCContext &operator=(const MCContext &) = delete;
~MCContext();
@@ -330,6 +385,11 @@
/// @}
+ /// \name McInst Management
+
+ /// Create and return a new MC instruction.
+ MCInst *createMCInst();
+
/// \name Symbol Management
/// @{
@@ -337,12 +397,16 @@
/// unspecified name.
MCSymbol *createLinkerPrivateTempSymbol();
- /// Create and return a new assembler temporary symbol with a unique but
- /// unspecified name.
- MCSymbol *createTempSymbol(bool CanBeUnnamed = true);
+ /// Create a temporary symbol with a unique name. The name will be omitted
+ /// in the symbol table if UseNamesOnTempLabels is false (default except
+ /// MCAsmStreamer). The overload without Name uses an unspecified name.
+ MCSymbol *createTempSymbol();
+ MCSymbol *createTempSymbol(const Twine &Name, bool AlwaysAddSuffix = true);
- MCSymbol *createTempSymbol(const Twine &Name, bool AlwaysAddSuffix,
- bool CanBeUnnamed = true);
+ /// Create a temporary symbol with a unique name whose name cannot be
+ /// omitted in the symbol table. This is rarely used.
+ MCSymbol *createNamedTempSymbol();
+ MCSymbol *createNamedTempSymbol(const Twine &Name);
/// Create the definition of a directional local symbol for numbered label
/// (used for "1:" definitions).
@@ -424,25 +488,19 @@
MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
unsigned Flags, unsigned EntrySize,
const Twine &Group) {
- return getELFSection(Section, Type, Flags, EntrySize, Group, ~0);
- }
-
- MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
- unsigned Flags, unsigned EntrySize,
- const Twine &Group, unsigned UniqueID) {
- return getELFSection(Section, Type, Flags, EntrySize, Group, UniqueID,
- nullptr);
+ return getELFSection(Section, Type, Flags, EntrySize, Group,
+ MCSection::NonUniqueID, nullptr);
}
MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
unsigned Flags, unsigned EntrySize,
const Twine &Group, unsigned UniqueID,
- const MCSymbolELF *Associated);
+ const MCSymbolELF *LinkedToSym);
MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
unsigned Flags, unsigned EntrySize,
const MCSymbolELF *Group, unsigned UniqueID,
- const MCSymbolELF *Associated);
+ const MCSymbolELF *LinkedToSym);
/// Get a section with the provided group identifier. This section is
/// named by concatenating \p Prefix with '.' then \p Suffix. The \p Type
@@ -461,6 +519,17 @@
MCSectionELF *createELFGroupSection(const MCSymbolELF *Group);
+ void recordELFMergeableSectionInfo(StringRef SectionName, unsigned Flags,
+ unsigned UniqueID, unsigned EntrySize);
+
+ bool isELFImplicitMergeableSectionNamePrefix(StringRef Name);
+
+ bool isELFGenericMergeableSection(StringRef Name);
+
+ Optional<unsigned> getELFUniqueIDForEntsize(StringRef SectionName,
+ unsigned Flags,
+ unsigned EntrySize);
+
MCSectionCOFF *getCOFFSection(StringRef Section, unsigned Characteristics,
SectionKind Kind, StringRef COMDATSymName,
int Selection,
@@ -503,7 +572,8 @@
MCSectionXCOFF *getXCOFFSection(StringRef Section,
XCOFF::StorageMappingClass MappingClass,
- SectionKind K,
+ XCOFF::SymbolType CSectType, SectionKind K,
+ bool MultiSymbolsAllowed = false,
const char *BeginSymName = nullptr);
// Create and save a copy of STI and return a reference to the copy.
@@ -534,7 +604,7 @@
const std::string &getMainFileName() const { return MainFileName; }
/// Set the main file name and override the default.
- void setMainFileName(StringRef S) { MainFileName = S; }
+ void setMainFileName(StringRef S) { MainFileName = std::string(S); }
/// Creates an entry in the dwarf file and directory tables.
Expected<unsigned> getDwarfFile(StringRef Directory, StringRef FileName,
@@ -644,10 +714,8 @@
void setDwarfDebugProducer(StringRef S) { DwarfDebugProducer = S; }
StringRef getDwarfDebugProducer() { return DwarfDebugProducer; }
- dwarf::DwarfFormat getDwarfFormat() const {
- // TODO: Support DWARF64
- return dwarf::DWARF32;
- }
+ void setDwarfFormat(dwarf::DwarfFormat f) { DwarfFormat = f; }
+ dwarf::DwarfFormat getDwarfFormat() const { return DwarfFormat; }
void setDwarfVersion(uint16_t v) { DwarfVersion = v; }
uint16_t getDwarfVersion() const { return DwarfVersion; }
@@ -672,6 +740,7 @@
bool hadError() { return HadError; }
void reportError(SMLoc L, const Twine &Msg);
+ void reportWarning(SMLoc L, const Twine &Msg);
// Unrecoverable error has occurred. Display the best diagnostic we can
// and bail via exit(1). For now, most MC backend errors are unrecoverable.
// FIXME: We should really do something about that.
@@ -688,6 +757,8 @@
}
void undefineMacro(StringRef Name) { MacroMap.erase(Name); }
+
+ MCPseudoProbeTable &getMCPseudoProbeTable() { return PseudoProbeTable; }
};
} // end namespace llvm