Commit r260791 contained an error in that it would introduce a cross-module
reference in the old module. It also introduced O(N^2) complexity in the
module cloner by requiring the entire module to be visited for each function.
Fix both of these problems by avoiding use of the CloneDebugInfoMetadata
function (which is only designed to do intra-module cloning) and cloning
function-attached metadata in the same way that we clone all other metadata.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
If you add a test this LGTM. I suggest adding something to
unittests/Transforms/Utils/.
This is already covered by the test CloneModule, Subprogram that was added by r260791. But I suppose I could add another test for another attribute since that is new functionality.
That test passes without this patch...
Can you test specifically for the bug you're fixing?
Most likely, let me see if I can reproduce the issue that Teresa found (I was mostly looking at the complexity issue).
LGTM, but would be good for Adrian or Duncan to take a look.
lib/Transforms/Utils/CloneFunction.cpp | ||
---|---|---|
194 ↗ | (On Diff #52001) | Maybe add a comment about this applying only to cloning within a single module? |
Sorry, looks like I'll have to go back to the drawing board with this one, it causes test failures in check-clang.
The problems were related to the calls to CloneFunction in lib/CodeGen/CGVTables.cpp` and in lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp. In both cases we were wrongly cloning distinct debug info, which confused later codegen/verifier passes. This update fixes the inconsistency. Please take another look.
@tstellarAMD it's a little surprising that the only test coverage for the always inline pass in the case where there's debug info is in Clang (specifically in test/CodeGen/backend-unsupported-error.ll, which seems to test something else). Might be something worth adding coverage for in LLVM?
lib/Transforms/Utils/CloneFunction.cpp | ||
---|---|---|
198–199 ↗ | (On Diff #52124) | I have a followup patch which will completely remove this function. |