Bring back the ability opt out of padding zero-byte functions by not providing a...
authorDaniel Sanders <daniel_l_sanders@apple.com>
Tue, 25 Apr 2017 14:27:27 +0000 (14:27 +0000)
committerDaniel Sanders <daniel_l_sanders@apple.com>
Tue, 25 Apr 2017 14:27:27 +0000 (14:27 +0000)
Summary: No test case since I'm not aware of an in-tree target that needs this.

Reviewers: hans

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D32398

llvm-svn: 301311

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

index a7e1d56..a8f45db 100644 (file)
@@ -1068,8 +1068,13 @@ void AsmPrinter::EmitFunctionBody() {
                           (TT.isOSWindows() && TT.isOSBinFormatCOFF()))) {
     MCInst Noop;
     MF->getSubtarget().getInstrInfo()->getNoop(Noop);
-    OutStreamer->AddComment("avoids zero-length function");
-    OutStreamer->EmitInstruction(Noop, getSubtargetInfo());
+
+    // Targets can opt-out of emitting the noop here by leaving the opcode
+    // unspecified.
+    if (Noop.getOpcode()) {
+      OutStreamer->AddComment("avoids zero-length function");
+      OutStreamer->EmitInstruction(Noop, getSubtargetInfo());
+    }
   }
 
   const Function *F = MF->getFunction();