Skip to content

Commit 8acda5b

Browse files
committed
Rename attribute to flatten_depth and MaxDepth to DepthHint
1 parent d7facaf commit 8acda5b

File tree

17 files changed

+61
-60
lines changed

17 files changed

+61
-60
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,11 +1976,11 @@ def Flatten : InheritableAttr {
19761976
let SimpleHandler = 1;
19771977
}
19781978

1979-
def FlattenDeep : InheritableAttr {
1980-
let Spellings = [Clang<"flatten_deep">];
1979+
def FlattenDepth : InheritableAttr {
1980+
let Spellings = [Clang<"flatten_depth">];
19811981
let Subjects = SubjectList<[Function], ErrorDiag>;
1982-
let Args = [UnsignedArgument<"MaxDepth">];
1983-
let Documentation = [FlattenDeepDocs];
1982+
let Args = [UnsignedArgument<"DepthHint">];
1983+
let Documentation = [FlattenDepthDocs];
19841984
}
19851985

19861986
def Format : InheritableAttr {

clang/include/clang/Basic/AttrDocs.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4032,23 +4032,23 @@ callee is unavailable or if the callee has the ``noinline`` attribute.
40324032
}];
40334033
}
40344034

4035-
def FlattenDeepDocs : Documentation {
4035+
def FlattenDepthDocs : Documentation {
40364036
let Category = DocCatFunction;
40374037
let Content = [{
4038-
The ``flatten_deep`` attribute causes calls within the attributed function and
4038+
The ``flatten_depth`` attribute causes calls within the attributed function and
40394039
their transitive callees to be inlined up to a specified depth, unless it is
40404040
impossible to do so (for example if the body of the callee is unavailable or if
40414041
the callee has the ``noinline`` attribute).
40424042

40434043
This attribute takes a single unsigned integer argument representing the maximum
4044-
depth of the call tree to inline. For example, ``__attribute__((flatten_deep(3)))``
4044+
depth of the call tree to inline. For example, ``__attribute__((flatten_depth(3)))``
40454045
will inline all calls within the function, then inline all calls within those
40464046
inlined functions (depth 2), and then inline all calls within those functions
40474047
(depth 3).
40484048

40494049
.. code-block:: c++
40504050

4051-
__attribute__((flatten_deep(3)))
4051+
__attribute__((flatten_depth(3)))
40524052
void process_data() {
40534053
// All calls up to 3 levels deep in the call tree will be inlined
40544054
}

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,12 +2751,12 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
27512751
B.addAttribute("aarch64_new_zt0");
27522752
}
27532753

2754-
// Handle flatten_deep attribute for depth-based inlining
2754+
// Handle flatten_depth attribute for depth-based inlining
27552755
if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
2756-
if (const FlattenDeepAttr *FDA = FD->getAttr<FlattenDeepAttr>()) {
2757-
// Add the flatten_deep attribute with the max depth value as a typed int
2756+
if (const FlattenDepthAttr *FDA = FD->getAttr<FlattenDepthAttr>()) {
2757+
// Add the flatten_depth attribute with the max depth value as a typed int
27582758
// attribute
2759-
B.addRawIntAttr(llvm::Attribute::FlattenDeep, FDA->getMaxDepth());
2759+
B.addRawIntAttr(llvm::Attribute::FlattenDepth, FDA->getDepthHint());
27602760
}
27612761
}
27622762

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3695,22 +3695,22 @@ static void handleInitPriorityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
36953695
D->addAttr(::new (S.Context) InitPriorityAttr(S.Context, AL, prioritynum));
36963696
}
36973697

3698-
static void handleFlattenDeepAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3698+
static void handleFlattenDepthAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
36993699
Expr *E = AL.getArgAsExpr(0);
3700-
uint32_t maxDepth;
3701-
if (!S.checkUInt32Argument(AL, E, maxDepth)) {
3700+
uint32_t depthHint;
3701+
if (!S.checkUInt32Argument(AL, E, depthHint)) {
37023702
AL.setInvalid();
37033703
return;
37043704
}
37053705

3706-
if (maxDepth == 0) {
3706+
if (depthHint == 0) {
37073707
S.Diag(AL.getLoc(), diag::err_attribute_argument_is_zero)
37083708
<< AL << E->getSourceRange();
37093709
AL.setInvalid();
37103710
return;
37113711
}
37123712

3713-
D->addAttr(::new (S.Context) FlattenDeepAttr(S.Context, AL, maxDepth));
3713+
D->addAttr(::new (S.Context) FlattenDepthAttr(S.Context, AL, depthHint));
37143714
}
37153715

37163716
ErrorAttr *Sema::mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,
@@ -7254,8 +7254,8 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
72547254
case ParsedAttr::AT_Format:
72557255
handleFormatAttr(S, D, AL);
72567256
break;
7257-
case ParsedAttr::AT_FlattenDeep:
7258-
handleFlattenDeepAttr(S, D, AL);
7257+
case ParsedAttr::AT_FlattenDepth:
7258+
handleFlattenDepthAttr(S, D, AL);
72597259
break;
72607260
case ParsedAttr::AT_FormatMatches:
72617261
handleFormatMatchesAttr(S, D, AL);

clang/test/CodeGen/attr-flatten-deep-cg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
// CHECK-LABEL: define {{.*}} @test1
44
// CHECK-SAME: #[[ATTR1:[0-9]+]]
5-
__attribute__((flatten_deep(3)))
5+
__attribute__((flatten_depth(3)))
66
void test1() {
77
}
88

99
// Verify the attribute is present in the attribute groups
10-
// CHECK-DAG: attributes #[[ATTR1]] = { {{.*}}flatten_deep=3{{.*}} }
10+
// CHECK-DAG: attributes #[[ATTR1]] = { {{.*}}flatten_depth=3{{.*}} }

clang/test/Misc/pragma-attribute-supported-attributes-list.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
// CHECK-NEXT: ExternalSourceSymbol ((SubjectMatchRule_record, SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, SubjectMatchRule_function, SubjectMatchRule_namespace, SubjectMatchRule_objc_category, SubjectMatchRule_objc_implementation, SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, SubjectMatchRule_record, SubjectMatchRule_type_alias, SubjectMatchRule_variable))
8787
// CHECK-NEXT: FlagEnum (SubjectMatchRule_enum)
8888
// CHECK-NEXT: Flatten (SubjectMatchRule_function)
89-
// CHECK-NEXT: FlattenDeep (SubjectMatchRule_function)
89+
// CHECK-NEXT: FlattenDepth (SubjectMatchRule_function)
9090
// CHECK-NEXT: FunctionReturnThunks (SubjectMatchRule_function)
9191
// CHECK-NEXT: GNUInline (SubjectMatchRule_function)
9292
// CHECK-NEXT: HIPManaged (SubjectMatchRule_variable)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// RUN: %clang_cc1 -fsyntax-only -verify %s
22

33
// Test basic usage - valid
4-
__attribute__((flatten_deep(3)))
4+
__attribute__((flatten_depth(3)))
55
void test_valid() {
66
}
77

88
// Test attribute on non-function - should error
9-
__attribute__((flatten_deep(3))) int x; // expected-error {{'flatten_deep' attribute only applies to functions}}
9+
__attribute__((flatten_depth(3))) int x; // expected-error {{'flatten_depth' attribute only applies to functions}}
1010

1111
// Test depth = 0 - should error (depth must be >= 1)
12-
__attribute__((flatten_deep(0))) // expected-error {{'flatten_deep' attribute must be greater than 0}}
12+
__attribute__((flatten_depth(0))) // expected-error {{'flatten_depth' attribute must be greater than 0}}
1313
void test_depth_zero() {
1414
}

llvm/include/llvm/AsmParser/LLParser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ namespace llvm {
320320
bool AllowParens = false);
321321
bool parseOptionalCodeModel(CodeModel::Model &model);
322322
bool parseOptionalDerefAttrBytes(lltok::Kind AttrKind, uint64_t &Bytes);
323-
bool parseOptionalFlattenDeepDepth(lltok::Kind AttrKind, uint64_t &Depth);
323+
bool parseOptionalFlattenDepthDepthHint(lltok::Kind AttrKind,
324+
uint64_t &Depth);
324325
bool parseOptionalUWTableKind(UWTableKind &Kind);
325326
bool parseAllocKind(AllocFnKind &Kind);
326327
std::optional<MemoryEffects> parseMemoryAttr();

llvm/include/llvm/Bitcode/LLVMBitCodes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ enum AttributeKindCodes {
802802
ATTR_KIND_DEAD_ON_RETURN = 103,
803803
ATTR_KIND_SANITIZE_ALLOC_TOKEN = 104,
804804
ATTR_KIND_NO_CREATE_UNDEF_OR_POISON = 105,
805-
ATTR_KIND_FLATTEN_DEEP = 106,
805+
ATTR_KIND_FLATTEN_DEPTH = 106,
806806
};
807807

808808
enum ComdatSelectionKindCodes {

llvm/include/llvm/IR/Attributes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,9 +1246,9 @@ class AttrBuilder {
12461246
/// form used internally in Attribute.
12471247
LLVM_ABI AttrBuilder &addDereferenceableOrNullAttr(uint64_t Bytes);
12481248

1249-
/// This turns the flatten_deep depth into the form used internally in
1249+
/// This turns the flatten_depth depth into the form used internally in
12501250
/// Attribute.
1251-
LLVM_ABI AttrBuilder &addFlattenDeepAttr(uint64_t Depth);
1251+
LLVM_ABI AttrBuilder &addFlattenDepthAttr(uint64_t Depth);
12521252

12531253
/// This turns one (or two) ints into the form used internally in Attribute.
12541254
LLVM_ABI AttrBuilder &

0 commit comments

Comments
 (0)