diff options
-rw-r--r-- | llvm/include/llvm/IR/Module.h | 26 | ||||
-rw-r--r-- | llvm/lib/Object/ModuleSymbolTable.cpp | 6 | ||||
-rw-r--r-- | llvm/test/Object/X86/nm-ir.ll | 3 |
3 files changed, 30 insertions, 5 deletions
diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h index de10b099a68..a2c64623da8 100644 --- a/llvm/include/llvm/IR/Module.h +++ b/llvm/include/llvm/IR/Module.h @@ -617,6 +617,32 @@ public: return global_objects().end(); } + typedef concat_iterator<GlobalValue, iterator, global_iterator, + alias_iterator, ifunc_iterator> + global_value_iterator; + typedef concat_iterator<const GlobalValue, const_iterator, + const_global_iterator, const_alias_iterator, + const_ifunc_iterator> + const_global_value_iterator; + + iterator_range<global_value_iterator> global_values() { + return concat<GlobalValue>(functions(), globals(), aliases(), ifuncs()); + } + iterator_range<const_global_value_iterator> global_values() const { + return concat<const GlobalValue>(functions(), globals(), aliases(), + ifuncs()); + } + + global_value_iterator global_value_begin() { return global_values().begin(); } + global_value_iterator global_value_end() { return global_values().end(); } + + const_global_value_iterator global_value_begin() const { + return global_values().begin(); + } + const_global_value_iterator global_value_end() const { + return global_values().end(); + } + /// @} /// @name Named Metadata Iteration /// @{ diff --git a/llvm/lib/Object/ModuleSymbolTable.cpp b/llvm/lib/Object/ModuleSymbolTable.cpp index 21709b5c223..9a935d8e086 100644 --- a/llvm/lib/Object/ModuleSymbolTable.cpp +++ b/llvm/lib/Object/ModuleSymbolTable.cpp @@ -43,12 +43,8 @@ void ModuleSymbolTable::addModule(Module *M) { else FirstMod = M; - for (Function &F : *M) - SymTab.push_back(&F); - for (GlobalVariable &GV : M->globals()) + for (GlobalValue &GV : M->global_values()) SymTab.push_back(&GV); - for (GlobalAlias &GA : M->aliases()) - SymTab.push_back(&GA); CollectAsmSymbols(*M, [this](StringRef Name, BasicSymbolRef::Flags Flags) { SymTab.push_back(new (AsmSymbols.Allocate()) AsmSymbol(Name, Flags)); diff --git a/llvm/test/Object/X86/nm-ir.ll b/llvm/test/Object/X86/nm-ir.ll index 1742a8f938e..29f7a5c7018 100644 --- a/llvm/test/Object/X86/nm-ir.ll +++ b/llvm/test/Object/X86/nm-ir.ll @@ -12,6 +12,7 @@ ; CHECK-NEXT: C g3 ; CHECK-NOT: g4 ; CHECK-NEXT: T global_asm_sym +; CHECK-NEXT: D ifunc_f1 ; CHECK-NEXT: t local_asm_sym ; CHECK-NEXT: U undef_asm_sy @@ -36,6 +37,8 @@ define void @f1() { ret void } +@ifunc_f1 = ifunc void (), void ()* @f1 + define internal void @f2() { ret void } |