[PATCH] D149781: [llvm-mca] Fix duplicate symbols error
Michael Maitland via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 3 13:28:37 PDT 2023
michaelmaitland created this revision.
michaelmaitland added reviewers: ormris, andreadb, myhsu.
Herald added a subscriber: gbedwell.
Herald added a project: All.
michaelmaitland requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D149781
Files:
llvm/test/tools/llvm-mca/X86/Generic/no-duplicate-symbols.s
llvm/tools/llvm-mca/llvm-mca.cpp
Index: llvm/tools/llvm-mca/llvm-mca.cpp
===================================================================
--- llvm/tools/llvm-mca/llvm-mca.cpp
+++ llvm/tools/llvm-mca/llvm-mca.cpp
@@ -401,11 +401,6 @@
// 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 @@
}
// 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 @@
// 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 @@
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(
Index: llvm/test/tools/llvm-mca/X86/Generic/no-duplicate-symbols.s
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-mca/X86/Generic/no-duplicate-symbols.s
@@ -0,0 +1,8 @@
+# RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=x86-64 < %s 2>&1 | FileCheck %s
+
+# This test checks that https://github.com/llvm/llvm-project/issues/62528 is resolved.
+foo:
+ pushq %rbp
+
+# CHECK-NOT: <stdin>:4:1: error: symbol 'foo' is already defined
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149781.519228.patch
Type: text/x-patch
Size: 2795 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230503/36ccf29e/attachment.bin>
More information about the llvm-commits
mailing list