Reduce the number of attributes attached to each function

This takes advantage of the implicit default behavior to reduce the number of
attributes.
This commit is contained in:
Dávid Bolvanský 2021-02-20 06:57:47 +01:00
parent cd54c57919
commit ee51c42e00
5 changed files with 6 additions and 7 deletions

View 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.

View 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)

View 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"{{.*}} }

View 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"{{.*}} }

View 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);
}