Reduce the number of attributes attached to each function
authorDávid Bolvanský <david.bolvansky@gmail.com>
Sat, 20 Feb 2021 05:57:47 +0000 (06:57 +0100)
committerDávid Bolvanský <david.bolvansky@gmail.com>
Sat, 20 Feb 2021 05:57:47 +0000 (06:57 +0100)
This takes advantage of the implicit default behavior to reduce the number of
attributes.

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

index 992e873..4ea7076 100644 (file)
@@ -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.
index b393c88..f552b27 100644 (file)
@@ -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)
index cd44346..7ae2419 100644 (file)
@@ -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"{{.*}} }
index abd1031..a7d28f2 100644 (file)
@@ -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"{{.*}} }
index 65872d4..ba2a8a2 100644 (file)
@@ -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);
   }