diff options
author | Michael Maitland <michaeltmaitland@gmail.com> | 2023-05-03 13:24:44 -0700 |
---|---|---|
committer | Michael Maitland <michaeltmaitland@gmail.com> | 2023-05-03 18:01:46 -0700 |
commit | 1c2b8129e99478a9b0222fc0aaf44a4a47e7ecd6 (patch) | |
tree | 2cbd46d044c5af01b82c892064a8ff491a45ecb3 /llvm/tools/llvm-mca/llvm-mca.cpp | |
parent | 2dc0fa050eff14fe5c4249fb44d42f29b41d5da4 (diff) | |
download | llvm-1c2b8129e99478a9b0222fc0aaf44a4a47e7ecd6.zip llvm-1c2b8129e99478a9b0222fc0aaf44a4a47e7ecd6.tar.gz llvm-1c2b8129e99478a9b0222fc0aaf44a4a47e7ecd6.tar.bz2 |
[llvm-mca] Fix duplicate symbols error
Parsing instruments and analysis regions causes us to see the same
labels two times since we parse the same file twice under the same
context.
This change creates a seperate context for instrument parsing
and another for analysis region parsing. I will post a follow up
commit once I get some free cycles to parse analysis regions and
instruments in one parsing pass under a single context.
Differential Revision: https://reviews.llvm.org/D149781
Diffstat (limited to 'llvm/tools/llvm-mca/llvm-mca.cpp')
-rw-r--r-- | llvm/tools/llvm-mca/llvm-mca.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp index babe73f..ff29e39 100644 --- a/llvm/tools/llvm-mca/llvm-mca.cpp +++ b/llvm/tools/llvm-mca/llvm-mca.cpp @@ -401,11 +401,6 @@ int main(int argc, char **argv) { // Tell SrcMgr about this buffer, which is what the parser will pick up. SrcMgr.AddNewSourceBuffer(std::move(*BufferPtr), SMLoc()); - MCContext Ctx(TheTriple, MAI.get(), MRI.get(), STI.get(), &SrcMgr); - std::unique_ptr<MCObjectFileInfo> MOFI( - TheTarget->createMCObjectFileInfo(Ctx, /*PIC=*/false)); - Ctx.setObjectFileInfo(MOFI.get()); - std::unique_ptr<buffer_ostream> BOS; std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo()); @@ -433,7 +428,11 @@ int main(int argc, char **argv) { } // Parse the input and create CodeRegions that llvm-mca can analyze. - mca::AsmAnalysisRegionGenerator CRG(*TheTarget, SrcMgr, Ctx, *MAI, *STI, + MCContext ACtx(TheTriple, MAI.get(), MRI.get(), STI.get(), &SrcMgr); + std::unique_ptr<MCObjectFileInfo> AMOFI( + TheTarget->createMCObjectFileInfo(ACtx, /*PIC=*/false)); + ACtx.setObjectFileInfo(AMOFI.get()); + mca::AsmAnalysisRegionGenerator CRG(*TheTarget, SrcMgr, ACtx, *MAI, *STI, *MCII); Expected<const mca::AnalysisRegions &> RegionsOrErr = CRG.parseAnalysisRegions(std::move(IPtemp)); @@ -471,7 +470,11 @@ int main(int argc, char **argv) { // Parse the input and create InstrumentRegion that llvm-mca // can use to improve analysis. - mca::AsmInstrumentRegionGenerator IRG(*TheTarget, SrcMgr, Ctx, *MAI, *STI, + MCContext ICtx(TheTriple, MAI.get(), MRI.get(), STI.get(), &SrcMgr); + std::unique_ptr<MCObjectFileInfo> IMOFI( + TheTarget->createMCObjectFileInfo(ICtx, /*PIC=*/false)); + ICtx.setObjectFileInfo(IMOFI.get()); + mca::AsmInstrumentRegionGenerator IRG(*TheTarget, SrcMgr, ICtx, *MAI, *STI, *MCII, *IM); Expected<const mca::InstrumentRegions &> InstrumentRegionsOrErr = IRG.parseInstrumentRegions(std::move(IPtemp)); @@ -547,7 +550,7 @@ int main(int argc, char **argv) { unsigned RegionIdx = 0; std::unique_ptr<MCCodeEmitter> MCE( - TheTarget->createMCCodeEmitter(*MCII, Ctx)); + TheTarget->createMCCodeEmitter(*MCII, ACtx)); assert(MCE && "Unable to create code emitter!"); std::unique_ptr<MCAsmBackend> MAB(TheTarget->createMCAsmBackend( |