[PATCH] D40979: [DWARF] Allow duplication of tails with CFI instructions

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 11:17:19 PST 2017


MatzeB added a comment.

I haven't worked much with CFI instruction before, but seeing this it appears the only reason they are marked as NotDuplicable is because they use this strange system of referencing the FrameInstructions side table in the MachineFunction instead of encoding the information with normal machine operand.

But if that is really all there is to it then I would rather see us implement this logic in the MachineInstr::MachineInstr(MachineFunction &MF, const MachineInstr &MI) constructor, set isNotDuplicable=0 for CFI_INSTRUCTION and happily use MachineFunction::CloneMachineInstruction() so we don't need a special case anymore.



================
Comment at: lib/CodeGen/TailDuplicator.cpp:370-372
+static void duplicateCFIInstruction(
+    MachineInstr *MI, MachineBasicBlock *TailBB, MachineBasicBlock *PredBB,
+    const TargetInstrInfo* TII) {
----------------
Use references instead of pointers for things that mustn't be nullptr.


================
Comment at: lib/CodeGen/TailDuplicator.cpp:379-411
+  switch (CFI.getOperation()) {
+  default: {
+    llvm_unreachable("Duplicating unsupported CFI instruction.");
+    return;
+  }
+  case MCCFIInstruction::OpDefCfaRegister: {
+    NewCFIIndex = MF->addFrameInst(
----------------
Why not implement a copy constructor for MCCFIInstruction instead?


Repository:
  rL LLVM

https://reviews.llvm.org/D40979





More information about the llvm-commits mailing list