This case triggers when merge-similar-functions tries to extract instructions out of instantiations of a template function.
Diff Detail
Event Timeline
Looks generally good, some nitpicks inside.
include/llvm/Transforms/Utils/Cloning.h | ||
---|---|---|
161 | Can you add an enum { ExtractingFunctions = true; CloningIntoSameModule = false; }; or something along those lines for better readability? | |
test/Transforms/MergeSimilarFunc/merge-debug-info-2.ll | ||
59 | Is there a reason why this function needs to have more than just a single instruction? | |
69 | please delete all the !tbaa metadata it's just distracting and will make the test harder to update in the future. | |
86 | please delete all non-essential attributes (everything in quotes). |
lib/Transforms/Utils/CloneFunction.cpp | ||
---|---|---|
136 | How about changing this to MustCloneSP = !ExtractingFunction && OldFunc->getParent() && OldFunc->getParent() == NewFunc->getParent(). Then you can leave the if block right after unchanged. |
test/Transforms/MergeSimilarFunc/merge-debug-info-2.ll | ||
---|---|---|
59 | Merge function seem to have some size metric to merge instructions. I think it may be possible to reduce a little bit but how much I'm not sure. |
You can use attributes to force inlining or non-inlining to create a
particular scenario.
include/llvm/Transforms/Utils/Cloning.h | ||
---|---|---|
132 | /// Used to control \p CloneFunctionInto. enum class CloneType { InvalidCloneType, /// Cloning will result in module level changes. ModuleLevelChanges, /// What does this mean exactly? Do we even need it? NoModuleLevelChanges, /// Cloning will be used for extracting functions /// by passes like function merging, it does not require module level changes /// but debug info needs special treatment like: DISubprogram is not cloned. ExtractingFunctions, }; |
include/llvm/Transforms/Utils/Cloning.h | ||
---|---|---|
132 |
This is used in cases when we dont want module level changes but it is not used for extracting functions. I did not want to modify the behavior at other places so introduced this for example: calls to CloneFunctionInto in Cloning.cpp. Perhaps we can merge ExtractingFunctions with NoModuleLevelChanges but I'm not very sure. |
include/llvm/Transforms/Utils/Cloning.h | ||
---|---|---|
137 | Could you please comment that explains exactly what scenario this is supposed to be used for? The idea being that If we can't document the use-case precisely, we probably should not have this mode. |
Can you please also add documentation to CloneFunctionInto that explains what the difference between those modes is?