[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-12 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 marked an inline comment as done.
flip1995 added inline comments.



Comment at: clang/tools/driver/cc1as_main.cpp:407
 
-  MOFI->initMCObjectFileInfo(Ctx, PIC);
+  // FIXME: This is not pretty. MCContext has a ptr to MCObjectFileInfo and
+  // MCObjectFileInfo needs a MCContext reference in order to initialize 
itself.

MaskRay wrote:
> Can we fix the FIXME now?
Not quite. The construction is still in the order `MCContext` -> `MOFI` -> 
"continue construction of `MCContext` by setting the `MOFI`".  The order just 
changed from "dummy `MOFI`" -> `MCContext` -> "init dummy `MOFI`".



Comment at: llvm/include/llvm/MC/MCObjectFileInfo.h:255
 
+  virtual unsigned getTextSectionAlignment() const { return 4; }
   MCSection *getTextSection() const { return TextSection; }

MaskRay wrote:
> This should be moved to D102052
Will do.



Comment at: llvm/lib/DWARFLinker/DWARFStreamer.cpp:57
 
-  MOFI.reset(new MCObjectFileInfo);
-  MC.reset(
-  new MCContext(TheTriple, MAI.get(), MRI.get(), MOFI.get(), MSTI.get()));
-  MOFI->initMCObjectFileInfo(*MC, /*PIC=*/false);
+  MC.reset(new MCContext(TheTriple, MAI.get(), MRI.get(), /*MOFI=*/nullptr,
+ MSTI.get()));

MaskRay wrote:
> flip1995 wrote:
> > MaskRay wrote:
> > > The argument is almost always `/*MOFI=*/nullptr`. Doesn't this regress a 
> > > bit?
> > I agree. I think the best thing to do here would be to just remove this 
> > argument?
> I think so. Since MOFI is guaranteed to be constructed after MCContext now. 
Will do.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101921/new/

https://reviews.llvm.org/D101921

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-13 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 updated this revision to Diff 344849.
flip1995 added a comment.
Herald added subscribers: lldb-commits, atanasyan, jrtc27.
Herald added a project: LLDB.

rebased and addressed review comments:

- [MC] Remove MOFI argument from MCContext constructor
- [MC] Remove getTextSectionAlignment function from MCObjectFileInfo


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101921/new/

https://reviews.llvm.org/D101921

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/Support/TargetRegistry.h
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCDisassembler/Disassembler.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.h
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.h
  llvm/tools/llvm-exegesis/lib/LlvmState.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-jitlink/llvm-jitlink.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/Disassembler.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/MachODump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/tools/sancov/sancov.cpp
  llvm/unittests/CodeGen/MachineInstrTest.cpp
  llvm/unittests/CodeGen/MachineOperandTest.cpp
  llvm/unittests/CodeGen/TestAsmPrinter.cpp
  llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
  llvm/unittests/MC/DwarfLineTables.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
  mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp

Index: mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
===
--- mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -168,9 +168,10 @@
   target->createMCAsmInfo(*mri, this->triple, mcOptions));
   mai->setRelaxELFRelocations(true);
 
-  llvm::MCObjectFileInfo mofi;
-  llvm::MCContext ctx(triple, mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
-  mofi.initMCObjectFileInfo(ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
+  llvm::MCContext ctx(triple, mai.get(), mri.get(), &srcMgr, &mcOptions);
+  std::unique_ptr mofi(target->createMCObjectFileInfo(
+  ctx, /*PIC=*/false, /*LargeCodeModel=*/false));
+  ctx.setObjectFileInfo(mofi.get());
 
   SmallString<128> cwd;
   if (!llvm::sys::fs::current_path(cwd))
Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -62,6 +62,7 @@
   std::unique_ptr MRI;
   std::unique_ptr MUPMAI;
   std::unique_ptr MII;
+  std::unique_ptr MOFI;
   std::unique_ptr Str;
   std::unique_ptr Parser;
   std::unique_ptr Ctx;
@@ -74,7 +75,6 @@
   const Target *TheTarget;
 
   const MCTargetOptions MCOptions;
-  MCObjectFileInfo MOFI;
 
   SystemZAsmLexerTest() {
 // We will use the SystemZ triple, because of missing
@@ -112,9 +112,11 @@
 SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 EXPECT_EQ(Buffer, nullptr);
 
-Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), &MOFI, STI.get(),
-&SrcMgr, &MCOptions));
-MOFI.initMCObjectFileInfo(*Ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
+Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), STI.get(), &SrcMgr,
+&MCOptions));
+MOFI.reset(TheTarget->createMCObjectFileInfo(*Ctx, /*PIC=*/false,
+ /*LargeCodeModel=*/false));
+Ctx->setObjectFileInfo(MOFI.get());
 
 Str.reset(TheTarget->createNullStreamer(*Ctx));
 
Index: llvm/unittests/MC/DwarfLineTables.cpp
===
--- llvm/unittests/MC/DwarfLineTables.cpp
+++ llvm/unittests/MC/DwarfLineTables.cpp
@@ -41,7 +41,7 @@
 MCTargetOptions MCOptions;
 MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
 Ctx = std::make_unique(Triple(TripleName), MAI.get(), MRI.get(),
-  /*MOFI=*/nullptr, /*MSTI=*/nullptr);
+  /*MSTI=*/nullptr);
   }
 
   operator bool() { return Ctx.get(); }
Index: llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
===
--- llvm/un

[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-13 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 added a comment.

In D101921#2754426 , @MaskRay wrote:

> Can `createMCObjectFileInfo` return `MCObjectFileInfo` instead of 
> `std::unique_ptr`?

`createMCObjectfileInfo` returns a `MCObjectFileInfo *` similar to every other 
`create*` function in `TargetRegistry.h`.




Comment at: clang/lib/Parse/ParseStmtAsm.cpp:590
+
   if (!MAI || !MII || !MOFI || !STI) {
 Diag(AsmLoc, diag::err_msasm_unable_to_create_target)

MaskRay wrote:
> Can `MOFI` be null? (i.e. can createMCObjectFileInfo guarantee no-null return 
> value?)
> 
> Consider moving the construction below the checks.
You're right. The `createMCObjectFileInfo` always returns a no-null value. I'll 
move the construction and remove the check for `MOFI`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101921/new/

https://reviews.llvm.org/D101921

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-14 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 updated this revision to Diff 345432.
flip1995 added a comment.

- [MC] Don't check if constructed MOFI is a nullptr


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101921/new/

https://reviews.llvm.org/D101921

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/Support/TargetRegistry.h
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCDisassembler/Disassembler.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.h
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.h
  llvm/tools/llvm-exegesis/lib/LlvmState.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-jitlink/llvm-jitlink.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/Disassembler.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/MachODump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/tools/sancov/sancov.cpp
  llvm/unittests/CodeGen/MachineInstrTest.cpp
  llvm/unittests/CodeGen/MachineOperandTest.cpp
  llvm/unittests/CodeGen/TestAsmPrinter.cpp
  llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
  llvm/unittests/MC/DwarfLineTables.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
  mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp

Index: mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
===
--- mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -168,9 +168,10 @@
   target->createMCAsmInfo(*mri, this->triple, mcOptions));
   mai->setRelaxELFRelocations(true);
 
-  llvm::MCObjectFileInfo mofi;
-  llvm::MCContext ctx(triple, mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
-  mofi.initMCObjectFileInfo(ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
+  llvm::MCContext ctx(triple, mai.get(), mri.get(), &srcMgr, &mcOptions);
+  std::unique_ptr mofi(target->createMCObjectFileInfo(
+  ctx, /*PIC=*/false, /*LargeCodeModel=*/false));
+  ctx.setObjectFileInfo(mofi.get());
 
   SmallString<128> cwd;
   if (!llvm::sys::fs::current_path(cwd))
Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -62,6 +62,7 @@
   std::unique_ptr MRI;
   std::unique_ptr MUPMAI;
   std::unique_ptr MII;
+  std::unique_ptr MOFI;
   std::unique_ptr Str;
   std::unique_ptr Parser;
   std::unique_ptr Ctx;
@@ -74,7 +75,6 @@
   const Target *TheTarget;
 
   const MCTargetOptions MCOptions;
-  MCObjectFileInfo MOFI;
 
   SystemZAsmLexerTest() {
 // We will use the SystemZ triple, because of missing
@@ -112,9 +112,11 @@
 SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 EXPECT_EQ(Buffer, nullptr);
 
-Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), &MOFI, STI.get(),
-&SrcMgr, &MCOptions));
-MOFI.initMCObjectFileInfo(*Ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
+Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), STI.get(), &SrcMgr,
+&MCOptions));
+MOFI.reset(TheTarget->createMCObjectFileInfo(*Ctx, /*PIC=*/false,
+ /*LargeCodeModel=*/false));
+Ctx->setObjectFileInfo(MOFI.get());
 
 Str.reset(TheTarget->createNullStreamer(*Ctx));
 
Index: llvm/unittests/MC/DwarfLineTables.cpp
===
--- llvm/unittests/MC/DwarfLineTables.cpp
+++ llvm/unittests/MC/DwarfLineTables.cpp
@@ -41,7 +41,7 @@
 MCTargetOptions MCOptions;
 MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
 Ctx = std::make_unique(Triple(TripleName), MAI.get(), MRI.get(),
-  /*MOFI=*/nullptr, /*MSTI=*/nullptr);
+  /*MSTI=*/nullptr);
   }
 
   operator bool() { return Ctx.get(); }
Index: llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
+++ llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
@@ -464,9 +464,10 @@
 return make_error("no target machine for target " + TripleName,
  

[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-26 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 added inline comments.



Comment at: llvm/include/llvm/Support/TargetRegistry.h:26
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/MC/MCObjectFileInfo.h"
 #include "llvm/Support/CodeGen.h"

MaskRay wrote:
> `include/llvm/Support/TargetRegistry.h now has cyclic dependency on 
> include/MC/*.h`.
> 
> The previous style isn't good as well: 
> `include/llvm/Support/TargetRegistry.h` has forward declarations of a number 
> of MC* classes.
> 
> I think this header probably should be moved to lib/Target.
> `include/llvm/Support/TargetRegistry.h now has cyclic dependency on 
> include/MC/*.h`

I'll submit a quick fix changing this to a forward decl.

> I think this header probably should be moved to lib/Target.

The whole `TargetRegistry.h` header? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101921/new/

https://reviews.llvm.org/D101921

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-26 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 added inline comments.



Comment at: llvm/include/llvm/Support/TargetRegistry.h:26
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/MC/MCObjectFileInfo.h"
 #include "llvm/Support/CodeGen.h"

flip1995 wrote:
> MaskRay wrote:
> > `include/llvm/Support/TargetRegistry.h now has cyclic dependency on 
> > include/MC/*.h`.
> > 
> > The previous style isn't good as well: 
> > `include/llvm/Support/TargetRegistry.h` has forward declarations of a 
> > number of MC* classes.
> > 
> > I think this header probably should be moved to lib/Target.
> > `include/llvm/Support/TargetRegistry.h now has cyclic dependency on 
> > include/MC/*.h`
> 
> I'll submit a quick fix changing this to a forward decl.
> 
> > I think this header probably should be moved to lib/Target.
> 
> The whole `TargetRegistry.h` header? 
> I'll submit a quick fix changing this to a forward decl.

I just noticed, that this isn't as easy, as I would've thought, since the MOFI 
is constructed if no `createMCObjectFileInfo` callback function is defined by 
the target.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101921/new/

https://reviews.llvm.org/D101921

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101462: Make it possible for targets to define their own MCObjectFileInfo

2021-04-29 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 created this revision.
flip1995 added reviewers: MaskRay, rnk, asb.
Herald added subscribers: frasercrmck, dexonsmith, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, jocewei, rupprecht, PkmX, the_o, brucehoult, 
MartinMosbeck, rogfer01, atanasyan, edward-jones, zzheng, jrtc27, gbedwell, 
niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, mgorny, jholewinski.
Herald added a reviewer: andreadb.
Herald added a reviewer: jhenderson.
flip1995 requested review of this revision.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, aheejin.
Herald added projects: clang, LLDB, LLVM.

Some information about the object file may be target specific. As an example,
this patch removes the hard-coded 4-byte alignment for text sections and now
uses the alignment defined by the target in the target specific
MCObjectFileInfo.

To get this to work some refactoring was involved:

1. MCObjectFileInfo and MCContext depend on each other (even during 
construction)
2. This patch removes the dependency of MCContext on MCObjectFileInfo during 
construction
3. Additionally, it untangles MCContext  and MCObjectFileInfo a bit more by 
moving elements, like the TargetTriple information from MCObjectFileInfo to 
MCContext.

The contruction of a MCContext with a MCObjectFileInfo is still a little weird:

1. Construct MCContext
2. Construct MCObjectFileInfo
3. Set MOFI for MCContext

But to untangle this futher, the circular dependency between the two would've
to be removed completely, which would be too big of a change for the thing this
patch tries to achive.

The one backend that now makes usage of this patch is RISC-V, where the text
section only has to be 2-byte aligned when the C extension is enabled. This now
produces the same alignments for RISC-V text sections as GCC does.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101462

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/include/llvm/Support/TargetRegistry.h
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCDisassembler/Disassembler.cpp
  llvm/lib/MC/MCELFStreamer.cpp
  llvm/lib/MC/MCMachOStreamer.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/MC/MCParser/COFFAsmParser.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/MC/MCParser/MasmParser.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/MC/MCWinCOFFStreamer.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCObjectFileInfo.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCObjectFileInfo.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
  llvm/lib/Target/TargetLoweringObjectFile.cpp
  llvm/test/MC/RISCV/align.s
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.cpp
  llvm/tools/llvm-exegesis/lib/LlvmState.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-jitlink/llvm-jitlink.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/Disassembler.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/MachODump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/tools/sancov/sancov.cpp
  llvm/unittests/CodeGen/MachineInstrTest.cpp
  llvm/unittests/CodeGen/MachineOperandTest.cpp
  llvm/unittests/CodeGen/TestAsmPrinter.cpp
  llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
  llvm/unittests/MC/DwarfLineTables.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp

Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -57,6 +57,7 @@
   std::unique_ptr MRI;
   std::unique_ptr MUPMAI;
   std::unique_ptr MII;
+  std::unique_ptr MSTI;
   std::unique_ptr Str;
   std::unique_ptr Parser;
   std::unique_ptr Ctx;
@@ -86,6 +87,10 @@
 MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
 EXPECT_NE(MAI, nullptr);
 
+std::unique_ptr MSTI;
+MSTI.reset(TheTarget->createMCSubtargetInfo(TripleName, "", ""));
+EXPECT_NE(MSTI, nullptr

[PATCH] D101462: Make it possible for targets to define their own MCObjectFileInfo

2021-04-29 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 added a comment.

Thanks for the review! I already thought that I will have to split this up, so 
I made the commits self contained so I'll do that. One question before I start:

Where should I split this? Should I only split out the RISC-V patch and leave 
the changes that targets can define their own `MCObjectFileInfo` in (commit 
a1b3a604a410), or should I also split out that part? Personally I would keep 
this change in the refactor PR and only split out the RISC-V changes.

---

About the alignment change: I guess we can discuss this then specifically for 
RISC-V in the split out review. But the short answer is: The main motivation is 
improving code size a bit, since less padding has to be added between 
functions. If function alignment is important `-align-all-functions=X` could be 
used.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101462/new/

https://reviews.llvm.org/D101462

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101462: Make it possible for targets to define their own MCObjectFileInfo

2021-04-30 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 added a comment.

> The refactoring adding `Triple` to `MCContext::MCContext` [...] should be 
> separate.

In order to make the `MCContext` construction independent from the 
`MCObjectFileInfo`, passing the `Triple` to the `MCContext` is necessary 
anyway. Moving it completely to the `MCContext` was just the logical next step 
for me. It also simplifies calls across the code base since it removes an 
indirection over `MOFI` when accessing the triple.

I'll update this on Monday 👍


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101462/new/

https://reviews.llvm.org/D101462

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101462: Make it possible for targets to define their own MCObjectFileInfo

2021-05-03 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 updated this revision to Diff 342345.
flip1995 added a comment.

[MC] Untangle MCContext and MCObjectFileInfo

This untangles the MCContext and the MCObjectFileInfo. There is a circular
dependency between MCContext and MCObjectFileInfo. Currently this dependency
also exists during construction: You can't contruct a MOFI without a MCContext
without constructing the MCContext with a dummy version of that MOFI first.
This removes this dependency during construction. In a perfect world,
MCObjectFileInfo wouldn't depend on MCContext at all, but only be stored in the
MCContext, like other MC information. This is future work.

This also shifts/adds more information to the MCContext making it more
available to the different targets. Namely:

- TargetTriple
- ObjectFileType
- SubtargetInfo

Included Commits:

- [MC] Add MCSubtargetInfo to MCContext
- [MC] Untangle MCContext and MCObjectFileInfo
- [MC] Move TargetTriple information from MCObjectFileInfo to MCContext


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101462/new/

https://reviews.llvm.org/D101462

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCDisassembler/Disassembler.cpp
  llvm/lib/MC/MCMachOStreamer.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/MC/MCParser/COFFAsmParser.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/MC/MCParser/MasmParser.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/MC/MCWinCOFFStreamer.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
  llvm/lib/Target/TargetLoweringObjectFile.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.cpp
  llvm/tools/llvm-exegesis/lib/LlvmState.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-jitlink/llvm-jitlink.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/Disassembler.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/MachODump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/tools/sancov/sancov.cpp
  llvm/unittests/CodeGen/MachineInstrTest.cpp
  llvm/unittests/CodeGen/MachineOperandTest.cpp
  llvm/unittests/CodeGen/TestAsmPrinter.cpp
  llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
  llvm/unittests/MC/DwarfLineTables.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp

Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -57,6 +57,7 @@
   std::unique_ptr MRI;
   std::unique_ptr MUPMAI;
   std::unique_ptr MII;
+  std::unique_ptr MSTI;
   std::unique_ptr Str;
   std::unique_ptr Parser;
   std::unique_ptr Ctx;
@@ -86,6 +87,11 @@
 MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
 EXPECT_NE(MAI, nullptr);
 
+std::unique_ptr MSTI;
+MSTI.reset(TheTarget->createMCSubtargetInfo(TripleName, /*CPU=*/"",
+/*Features=*/""));
+EXPECT_NE(MSTI, nullptr);
+
 // Now we cast to our mocked up version of MCAsmInfo.
 MUPMAI.reset(static_cast(MAI.release()));
 // MUPMAI should "hold" MAI.
@@ -99,9 +105,9 @@
 SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 EXPECT_EQ(Buffer, nullptr);
 
-Ctx.reset(
-new MCContext(MUPMAI.get(), MRI.get(), &MOFI, &SrcMgr, &MCOptions));
-MOFI.InitMCObjectFileInfo(Triple, false, *Ctx, false);
+Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), &MOFI, MSTI.get(),
+&SrcMgr, &MCOptions));
+MOFI.InitMCObjectFileInfo(/*PIC=*/false, *Ctx, /*LargeCodeModel=*/false);
 
 Str.reset(TheTarget->createNullStreamer(*Ctx));
 
Index: llvm/unittests/MC/DwarfLineTables.cpp
===
--- llvm/unittests/MC/DwarfLineTables.cpp
+++ llvm/unittests/MC/DwarfLineTables.cpp
@@ -21,7 +21,7 @@
 
 namespace {
 struct Context {
-  const char *Triple = "x86_64-pc-linux";
+  const char *TripleName = "x86_64-pc-linux";
   std::unique_ptr 

[PATCH] D101462: [MC] Untangle MCContext and MCObjectFileInfo

2021-05-03 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 updated this revision to Diff 342352.
flip1995 marked 3 inline comments as done.
flip1995 edited the summary of this revision.
flip1995 added a comment.
Herald added subscribers: dcaballe, cota, teijeong, rdzhabarov, tatianashp, 
msifontes, jurahul, Kayjukh, grosul1, Joonsoo, stephenneuendorffer, liufengdb, 
aartbik, lucyrfox, mgester, arpith-jacob, csigg, nicolasvasilache, antiagainst, 
shauheen, rriddle, mehdi_amini.
Herald added a reviewer: herhut.
Herald added a project: MLIR.

Rename InitMCObjectFileInfo and reorder arguments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101462/new/

https://reviews.llvm.org/D101462

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/lib/Target/TargetLoweringObjectFile.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
  mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp

Index: mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
===
--- mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -169,8 +169,8 @@
   mai->setRelaxELFRelocations(true);
 
   llvm::MCObjectFileInfo mofi;
-  llvm::MCContext ctx(mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
-  mofi.InitMCObjectFileInfo(triple, false, ctx, false);
+  llvm::MCContext ctx(triple, mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
+  mofi.initMCObjectFileInfo(ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
 
   SmallString<128> cwd;
   if (!llvm::sys::fs::current_path(cwd))
Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -107,7 +107,7 @@
 
 Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), &MOFI, MSTI.get(),
 &SrcMgr, &MCOptions));
-MOFI.InitMCObjectFileInfo(/*PIC=*/false, *Ctx, /*LargeCodeModel=*/false);
+MOFI.initMCObjectFileInfo(*Ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
 
 Str.reset(TheTarget->createNullStreamer(*Ctx));
 
Index: llvm/tools/llvm-profgen/ProfiledBinary.cpp
===
--- llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -334,7 +334,7 @@
 
   MCObjectFileInfo MOFI;
   MCContext Ctx(Triple(TripleName), AsmInfo.get(), MRI.get(), &MOFI, STI.get());
-  MOFI.InitMCObjectFileInfo(/*PIC=*/false, Ctx);
+  MOFI.initMCObjectFileInfo(Ctx, /*PIC=*/false);
   DisAsm.reset(TheTarget->createMCDisassembler(*STI, Ctx));
   if (!DisAsm)
 exitWithError("no disassembler for target " + TripleName, FileName);
Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1579,7 +1579,7 @@
   MCObjectFileInfo MOFI;
   MCContext Ctx(Triple(TripleName), AsmInfo.get(), MRI.get(), &MOFI, STI.get());
   // FIXME: for now initialize MCObjectFileInfo with default values
-  MOFI.InitMCObjectFileInfo(/*PIC=*/false, Ctx);
+  MOFI.initMCObjectFileInfo(Ctx, /*PIC=*/false);
 
   std::unique_ptr DisAsm(
   TheTarget->createMCDisassembler(*STI, Ctx));
Index: llvm/tools/llvm-ml/llvm-ml.cpp
===
--- llvm/tools/llvm-ml/llvm-ml.cpp
+++ llvm/tools/llvm-ml/llvm-ml.cpp
@@ -283,7 +283,7 @@
   // MCObjectFileInfo needs a MCContext reference in order to initialize itself.
   MCObjectFileInfo MOFI;
   MCContext Ctx(TheTriple, MAI.get(), MRI.get(), &MOFI, STI.get(), &SrcMgr);
-  MOFI.InitMCObjectFileInfo(/*PIC=*/false, Ctx,
+  MOFI.initMCObjectFileInfo(Ctx, /*PIC=*/false,
 /*LargeCodeModel=*/true);
 
   if (InputArgs.hasArg(OPT_save_temp_labels))
Index: llvm/tools/llvm-mca/llvm-mca.cpp
===
--- llvm/tools/llvm-mca/llvm-mca.cpp
+++ llvm/tools/llvm-mca/llvm-mca.cpp
@@ -379,7 +379,7 @@
 
   MCContext Ctx(TheTriple, MAI.get(), MRI.get(), &MOFI, STI.get(), &SrcMgr);
 
-  MOFI.InitMCObjectFileInfo(/*PIC=*/false, Ctx);
+  MOFI.initMCObjectFileInfo(Ctx, /*PIC=*/false);
 
   std::unique_ptr BOS;
 
Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm

[PATCH] D101462: [MC] Untangle MCContext and MCObjectFileInfo

2021-05-03 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 updated this revision to Diff 342354.
flip1995 added a comment.

Fix arc mistake...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101462/new/

https://reviews.llvm.org/D101462

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCDisassembler/Disassembler.cpp
  llvm/lib/MC/MCMachOStreamer.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/MC/MCParser/COFFAsmParser.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/MC/MCParser/MasmParser.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/MC/MCWinCOFFStreamer.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
  llvm/lib/Target/TargetLoweringObjectFile.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.cpp
  llvm/tools/llvm-exegesis/lib/LlvmState.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-jitlink/llvm-jitlink.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/Disassembler.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/MachODump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/tools/sancov/sancov.cpp
  llvm/unittests/CodeGen/MachineInstrTest.cpp
  llvm/unittests/CodeGen/MachineOperandTest.cpp
  llvm/unittests/CodeGen/TestAsmPrinter.cpp
  llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
  llvm/unittests/MC/DwarfLineTables.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
  mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp

Index: mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
===
--- mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -169,8 +169,8 @@
   mai->setRelaxELFRelocations(true);
 
   llvm::MCObjectFileInfo mofi;
-  llvm::MCContext ctx(mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
-  mofi.InitMCObjectFileInfo(triple, false, ctx, false);
+  llvm::MCContext ctx(triple, mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
+  mofi.initMCObjectFileInfo(ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
 
   SmallString<128> cwd;
   if (!llvm::sys::fs::current_path(cwd))
Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -57,6 +57,7 @@
   std::unique_ptr MRI;
   std::unique_ptr MUPMAI;
   std::unique_ptr MII;
+  std::unique_ptr MSTI;
   std::unique_ptr Str;
   std::unique_ptr Parser;
   std::unique_ptr Ctx;
@@ -86,6 +87,11 @@
 MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
 EXPECT_NE(MAI, nullptr);
 
+std::unique_ptr MSTI;
+MSTI.reset(TheTarget->createMCSubtargetInfo(TripleName, /*CPU=*/"",
+/*Features=*/""));
+EXPECT_NE(MSTI, nullptr);
+
 // Now we cast to our mocked up version of MCAsmInfo.
 MUPMAI.reset(static_cast(MAI.release()));
 // MUPMAI should "hold" MAI.
@@ -99,9 +105,9 @@
 SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 EXPECT_EQ(Buffer, nullptr);
 
-Ctx.reset(
-new MCContext(MUPMAI.get(), MRI.get(), &MOFI, &SrcMgr, &MCOptions));
-MOFI.InitMCObjectFileInfo(Triple, false, *Ctx, false);
+Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), &MOFI, MSTI.get(),
+&SrcMgr, &MCOptions));
+MOFI.initMCObjectFileInfo(*Ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
 
 Str.reset(TheTarget->createNullStreamer(*Ctx));
 
Index: llvm/unittests/MC/DwarfLineTables.cpp
===
--- llvm/unittests/MC/DwarfLineTables.cpp
+++ llvm/unittests/MC/DwarfLineTables.cpp
@@ -21,7 +21,7 @@
 
 namespace {
 struct Context {
-  const char *Triple = "x86_64-pc-linux";
+  const char *TripleName = "x86_64-pc-linux";
   std::unique_ptr MRI;
   std::unique_ptr MAI;
   std::unique_ptr Ctx;
@@ -33,14 +33,15 @@
 
 // If we didn't build x86, do not run the test.
 std::st

[PATCH] D101462: [MC] Untangle MCContext and MCObjectFileInfo

2021-05-03 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 added a comment.

Not sure how the process from here on out is. I think it is important to note, 
that I don't have push rights and someone else will have to land this for me (I 
guess?).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101462/new/

https://reviews.llvm.org/D101462

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101462: [MC] Untangle MCContext and MCObjectFileInfo

2021-05-03 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 added a comment.

> I'll keep this open for a few days as it touches too many things.

Sounds good 👍

I used `arc diff`. The commits I made with `git` have my name and email 
attached. But it seems like `arc` doesn't use them? I'll figure it out 
tomorrow, can't be that hard, I hope.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101462/new/

https://reviews.llvm.org/D101462

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101462: [MC] Untangle MCContext and MCObjectFileInfo

2021-05-05 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 updated this revision to Diff 343056.
flip1995 added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101462/new/

https://reviews.llvm.org/D101462

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCDisassembler/Disassembler.cpp
  llvm/lib/MC/MCMachOStreamer.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/MC/MCParser/COFFAsmParser.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/MC/MCParser/MasmParser.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/MC/MCWinCOFFStreamer.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
  llvm/lib/Target/TargetLoweringObjectFile.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.cpp
  llvm/tools/llvm-exegesis/lib/LlvmState.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-jitlink/llvm-jitlink.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/Disassembler.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/MachODump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/tools/sancov/sancov.cpp
  llvm/unittests/CodeGen/MachineInstrTest.cpp
  llvm/unittests/CodeGen/MachineOperandTest.cpp
  llvm/unittests/CodeGen/TestAsmPrinter.cpp
  llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
  llvm/unittests/MC/DwarfLineTables.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
  mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp

Index: mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
===
--- mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -169,8 +169,8 @@
   mai->setRelaxELFRelocations(true);
 
   llvm::MCObjectFileInfo mofi;
-  llvm::MCContext ctx(mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
-  mofi.InitMCObjectFileInfo(triple, false, ctx, false);
+  llvm::MCContext ctx(triple, mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
+  mofi.initMCObjectFileInfo(ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
 
   SmallString<128> cwd;
   if (!llvm::sys::fs::current_path(cwd))
Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -112,9 +112,9 @@
 SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 EXPECT_EQ(Buffer, nullptr);
 
-Ctx.reset(
-new MCContext(MUPMAI.get(), MRI.get(), &MOFI, &SrcMgr, &MCOptions));
-MOFI.InitMCObjectFileInfo(Triple, false, *Ctx, false);
+Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), &MOFI, STI.get(),
+&SrcMgr, &MCOptions));
+MOFI.initMCObjectFileInfo(*Ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
 
 Str.reset(TheTarget->createNullStreamer(*Ctx));
 
Index: llvm/unittests/MC/DwarfLineTables.cpp
===
--- llvm/unittests/MC/DwarfLineTables.cpp
+++ llvm/unittests/MC/DwarfLineTables.cpp
@@ -21,7 +21,7 @@
 
 namespace {
 struct Context {
-  const char *Triple = "x86_64-pc-linux";
+  const char *TripleName = "x86_64-pc-linux";
   std::unique_ptr MRI;
   std::unique_ptr MAI;
   std::unique_ptr Ctx;
@@ -33,14 +33,15 @@
 
 // If we didn't build x86, do not run the test.
 std::string Error;
-const Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error);
+const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
 if (!TheTarget)
   return;
 
-MRI.reset(TheTarget->createMCRegInfo(Triple));
+MRI.reset(TheTarget->createMCRegInfo(TripleName));
 MCTargetOptions MCOptions;
-MAI.reset(TheTarget->createMCAsmInfo(*MRI, Triple, MCOptions));
-Ctx = std::make_unique(MAI.get(), MRI.get(), nullptr);
+MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
+Ctx = std::make_unique(Triple(TripleName), MAI.get(), MRI.get(),
+  /*MOFI=*/nul

[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-06 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 created this revision.
Herald added subscribers: dcaballe, cota, teijeong, dexonsmith, rdzhabarov, 
tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, 
lucyrfox, mgester, arpith-jacob, csigg, antiagainst, shauheen, rriddle, 
mehdi_amini, rupprecht, gbedwell, hiraditya.
Herald added a reviewer: andreadb.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
flip1995 updated this revision to Diff 343324.
flip1995 edited the summary of this revision.
flip1995 added a comment.
Herald added subscribers: luismarques, s.egerton, PkmX, simoncook.
flip1995 published this revision for review.
Herald added subscribers: llvm-commits, cfe-commits, stephenneuendorffer, 
nicolasvasilache.
Herald added a reviewer: herhut.
Herald added projects: clang, MLIR, LLVM.

rebased


This MCObjectFileInfo is then used to determine things like section
alignment.

For example, this commit removes the hard-coded 4-byte alignment for
text sections and uses the alignment defined by the target specific
MCObjectFileInfo.

This is a follow up to https://reviews.llvm.org/D101462 and prepares for the
RISCV backend defining the text section alignment depending on the enabled
extensions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101921

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/include/llvm/Support/TargetRegistry.h
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCELFStreamer.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
  mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp

Index: mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
===
--- mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -168,9 +168,11 @@
   target->createMCAsmInfo(*mri, this->triple, mcOptions));
   mai->setRelaxELFRelocations(true);
 
-  llvm::MCObjectFileInfo mofi;
-  llvm::MCContext ctx(triple, mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
-  mofi.initMCObjectFileInfo(ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
+  llvm::MCContext ctx(triple, mai.get(), mri.get(), /*MOFI=*/nullptr, &srcMgr,
+  &mcOptions);
+  std::unique_ptr mofi(target->createMCObjectFileInfo(
+  ctx, /*PIC=*/false, /*LargeCodeModel=*/false));
+  ctx.setObjectFileInfo(mofi.get());
 
   SmallString<128> cwd;
   if (!llvm::sys::fs::current_path(cwd))
Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -62,6 +62,7 @@
   std::unique_ptr MRI;
   std::unique_ptr MUPMAI;
   std::unique_ptr MII;
+  std::unique_ptr MOFI;
   std::unique_ptr Str;
   std::unique_ptr Parser;
   std::unique_ptr Ctx;
@@ -74,7 +75,6 @@
   const Target *TheTarget;
 
   const MCTargetOptions MCOptions;
-  MCObjectFileInfo MOFI;
 
   SystemZAsmLexerTest() {
 // We will use the SystemZ triple, because of missing
@@ -112,9 +112,11 @@
 SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 EXPECT_EQ(Buffer, nullptr);
 
-Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), &MOFI, STI.get(),
-&SrcMgr, &MCOptions));
-MOFI.initMCObjectFileInfo(*Ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
+Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), /*MOFI=*/nullptr,
+STI.get(), &SrcMgr, &MCOptions));
+MOFI.reset(TheTarget->createMCObjectFileInfo(*Ctx, /*PIC=*/false,
+ /*LargeCodeModel=*/false));
+Ctx->setObjectFileInfo(MOFI.get());
 
 Str.reset(TheTarget->createNullStreamer(*Ctx));
 
Index: llvm/tools/llvm-profgen/ProfiledBinary.cpp
===
--- llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -332,9 +332,11 @@
   if (!MII)
 exitWithError("no instruction info for target " + TripleName, FileName);
 
-  MCObjectFileInfo MOFI;
-  MCContext Ctx(Triple(TripleName), AsmInfo.get(), MRI.get(), &MOFI, STI.get());
-  MOFI.initMCObjectFileInfo(Ctx, /*PIC=*/false);
+  MCContext Ctx(Triple(TripleName), AsmInfo.get(), MRI.get(), /*MOFI=*/nullptr,
+STI.get());
+  std::unique_ptr MOFI(
+  TheTarget->createMCObjectFileInfo(Ctx, /*PIC=*/fals

[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-07 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 added a comment.

In D101921#2743735 , @MaskRay wrote:

> Can you post the RISCV patch depending on this one?

Yes, sure. See https://reviews.llvm.org/D102052.




Comment at: llvm/include/llvm/Support/TargetRegistry.h:1029
 
+/// RegisterMCObjectFileInfo - Helper template for registering a target object
+/// file info implementation.  This invokes the static "Create" method on the

MaskRay wrote:
> https://llvm.org/docs/CodingStandards.html#doxygen-use-in-documentation-comments
> "Don’t duplicate function or class name at the beginning of the comment."
> 
> Just ignore existing comments which do not abide by the standard.
> https://llvm.org/docs/CodingStandards.html#doxygen-use-in-documentation-comments
> "Don’t duplicate function or class name at the beginning of the comment."
> 
> Just ignore existing comments which do not abide by the standard.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101921/new/

https://reviews.llvm.org/D101921

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-07 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 added inline comments.



Comment at: llvm/lib/DWARFLinker/DWARFStreamer.cpp:57
 
-  MOFI.reset(new MCObjectFileInfo);
-  MC.reset(
-  new MCContext(TheTriple, MAI.get(), MRI.get(), MOFI.get(), MSTI.get()));
-  MOFI->initMCObjectFileInfo(*MC, /*PIC=*/false);
+  MC.reset(new MCContext(TheTriple, MAI.get(), MRI.get(), /*MOFI=*/nullptr,
+ MSTI.get()));

MaskRay wrote:
> The argument is almost always `/*MOFI=*/nullptr`. Doesn't this regress a bit?
I agree. I think the best thing to do here would be to just remove this 
argument?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101921/new/

https://reviews.llvm.org/D101921

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-07 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 added a comment.

In D101921#2743735 , @MaskRay wrote:

> Can you post the RISCV patch depending on this one?

Yes, sure. See https://reviews.llvm.org/D102052.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101921/new/

https://reviews.llvm.org/D101921

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-07 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 updated this revision to Diff 343605.
flip1995 added a comment.

Remove redundant item names in doc comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101921/new/

https://reviews.llvm.org/D101921

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/include/llvm/Support/TargetRegistry.h
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCELFStreamer.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
  mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp

Index: mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
===
--- mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -168,9 +168,11 @@
   target->createMCAsmInfo(*mri, this->triple, mcOptions));
   mai->setRelaxELFRelocations(true);
 
-  llvm::MCObjectFileInfo mofi;
-  llvm::MCContext ctx(triple, mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
-  mofi.initMCObjectFileInfo(ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
+  llvm::MCContext ctx(triple, mai.get(), mri.get(), /*MOFI=*/nullptr, &srcMgr,
+  &mcOptions);
+  std::unique_ptr mofi(target->createMCObjectFileInfo(
+  ctx, /*PIC=*/false, /*LargeCodeModel=*/false));
+  ctx.setObjectFileInfo(mofi.get());
 
   SmallString<128> cwd;
   if (!llvm::sys::fs::current_path(cwd))
Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -62,6 +62,7 @@
   std::unique_ptr MRI;
   std::unique_ptr MUPMAI;
   std::unique_ptr MII;
+  std::unique_ptr MOFI;
   std::unique_ptr Str;
   std::unique_ptr Parser;
   std::unique_ptr Ctx;
@@ -74,7 +75,6 @@
   const Target *TheTarget;
 
   const MCTargetOptions MCOptions;
-  MCObjectFileInfo MOFI;
 
   SystemZAsmLexerTest() {
 // We will use the SystemZ triple, because of missing
@@ -112,9 +112,11 @@
 SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 EXPECT_EQ(Buffer, nullptr);
 
-Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), &MOFI, STI.get(),
-&SrcMgr, &MCOptions));
-MOFI.initMCObjectFileInfo(*Ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
+Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), /*MOFI=*/nullptr,
+STI.get(), &SrcMgr, &MCOptions));
+MOFI.reset(TheTarget->createMCObjectFileInfo(*Ctx, /*PIC=*/false,
+ /*LargeCodeModel=*/false));
+Ctx->setObjectFileInfo(MOFI.get());
 
 Str.reset(TheTarget->createNullStreamer(*Ctx));
 
Index: llvm/tools/llvm-profgen/ProfiledBinary.cpp
===
--- llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -332,9 +332,11 @@
   if (!MII)
 exitWithError("no instruction info for target " + TripleName, FileName);
 
-  MCObjectFileInfo MOFI;
-  MCContext Ctx(Triple(TripleName), AsmInfo.get(), MRI.get(), &MOFI, STI.get());
-  MOFI.initMCObjectFileInfo(Ctx, /*PIC=*/false);
+  MCContext Ctx(Triple(TripleName), AsmInfo.get(), MRI.get(), /*MOFI=*/nullptr,
+STI.get());
+  std::unique_ptr MOFI(
+  TheTarget->createMCObjectFileInfo(Ctx, /*PIC=*/false));
+  Ctx.setObjectFileInfo(MOFI.get());
   DisAsm.reset(TheTarget->createMCDisassembler(*STI, Ctx));
   if (!DisAsm)
 exitWithError("no disassembler for target " + TripleName, FileName);
Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1576,10 +1576,12 @@
   if (!MII)
 reportError(Obj->getFileName(),
 "no instruction info for target " + TripleName);
-  MCObjectFileInfo MOFI;
-  MCContext Ctx(Triple(TripleName), AsmInfo.get(), MRI.get(), &MOFI, STI.get());
+  MCContext Ctx(Triple(TripleName), AsmInfo.get(), MRI.get(), /*MOFI=*/nullptr,
+STI.get());
   // FIXME: for now initialize MCObjectFileInfo with default values
-  MOFI.initMCObjectFileInfo(Ctx, /*PIC=*/false);
+  std::unique_ptr MOFI(
+  TheTarget->createMCObjectFileInfo(Ctx, /*PIC=*/false));
+  Ctx.setObjectFileInfo(MOFI.get());
 
   std::unique_ptr DisAsm(