diff --git a/llvm/lib/Object/IRObjectFile.cpp b/llvm/lib/Object/IRObjectFile.cpp index e927447739eb..62eaac7a2f06 100644 --- a/llvm/lib/Object/IRObjectFile.cpp +++ b/llvm/lib/Object/IRObjectFile.cpp @@ -238,16 +238,13 @@ uint32_t IRObjectFile::getSymbolFlags(DataRefImpl Symb) const { if (GV->hasLinkOnceLinkage() || GV->hasWeakLinkage()) Res |= BasicSymbolRef::SF_Weak; - if (auto *Var = dyn_cast(GV)) { + if (GV->getName().startswith("llvm.")) + Res |= BasicSymbolRef::SF_FormatSpecific; + else if (auto *Var = dyn_cast(GV)) { if (Var->getSection() == StringRef("llvm.metadata")) Res |= BasicSymbolRef::SF_FormatSpecific; } - if (auto *F = dyn_cast(GV)) { - if (F->getName().startswith("llvm.")) - Res |= BasicSymbolRef::SF_FormatSpecific; - } - return Res; } diff --git a/llvm/test/Object/Inputs/trivial.ll b/llvm/test/Object/Inputs/trivial.ll index 622d1e97f1e3..463442eb90ac 100644 --- a/llvm/test/Object/Inputs/trivial.ll +++ b/llvm/test/Object/Inputs/trivial.ll @@ -13,3 +13,4 @@ declare void @SomeOtherFunction(...) @var = global i32 0 @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* @var to i8*)], section "llvm.metadata" +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* null, i8* null }]