Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 4a6fc8b

Browse files
committed
Kill deprecated attribute API
Summary: This kill various depreacated API related to attribute : - The deprecated C API attribute based on LLVMAttribute enum. - The Raw attribute set format (planned to be removed in 4.0). Reviewers: bkramer, echristo, mehdi_amini, void Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D23039 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286062 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c7524ad commit 4a6fc8b

File tree

7 files changed

+100
-302
lines changed

7 files changed

+100
-302
lines changed

docs/ReleaseNotes.rst

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ page <http://llvm.org/releases/>`_.
3333

3434
Non-comprehensive list of changes in this release
3535
=================================================
36+
* The C API functions LLVMAddFunctionAttr, LLVMGetFunctionAttr,
37+
LLVMRemoveFunctionAttr, LLVMAddAttribute, LLVMRemoveAttribute,
38+
LLVMGetAttribute, LLVMAddInstrAttribute and
39+
LLVMRemoveInstrAttribute have been removed.
40+
41+
* The C API enum LLVMAttribute has been deleted.
3642

3743
.. NOTE
3844
For small 1-3 sentence descriptions, just add an entry at the end of

include/llvm-c/Core.h

-81
Original file line numberDiff line numberDiff line change
@@ -54,51 +54,6 @@ extern "C" {
5454
* @{
5555
*/
5656

57-
typedef enum {
58-
LLVMZExtAttribute = 1<<0,
59-
LLVMSExtAttribute = 1<<1,
60-
LLVMNoReturnAttribute = 1<<2,
61-
LLVMInRegAttribute = 1<<3,
62-
LLVMStructRetAttribute = 1<<4,
63-
LLVMNoUnwindAttribute = 1<<5,
64-
LLVMNoAliasAttribute = 1<<6,
65-
LLVMByValAttribute = 1<<7,
66-
LLVMNestAttribute = 1<<8,
67-
LLVMReadNoneAttribute = 1<<9,
68-
LLVMReadOnlyAttribute = 1<<10,
69-
LLVMNoInlineAttribute = 1<<11,
70-
LLVMAlwaysInlineAttribute = 1<<12,
71-
LLVMOptimizeForSizeAttribute = 1<<13,
72-
LLVMStackProtectAttribute = 1<<14,
73-
LLVMStackProtectReqAttribute = 1<<15,
74-
LLVMAlignment = 31<<16,
75-
LLVMNoCaptureAttribute = 1<<21,
76-
LLVMNoRedZoneAttribute = 1<<22,
77-
LLVMNoImplicitFloatAttribute = 1<<23,
78-
LLVMNakedAttribute = 1<<24,
79-
LLVMInlineHintAttribute = 1<<25,
80-
LLVMStackAlignment = 7<<26,
81-
LLVMReturnsTwice = 1 << 29,
82-
LLVMUWTable = 1 << 30,
83-
LLVMNonLazyBind = 1 << 31
84-
85-
/* FIXME: These attributes are currently not included in the C API as
86-
a temporary measure until the API/ABI impact to the C API is understood
87-
and the path forward agreed upon.
88-
LLVMSanitizeAddressAttribute = 1ULL << 32,
89-
LLVMStackProtectStrongAttribute = 1ULL<<35,
90-
LLVMColdAttribute = 1ULL << 40,
91-
LLVMOptimizeNoneAttribute = 1ULL << 42,
92-
LLVMInAllocaAttribute = 1ULL << 43,
93-
LLVMNonNullAttribute = 1ULL << 44,
94-
LLVMJumpTableAttribute = 1ULL << 45,
95-
LLVMConvergentAttribute = 1ULL << 46,
96-
LLVMSafeStackAttribute = 1ULL << 47,
97-
LLVMSwiftSelfAttribute = 1ULL << 48,
98-
LLVMSwiftErrorAttribute = 1ULL << 49,
99-
*/
100-
} LLVMAttribute;
101-
10257
typedef enum {
10358
/* Terminator Instructions */
10459
LLVMRet = 1,
@@ -2011,8 +1966,6 @@ void LLVMSetGC(LLVMValueRef Fn, const char *Name);
20111966
*
20121967
* @see llvm::Function::addAttribute()
20131968
*/
2014-
void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
2015-
20161969
void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
20171970
LLVMAttributeRef A);
20181971
unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx);
@@ -2036,18 +1989,6 @@ void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
20361989
void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
20371990
const char *V);
20381991

2039-
/**
2040-
* Obtain an attribute from a function.
2041-
*
2042-
* @see llvm::Function::getAttributes()
2043-
*/
2044-
LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
2045-
2046-
/**
2047-
* Remove an attribute from a function.
2048-
*/
2049-
void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
2050-
20511992
/**
20521993
* @defgroup LLVMCCoreValueFunctionParameters Function Parameters
20531994
*
@@ -2129,25 +2070,6 @@ LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
21292070
*/
21302071
LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
21312072

2132-
/**
2133-
* Add an attribute to a function argument.
2134-
*
2135-
* @see llvm::Argument::addAttr()
2136-
*/
2137-
void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
2138-
2139-
/**
2140-
* Remove an attribute from a function argument.
2141-
*
2142-
* @see llvm::Argument::removeAttr()
2143-
*/
2144-
void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
2145-
2146-
/**
2147-
* Get an attribute from a function argument.
2148-
*/
2149-
LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
2150-
21512073
/**
21522074
* Set the alignment for a function parameter.
21532075
*
@@ -2596,9 +2518,6 @@ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
25962518
*/
25972519
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
25982520

2599-
void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
2600-
void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
2601-
LLVMAttribute);
26022521
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
26032522
unsigned Align);
26042523

include/llvm/IR/Attributes.h

-13
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,6 @@ class AttributeSet {
391391
// AttributeSet Introspection
392392
//===--------------------------------------------------------------------===//
393393

394-
// FIXME: Remove this.
395-
uint64_t Raw(unsigned Index) const;
396-
397394
/// \brief Return a raw pointer that uniquely identifies this attribute list.
398395
void *getRawPointer() const {
399396
return pImpl;
@@ -458,11 +455,6 @@ class AttrBuilder {
458455
AttrBuilder()
459456
: Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
460457
DerefOrNullBytes(0), AllocSizeArgs(0) {}
461-
explicit AttrBuilder(uint64_t Val)
462-
: Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
463-
DerefOrNullBytes(0), AllocSizeArgs(0) {
464-
addRawValue(Val);
465-
}
466458
AttrBuilder(const Attribute &A)
467459
: Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
468460
DerefOrNullBytes(0), AllocSizeArgs(0) {
@@ -590,11 +582,6 @@ class AttrBuilder {
590582
bool operator!=(const AttrBuilder &B) {
591583
return !(*this == B);
592584
}
593-
594-
// FIXME: Remove this in 4.0.
595-
596-
/// \brief Add the raw value to the internal representation.
597-
AttrBuilder &addRawValue(uint64_t Val);
598585
};
599586

600587
namespace AttributeFuncs {

lib/Bitcode/Reader/BitcodeReader.cpp

+94-2
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,98 @@ StructType *BitcodeReader::createIdentifiedStructType(LLVMContext &Context) {
13551355
// Functions for parsing blocks from the bitcode file
13561356
//===----------------------------------------------------------------------===//
13571357

1358+
static uint64_t getRawAttributeMask(Attribute::AttrKind Val) {
1359+
switch (Val) {
1360+
case Attribute::EndAttrKinds:
1361+
llvm_unreachable("Synthetic enumerators which should never get here");
1362+
1363+
case Attribute::None: return 0;
1364+
case Attribute::ZExt: return 1 << 0;
1365+
case Attribute::SExt: return 1 << 1;
1366+
case Attribute::NoReturn: return 1 << 2;
1367+
case Attribute::InReg: return 1 << 3;
1368+
case Attribute::StructRet: return 1 << 4;
1369+
case Attribute::NoUnwind: return 1 << 5;
1370+
case Attribute::NoAlias: return 1 << 6;
1371+
case Attribute::ByVal: return 1 << 7;
1372+
case Attribute::Nest: return 1 << 8;
1373+
case Attribute::ReadNone: return 1 << 9;
1374+
case Attribute::ReadOnly: return 1 << 10;
1375+
case Attribute::NoInline: return 1 << 11;
1376+
case Attribute::AlwaysInline: return 1 << 12;
1377+
case Attribute::OptimizeForSize: return 1 << 13;
1378+
case Attribute::StackProtect: return 1 << 14;
1379+
case Attribute::StackProtectReq: return 1 << 15;
1380+
case Attribute::Alignment: return 31 << 16;
1381+
case Attribute::NoCapture: return 1 << 21;
1382+
case Attribute::NoRedZone: return 1 << 22;
1383+
case Attribute::NoImplicitFloat: return 1 << 23;
1384+
case Attribute::Naked: return 1 << 24;
1385+
case Attribute::InlineHint: return 1 << 25;
1386+
case Attribute::StackAlignment: return 7 << 26;
1387+
case Attribute::ReturnsTwice: return 1 << 29;
1388+
case Attribute::UWTable: return 1 << 30;
1389+
case Attribute::NonLazyBind: return 1U << 31;
1390+
case Attribute::SanitizeAddress: return 1ULL << 32;
1391+
case Attribute::MinSize: return 1ULL << 33;
1392+
case Attribute::NoDuplicate: return 1ULL << 34;
1393+
case Attribute::StackProtectStrong: return 1ULL << 35;
1394+
case Attribute::SanitizeThread: return 1ULL << 36;
1395+
case Attribute::SanitizeMemory: return 1ULL << 37;
1396+
case Attribute::NoBuiltin: return 1ULL << 38;
1397+
case Attribute::Returned: return 1ULL << 39;
1398+
case Attribute::Cold: return 1ULL << 40;
1399+
case Attribute::Builtin: return 1ULL << 41;
1400+
case Attribute::OptimizeNone: return 1ULL << 42;
1401+
case Attribute::InAlloca: return 1ULL << 43;
1402+
case Attribute::NonNull: return 1ULL << 44;
1403+
case Attribute::JumpTable: return 1ULL << 45;
1404+
case Attribute::Convergent: return 1ULL << 46;
1405+
case Attribute::SafeStack: return 1ULL << 47;
1406+
case Attribute::NoRecurse: return 1ULL << 48;
1407+
case Attribute::InaccessibleMemOnly: return 1ULL << 49;
1408+
case Attribute::InaccessibleMemOrArgMemOnly: return 1ULL << 50;
1409+
case Attribute::SwiftSelf: return 1ULL << 51;
1410+
case Attribute::SwiftError: return 1ULL << 52;
1411+
case Attribute::WriteOnly: return 1ULL << 53;
1412+
case Attribute::Dereferenceable:
1413+
llvm_unreachable("dereferenceable attribute not supported in raw format");
1414+
break;
1415+
case Attribute::DereferenceableOrNull:
1416+
llvm_unreachable("dereferenceable_or_null attribute not supported in raw "
1417+
"format");
1418+
break;
1419+
case Attribute::ArgMemOnly:
1420+
llvm_unreachable("argmemonly attribute not supported in raw format");
1421+
break;
1422+
case Attribute::AllocSize:
1423+
llvm_unreachable("allocsize not supported in raw format");
1424+
break;
1425+
}
1426+
llvm_unreachable("Unsupported attribute type");
1427+
}
1428+
1429+
static void addRawAttributeValue(AttrBuilder &B, uint64_t Val) {
1430+
if (!Val) return;
1431+
1432+
for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
1433+
I = Attribute::AttrKind(I + 1)) {
1434+
if (I == Attribute::Dereferenceable ||
1435+
I == Attribute::DereferenceableOrNull ||
1436+
I == Attribute::ArgMemOnly ||
1437+
I == Attribute::AllocSize)
1438+
continue;
1439+
if (uint64_t A = (Val & getRawAttributeMask(I))) {
1440+
if (I == Attribute::Alignment)
1441+
B.addAlignmentAttr(1ULL << ((A >> 16) - 1));
1442+
else if (I == Attribute::StackAlignment)
1443+
B.addStackAlignmentAttr(1ULL << ((A >> 26)-1));
1444+
else
1445+
B.addAttribute(I);
1446+
}
1447+
}
1448+
}
1449+
13581450
/// \brief This fills an AttrBuilder object with the LLVM attributes that have
13591451
/// been decoded from the given integer. This function must stay in sync with
13601452
/// 'encodeLLVMAttributesForBitcode'.
@@ -1370,8 +1462,8 @@ static void decodeLLVMAttributesForBitcode(AttrBuilder &B,
13701462

13711463
if (Alignment)
13721464
B.addAlignmentAttr(Alignment);
1373-
B.addRawValue(((EncodedAttrs & (0xfffffULL << 32)) >> 11) |
1374-
(EncodedAttrs & 0xffff));
1465+
addRawAttributeValue(B, ((EncodedAttrs & (0xfffffULL << 32)) >> 11) |
1466+
(EncodedAttrs & 0xffff));
13751467
}
13761468

13771469
std::error_code BitcodeReader::parseAttributeBlock() {

lib/IR/AttributeImpl.h

-6
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ class AttributeImpl : public FoldingSetNode {
8585
ID.AddString(Kind);
8686
if (!Values.empty()) ID.AddString(Values);
8787
}
88-
89-
// FIXME: Remove this!
90-
static uint64_t getAttrMask(Attribute::AttrKind Val);
9188
};
9289

9390
//===----------------------------------------------------------------------===//
@@ -258,9 +255,6 @@ class AttributeSetImpl final
258255
}
259256
}
260257

261-
// FIXME: This atrocity is temporary.
262-
uint64_t Raw(unsigned Index) const;
263-
264258
void dump() const;
265259
};
266260

0 commit comments

Comments
 (0)