[llvm] r299018 - Add ifunc support to ModuleSymbolTable.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 29 13:32:41 PDT 2017


On 29 March 2017 at 16:04, Peter Collingbourne <peter at pcc.me.uk> wrote:
> 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/ModuleSymbolTable.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"?

Yes, but currently we don't get that even for ELF. I will open a bug.

Cheers,
Rafael


More information about the llvm-commits mailing list