[llvm] r301311 - Bring back the ability opt out of padding zero-byte functions by not providing a nop instruction.

Daniel Sanders via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 25 07:27:28 PDT 2017


Author: dsanders
Date: Tue Apr 25 09:27:27 2017
New Revision: 301311

URL: http://llvm.org/viewvc/llvm-project?rev=301311&view=rev
Log:
Bring back the ability opt out of padding zero-byte functions by not providing a nop instruction.

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

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=301311&r1=301310&r2=301311&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Apr 25 09:27:27 2017
@@ -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();




More information about the llvm-commits mailing list