[llvm] r299018 - Add ifunc support to ModuleSymbolTable.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 29 13:04:07 PDT 2017


On Wed, Mar 29, 2017 at 12:26 PM, Rafael Espindola via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: rafael
> Date: Wed Mar 29 14:26:26 2017
> New Revision: 299018
>
> URL: http://llvm.org/viewvc/llvm-project?rev=299018&view=rev
> Log:
> Add ifunc support to ModuleSymbolTable.
>

Thanks!


> Do that by creating a global_values, which is similar to
> global_objects, but also iterates over aliases and ifuncs.
>
> Modified:
>     llvm/trunk/include/llvm/IR/Module.h
>     llvm/trunk/lib/Object/ModuleSymbolTable.cpp
>     llvm/trunk/test/Object/X86/nm-ir.ll
>
> Modified: llvm/trunk/include/llvm/IR/Module.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/
> IR/Module.h?rev=299018&r1=299017&r2=299018&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/IR/Module.h (original)
> +++ llvm/trunk/include/llvm/IR/Module.h Wed Mar 29 14:26:26 2017
> @@ -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
>    /// @{
>
> Modified: llvm/trunk/lib/Object/ModuleSymbolTable.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Mo
> duleSymbolTable.cpp?rev=299018&r1=299017&r2=299018&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Object/ModuleSymbolTable.cpp (original)
> +++ llvm/trunk/lib/Object/ModuleSymbolTable.cpp Wed Mar 29 14:26:26 2017
> @@ -43,12 +43,8 @@ void ModuleSymbolTable::addModule(Module
>    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));
>
> Modified: llvm/trunk/test/Object/X86/nm-ir.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/
> X86/nm-ir.ll?rev=299018&r1=299017&r2=299018&view=diff
> ============================================================
> ==================
> --- llvm/trunk/test/Object/X86/nm-ir.ll (original)
> +++ llvm/trunk/test/Object/X86/nm-ir.ll Wed Mar 29 14:26:26 2017
> @@ -12,6 +12,7 @@
>  ; CHECK-NEXT: C g3
>  ; CHECK-NOT: g4
>  ; CHECK-NEXT: T global_asm_sym
> +; CHECK-NEXT: D ifunc_f1
>

Should the expected output be "i ifunc_f1"?


>  ; CHECK-NEXT: t local_asm_sym
>  ; CHECK-NEXT: U undef_asm_sy
>
> @@ -36,6 +37,8 @@ define void @f1() {
>    ret void
>  }
>
> + at ifunc_f1 = ifunc void (), void ()* @f1
> +
>  define internal void @f2() {
>    ret void
>  }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>



-- 
-- 
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170329/cb62a9f5/attachment.html>


More information about the llvm-commits mailing list