[llvm-dev] llvm-ir: anonymous struct name mangling

Jeroen Dobbelaere via llvm-dev llvm-dev at lists.llvm.org
Tue Nov 10 03:08:33 PST 2020


Hi,

Nikita pointed me to an issue in the full restrict patches, related to name mangling used for llvm-ir functions (See [0, 3]).


The problem is the following: Given:

  %0 = type { i32 }
  %1 = type { i32 }

  
Creating an intrinsic @llvm.FOO that accepts 'a pointer to %0' cannot be distinguished from the intrinsic accepting 'a pointer to %1':
  ;For a %0* ptr0, %1* ptr1  
  
  call @llvm.FOO.p0s_s %0* %ptr0
  call @llvm.FOO.p0s_s %1* %ptr1   ; assertion failure: same name produced, but %ptr1 is not compatible with '%0*'

It seems that the name mangling is not coping well with anonymous structs ?
See: [1,2]: All anonymous structs get a 's_s' mangling. Still, %0 and %1 are treated as different types.

Any idea what the best way is to handle (or fix) this ?
(My feeling is that the name mangling should be improved, but at the moment I have no clue what the right approach would be)

Thanks,

Jeroen Dobbelaere


[0] The problem, as reported by Nikita: https://reviews.llvm.org/D68484#2372356
[1] Intrinsic::getName  https://github.com/llvm/llvm-project/blob/master/llvm/lib/IR/Function.cpp#L775
[2] getMangledTypeStr for a struct:  https://github.com/llvm/llvm-project/blob/master/llvm/lib/IR/Function.cpp#L725
[3] The actual intrinsic creation that triggered the problem: https://reviews.llvm.org/D68491  (Look for 'Intrinsic::getDeclaration')





More information about the llvm-dev mailing list