[clang] ee51c42 - Reduce the number of attributes attached to each function

Dávid Bolvanský via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 19 21:58:08 PST 2021


Author: Dávid Bolvanský
Date: 2021-02-20T06:57:47+01:00
New Revision: ee51c42e0060fc98b499312e51a96bc7cf4bcc18

URL: https://github.com/llvm/llvm-project/commit/ee51c42e0060fc98b499312e51a96bc7cf4bcc18
DIFF: https://github.com/llvm/llvm-project/commit/ee51c42e0060fc98b499312e51a96bc7cf4bcc18.diff

LOG: Reduce the number of attributes attached to each function

This takes advantage of the implicit default behavior to reduce the number of
attributes.

Added: 
    

Modified: 
    clang/lib/CodeGen/CGCall.cpp
    clang/lib/CodeGen/CodeGenFunction.cpp
    clang/test/CodeGen/attr-disable-tail-calls.c
    clang/test/CodeGenCXX/attr-disable-tail-calls.cpp
    clang/test/CodeGenCXX/union-tbaa2.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 992e87319943..4ea707621b33 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2116,8 +2116,8 @@ void CodeGenModule::ConstructAttributeList(
 
       return false;
     };
-    FuncAttrs.addAttribute("disable-tail-calls",
-                           llvm::toStringRef(shouldDisableTailCalls()));
+    if (shouldDisableTailCalls())
+      FuncAttrs.addAttribute("disable-tail-calls", "true");
 
     // CPU/feature overrides.  addDefaultFunctionDefinitionAttributes
     // handles these separately to set them based on the global defaults.

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index b393c88f7751..f552b27fee5e 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -859,8 +859,8 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
   }
 
   // Add no-jump-tables value.
-  Fn->addFnAttr("no-jump-tables",
-                llvm::toStringRef(CGM.getCodeGenOpts().NoUseJumpTables));
+  if (CGM.getCodeGenOpts().NoUseJumpTables)
+    Fn->addFnAttr("no-jump-tables", "true");
 
   // Add no-inline-line-tables value.
   if (CGM.getCodeGenOpts().NoInlineLineTables)

diff  --git a/clang/test/CodeGen/attr-disable-tail-calls.c b/clang/test/CodeGen/attr-disable-tail-calls.c
index cd44346037f9..7ae241922813 100644
--- a/clang/test/CodeGen/attr-disable-tail-calls.c
+++ b/clang/test/CodeGen/attr-disable-tail-calls.c
@@ -15,5 +15,5 @@ int f2() __attribute__((disable_tail_calls)) {
 }
 
 // DISABLE: attributes [[ATTRTRUE]] = { {{.*}}"disable-tail-calls"="true"{{.*}} }
-// ENABLE: attributes [[ATTRFALSE]] = { {{.*}}"disable-tail-calls"="false"{{.*}} }
+// ENABLE-NOT: attributes [[ATTRFALSE]] = { {{.*}}"disable-tail-calls"="false"{{.*}} }
 // ENABLE: attributes [[ATTRTRUE]] = { {{.*}}"disable-tail-calls"="true"{{.*}} }

diff  --git a/clang/test/CodeGenCXX/attr-disable-tail-calls.cpp b/clang/test/CodeGenCXX/attr-disable-tail-calls.cpp
index abd1031848df..a7d28f2d0091 100644
--- a/clang/test/CodeGenCXX/attr-disable-tail-calls.cpp
+++ b/clang/test/CodeGenCXX/attr-disable-tail-calls.cpp
@@ -30,6 +30,6 @@ int foo1() {
 // CHECK: define linkonce_odr i32 @_ZN1D2m1Ev(%class.D* {{[^,]*}} %this) unnamed_addr [[ATTRFALSE:#[0-9]+]]
 // CHECK: define linkonce_odr i32 @_ZN1D2m2Ev(%class.D* {{[^,]*}} %this) unnamed_addr [[ATTRTRUE1:#[0-9]+]]
 
-// CHECK: attributes [[ATTRFALSE]] = { {{.*}}"disable-tail-calls"="false"{{.*}} }
+// CHECK-NOT: attributes [[ATTRFALSE]] = { {{.*}}"disable-tail-calls"="false"{{.*}} }
 // CHECK: attributes [[ATTRTRUE0]] = { {{.*}}"disable-tail-calls"="true"{{.*}} }
 // CHECK: attributes [[ATTRTRUE1]] = { {{.*}}"disable-tail-calls"="true"{{.*}} }

diff  --git a/clang/test/CodeGenCXX/union-tbaa2.cpp b/clang/test/CodeGenCXX/union-tbaa2.cpp
index 65872d4a98ae..ba2a8a222a22 100644
--- a/clang/test/CodeGenCXX/union-tbaa2.cpp
+++ b/clang/test/CodeGenCXX/union-tbaa2.cpp
@@ -20,7 +20,6 @@ struct A {
 // CHECK: tbaa ![[OCPATH:[0-9]+]]
 // CHECK: store <4 x double>
 // CHECK: tbaa ![[OCPATH]]
-// CHECK: call
     a = _mm256_setr_pd(0.0, 1.0, 2.0, 3.0);
     b = _mm256_setr_pd(4.0, 5.0, 6.0, 7.0);
   }


        


More information about the cfe-commits mailing list