[AutoDiff] [SR-14240] Align name mangling for Clang-imported declarations #38850
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When importing Clang declarations, DifferentiationMangler handles their non-mangled names differently than other mangled functions. ASTMangler currently does not, and as a consequence
createEmptyVJP()
andcreateEmptyJVP()
add empty JVPs and VJPs with different mangled names for IR and TBD.When you try to add a custom VJP to one of these imported functions, like in the following:
You hit an error of
error: symbol 'powTJfSSpSr' (powTJfSSpSr) is in generated IR file, but not in TBD file
due to the matching empty JVP that is created.This PR has
ASTMangler::beginManglingWithAutoDiffOriginalFunction()
detect imported Clang functions and mangles them in the same way as DifferentiationMangler. That then prevents the difference in symbols that triggers the above error.Resolves SR-14240.