diff --git a/llvm/include/llvm-c/lto.h b/llvm/include/llvm-c/lto.h index 1db077822ae2..9f37dd71e31c 100644 --- a/llvm/include/llvm-c/lto.h +++ b/llvm/include/llvm-c/lto.h @@ -62,7 +62,8 @@ typedef enum { LTO_SYMBOL_SCOPE_HIDDEN = 0x00001000, LTO_SYMBOL_SCOPE_PROTECTED = 0x00002000, LTO_SYMBOL_SCOPE_DEFAULT = 0x00001800, - LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN = 0x00002800 + LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN = 0x00002800, + LTO_SYMBOL_COMDAT = 0x00004000 } lto_symbol_attributes; /** diff --git a/llvm/lib/LTO/LTOModule.cpp b/llvm/lib/LTO/LTOModule.cpp index 5cdbca66a80e..0794d3c9ea4a 100644 --- a/llvm/lib/LTO/LTOModule.cpp +++ b/llvm/lib/LTO/LTOModule.cpp @@ -468,6 +468,9 @@ void LTOModule::addDefinedSymbol(const char *Name, const GlobalValue *def, else attr |= LTO_SYMBOL_SCOPE_DEFAULT; + if (def->hasComdat()) + attr |= LTO_SYMBOL_COMDAT; + auto Iter = _defines.insert(Name).first; // fill information structure