[PATCH] D71669: [Clang FE, SystemZ] Don't add "true" value for the "mnop-mcount" attribute.

Jonas Paulsson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 18 10:38:20 PST 2019


jonpa created this revision.
jonpa added a reviewer: uweigand.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Let the "mnop-mcount" function attribute simply be present or non-present.

Update SystemZ backend as well to use hasFnAttribute() instead.


https://reviews.llvm.org/D71669

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/mnop-mcount.c
  llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
  llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
  llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll
  llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll


Index: llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll
===================================================================
--- llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll
+++ llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll
@@ -7,5 +7,4 @@
   ret void
 }
 
-attributes #0 = { "instrument-function-entry-inlined"="mcount" "mnop-mcount"="true" }
-
+attributes #0 = { "instrument-function-entry-inlined"="mcount" "mnop-mcount" }
Index: llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll
===================================================================
--- llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll
+++ llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll
@@ -22,5 +22,5 @@
 }
 
 attributes #0 = { "fentry-call"="true" }
-attributes #1 = { "fentry-call"="true" "mnop-mcount"="true" }
+attributes #1 = { "fentry-call"="true" "mnop-mcount" }
 
Index: llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
===================================================================
--- llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
+++ llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
@@ -347,7 +347,7 @@
 
   bool runOnMachineFunction(MachineFunction &MF) override {
     const Function &F = MF.getFunction();
-    if (F.getFnAttribute("mnop-mcount").getValueAsString() == "true" &&
+    if (F.hasFnAttribute("mnop-mcount") &&
         F.getFnAttribute("fentry-call").getValueAsString() != "true")
       report_fatal_error("mnop-mcount only supported with fentry-call");
 
Index: llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
+++ llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
@@ -553,8 +553,7 @@
 void SystemZAsmPrinter::LowerFENTRY_CALL(const MachineInstr &MI,
                                          SystemZMCInstLower &Lower) {
   MCContext &Ctx = MF->getContext();
-  if (MF->getFunction().getFnAttribute("mnop-mcount")
-                       .getValueAsString() == "true") {
+  if (MF->getFunction().hasFnAttribute("mnop-mcount")) {
     EmitNop(Ctx, *OutStreamer, 6, getSubtargetInfo());
     return;
   }
Index: clang/test/CodeGen/mnop-mcount.c
===================================================================
--- clang/test/CodeGen/mnop-mcount.c
+++ clang/test/CodeGen/mnop-mcount.c
@@ -17,9 +17,9 @@
   return foo();
 }
 
-//CHECK: attributes #0 = { {{.*}}"mnop-mcount"="true"{{.*}} }
+//CHECK: attributes #0 = { {{.*}}"mnop-mcount"{{.*}} }
 //CHECK: attributes #1 = { {{.*}} }
-//CHECK-NOT: attributes #1 = { {{.*}}"mnop-mcount"="true"{{.*}} }
+//CHECK-NOT: attributes #1 = { {{.*}}"mnop-mcount"{{.*}} }
 //NOMFENTRY: error: option '-mnop-mcount' cannot be specified without '-mfentry'
 //NOPG-NOT: attributes #0 = { {{.*}}"mnop-mcount"{{.*}} }
 //NOPG-NOT: attributes #1 = { {{.*}}"mnop-mcount"{{.*}} }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -966,7 +966,7 @@
         if (!CGM.getCodeGenOpts().CallFEntry)
           CGM.getDiags().Report(diag::err_opt_not_valid_without_opt)
             << "-mnop-mcount" << "-mfentry";
-        Fn->addFnAttr("mnop-mcount", "true");
+        Fn->addFnAttr("mnop-mcount");
       }
     }
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71669.234576.patch
Type: text/x-patch
Size: 3287 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191218/21952fec/attachment-0001.bin>


More information about the cfe-commits mailing list