This is an attempt topatch adds support for intrinsic overloading on anonymous struct basunnamed types.
This fixes PR38117 and will also be needed for the Full Restrict Patches (D68484).
The main problem is that the intrinsic overloading name mangling is using 's_s' for anonymous structsunnamed types.
This can result in identical intrinsic mangled names for different function prototypes.
This patch changes this by adding a '.XXXXX' to such the intrinsic mangled name when at least one of the types is based on an unnamesd type, ensuring that the name iswe get a uniquee name.
- The mapping is created on demand and kept in Module.
- It also check for existing clashes and recycles potentially existing prototypes and declarations.
- Because of extra data in Module, Intrinsic::getName needs an extra Module* argument and, for speed, an optional FunctionType* argument.
- I still kept the original two-argument 'Intrinsic::getName' around which keeps the original behavior (providing the base name).
(-- Main reason is that I did not want to change the LLVMIntrinsicGetName version, as I don't know how acceptable such a change is
-- The current situation already has a limitation. as I don't know how acceptable such a change is)So that should not get worse with this patch.
- Intrinsic::getDeclaration and the verifier are now using the new version.
- A testcase is not yet included. I first want to get feedback if this is an acceptable approach to the problem
- As far as I see, this should not suffer from stability issues. The count is only added for prototypes depending on at least one anonymous struct
- The initial count starts from 0 for each intrinsic idmangled name.
- In case of name clashes, existing prototypes are remembered and reused when that makes sense.
- In case of name clashes, I try to reuse existing names.
- on second thought: the current mechanism does not prohibit associating different 'BaseName's to the same intrinsic id. In this case they still share the 'unique number count'. It could make sense to associate the unique number to the 'BaseName' instead of to the intrinsic id.