[compiler-rt] [clang] [llvm] [Profile] Refactor profile correlation. (PR #70712)
Zequan Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 31 08:35:17 PDT 2023
ZequanWu wrote:
I can repro the linking failures when using the same cmake invocation.
Here is the full command:
```
$ /usr/bin/c++ -std=c++11 -Wno-documentation-deprecated-sync -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -Wl,--gc-sections unittests/IR/CMakeFiles/IRTests.dir/AbstractCallSiteTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/AsmWriterTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/AttributesTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/BasicBlockTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/CFGBuilder.cpp.o unittests/IR/CMakeFiles/IRTests.dir/ConstantRangeTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/ConstantsTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/DataLayoutTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/DebugInfoTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/DebugTypeODRUniquingTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/DemandedBitsTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/DominatorTreeTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/DominatorTreeBatchUpdatesTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/FunctionTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/PassBuilderCallbacksTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/IRBuilderTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/InstructionsTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/IntrinsicsTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/LegacyPassManagerTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/MDBuilderTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/ManglerTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/MetadataTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/ModuleTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/ModuleSummaryIndexTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/PassManagerTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/PatternMatch.cpp.o unittests/IR/CMakeFiles/IRTests.dir/ShuffleVectorInstTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/StructuralHashTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/TimePassesTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/TypesTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/UseTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/UserTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/ValueHandleTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/ValueMapTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/ValueTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/VectorBuilderTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/VectorTypesTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/VerifierTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/VPIntrinsicTest.cpp.o unittests/IR/CMakeFiles/IRTests.dir/CoreBindings.cpp.o -o unittests/IR/IRTests lib/libLLVMAnalysis.a lib/libLLVMAsmParser.a lib/libLLVMCore.a lib/libLLVMSupport.a lib/libLLVMPasses.a lib/libLLVMTargetParser.a lib/libLLVMTransformUtils.a lib/libLLVMScalarOpts.a lib/libLLVMSupport.a lib/libllvm_gtest_main.a lib/libllvm_gtest.a lib/libLLVMTestingSupport.a lib/libLLVMCodeGen.a lib/libLLVMCodeGenTypes.a lib/libLLVMCoroutines.a lib/libLLVMHipStdPar.a lib/libLLVMipo.a lib/libLLVMBitWriter.a lib/libLLVMFrontendOpenMP.a lib/libLLVMScalarOpts.a lib/libLLVMAggressiveInstCombine.a lib/libLLVMFrontendOffloading.a lib/libLLVMLinker.a lib/libLLVMInstCombine.a lib/libLLVMIRPrinter.a lib/libLLVMObjCARCOpts.a lib/libLLVMTarget.a lib/libLLVMVectorize.a lib/libLLVMInstrumentation.a lib/libLLVMTransformUtils.a lib/libLLVMAnalysis.a lib/libLLVMProfileData.a lib/libLLVMSymbolize.a lib/libLLVMDebugInfoPDB.a lib/libLLVMDebugInfoMSF.a lib/libLLVMDebugInfoBTF.a lib/libLLVMDebugInfoDWARF.a lib/libLLVMObject.a lib/libLLVMIRReader.a lib/libLLVMAsmParser.a lib/libLLVMBitReader.a lib/libLLVMCore.a lib/libLLVMRemarks.a lib/libLLVMBitstreamReader.a lib/libLLVMMCParser.a lib/libLLVMTextAPI.a lib/libLLVMMC.a lib/libLLVMBinaryFormat.a lib/libLLVMTargetParser.a lib/libLLVMDebugInfoCodeView.a lib/libllvm_gtest.a lib/libLLVMSupport.a lib/libLLVMDemangle.a -lrt -ldl -lm /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/x86_64-linux-gnu/libzstd.so /usr/lib/x86_64-linux-gnu/libtinfo.so -lpthread
/usr/bin/ld: lib/libLLVMInstrumentation.a(InstrProfiling.cpp.o): in function `llvm::InstrProfiling::lowerValueProfileInst(llvm::InstrProfValueProfileInst*) [clone .localalias]':
InstrProfiling.cpp:(.text._ZN4llvm14InstrProfiling21lowerValueProfileInstEPNS_25InstrProfValueProfileInstE+0x1a): undefined reference to `llvm::DebugInfoCorrelate'
/usr/bin/ld: InstrProfiling.cpp:(.text._ZN4llvm14InstrProfiling21lowerValueProfileInstEPNS_25InstrProfValueProfileInstE+0x2a): undefined reference to `llvm::ProfileCorrelate'
/usr/bin/ld: lib/libLLVMInstrumentation.a(InstrProfiling.cpp.o): in function `llvm::InstrProfiling::setupProfileSection(llvm::InstrProfInstBase*, llvm::InstrProfSectKind) [clone .localalias]':
InstrProfiling.cpp:(.text._ZN4llvm14InstrProfiling19setupProfileSectionEPNS_17InstrProfInstBaseENS_17InstrProfSectKindE+0x68): undefined reference to `llvm::DebugInfoCorrelate'
/usr/bin/ld: InstrProfiling.cpp:(.text._ZN4llvm14InstrProfiling19setupProfileSectionEPNS_17InstrProfInstBaseENS_17InstrProfSectKindE+0x243): undefined reference to `llvm::ProfileCorrelate'
/usr/bin/ld: lib/libLLVMInstrumentation.a(InstrProfiling.cpp.o): in function `llvm::InstrProfiling::getOrCreateRegionCounters(llvm::InstrProfCntrInstBase*) [clone .localalias]':
InstrProfiling.cpp:(.text._ZN4llvm14InstrProfiling25getOrCreateRegionCountersEPNS_21InstrProfCntrInstBaseE+0x12a): undefined reference to `llvm::DebugInfoCorrelate'
/usr/bin/ld: InstrProfiling.cpp:(.text._ZN4llvm14InstrProfiling25getOrCreateRegionCountersEPNS_21InstrProfCntrInstBaseE+0x13a): undefined reference to `llvm::ProfileCorrelate'
/usr/bin/ld: lib/libLLVMInstrumentation.a(InstrProfiling.cpp.o): in function `llvm::InstrProfiling::run(llvm::Module&, std::function<llvm::TargetLibraryInfo const& (llvm::Function&)>) [clone .localalias]':
InstrProfiling.cpp:(.text._ZN4llvm14InstrProfiling3runERNS_6ModuleESt8functionIFRKNS_17TargetLibraryInfoERNS_8FunctionEEE+0x486): undefined reference to `llvm::DebugInfoCorrelate'
/usr/bin/ld: InstrProfiling.cpp:(.text._ZN4llvm14InstrProfiling3runERNS_6ModuleESt8functionIFRKNS_17TargetLibraryInfoERNS_8FunctionEEE+0x49b): undefined reference to `llvm::ProfileCorrelate'
/usr/bin/ld: lib/libLLVMInstrumentation.a(PGOInstrumentation.cpp.o): in function `createIRLevelProfileFlagVar(llvm::Module&, bool)':
PGOInstrumentation.cpp:(.text._ZL27createIRLevelProfileFlagVarRN4llvm6ModuleEb+0x5f): undefined reference to `llvm::DebugInfoCorrelate'
/usr/bin/ld: PGOInstrumentation.cpp:(.text._ZL27createIRLevelProfileFlagVarRN4llvm6ModuleEb+0x73): undefined reference to `llvm::ProfileCorrelate'
collect2: error: ld returned 1 exit status
```
Note that we have `File: lib/libLLVMCodeGen.a(TargetLoweringObjectFileImpl.cpp.o)` and `File: lib/libLLVMInstrumentation.a(InstrProfiling.cpp.o)` so they should be able to linked together. And if I switch to clang and use `-fuse-ld=lld` removing `-fno-lifetime-dse`, this links successfully. So, it is a ld problem causing the linking error, but I have to work around this.
I'll just simply remove the flag `-profile-correlate` and keep `-debug-info-correlate`.
https://github.com/llvm/llvm-project/pull/70712
More information about the cfe-commits
mailing list