Skip to content

Commit 015272c

Browse files
author
git apple-llvm automerger
committed
Merge commit '8e9ffa1dc698' from llvm.org/main into next
2 parents d1cf777 + 8e9ffa1 commit 015272c

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3615,7 +3615,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
36153615
assert(F->getName() == MangledName && "name was uniqued!");
36163616
if (D)
36173617
SetFunctionAttributes(GD, F, IsIncompleteFunction, IsThunk);
3618-
if (ExtraAttrs.hasAttributes(llvm::AttributeList::FunctionIndex)) {
3618+
if (ExtraAttrs.hasFnAttrs()) {
36193619
llvm::AttrBuilder B(ExtraAttrs, llvm::AttributeList::FunctionIndex);
36203620
F->addAttributes(llvm::AttributeList::FunctionIndex, B);
36213621
}

llvm/include/llvm/IR/Attributes.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -657,17 +657,18 @@ class AttributeList {
657657
return hasAttribute(ReturnIndex, Kind);
658658
}
659659

660-
/// Return true if attributes exists for the return value.
660+
/// Return true if attributes exist for the return value.
661661
bool hasRetAttrs() const { return hasAttributes(ReturnIndex); }
662662

663-
/// Equivalent to hasAttribute(AttributeList::FunctionIndex, Kind) but
664-
/// may be faster.
663+
/// Return true if the attribute exists for the function.
665664
bool hasFnAttr(Attribute::AttrKind Kind) const;
666665

667-
/// Equivalent to hasAttribute(AttributeList::FunctionIndex, Kind) but
668-
/// may be faster.
666+
/// Return true if the attribute exists for the function.
669667
bool hasFnAttr(StringRef Kind) const;
670668

669+
/// Return true the attributes exist for the function.
670+
bool hasFnAttrs() const { return hasAttributes(FunctionIndex); }
671+
671672
/// Return true if the specified attribute is set for at least one
672673
/// parameter or for the return value. If Index is not nullptr, the index
673674
/// of a parameter with the specified attribute is provided.

llvm/lib/IR/AsmWriter.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3688,7 +3688,7 @@ void AssemblyWriter::printFunction(const Function *F) {
36883688
Out << "; Materializable\n";
36893689

36903690
const AttributeList &Attrs = F->getAttributes();
3691-
if (Attrs.hasAttributes(AttributeList::FunctionIndex)) {
3691+
if (Attrs.hasFnAttrs()) {
36923692
AttributeSet AS = Attrs.getFnAttrs();
36933693
std::string AttrStr;
36943694

@@ -3726,7 +3726,7 @@ void AssemblyWriter::printFunction(const Function *F) {
37263726
}
37273727

37283728
FunctionType *FT = F->getFunctionType();
3729-
if (Attrs.hasAttributes(AttributeList::ReturnIndex))
3729+
if (Attrs.hasRetAttrs())
37303730
Out << Attrs.getAsString(AttributeList::ReturnIndex) << ' ';
37313731
TypePrinter.print(F->getReturnType(), Out);
37323732
Out << ' ';
@@ -3775,7 +3775,7 @@ void AssemblyWriter::printFunction(const Function *F) {
37753775
if (F->getAddressSpace() != 0 || !Mod ||
37763776
Mod->getDataLayout().getProgramAddressSpace() != 0)
37773777
Out << " addrspace(" << F->getAddressSpace() << ")";
3778-
if (Attrs.hasAttributes(AttributeList::FunctionIndex))
3778+
if (Attrs.hasFnAttrs())
37793779
Out << " #" << Machine.getAttributeGroupSlot(Attrs.getFnAttrs());
37803780
if (F->hasSection()) {
37813781
Out << " section \"";
@@ -4132,7 +4132,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
41324132
Type *RetTy = FTy->getReturnType();
41334133
const AttributeList &PAL = CI->getAttributes();
41344134

4135-
if (PAL.hasAttributes(AttributeList::ReturnIndex))
4135+
if (PAL.hasRetAttrs())
41364136
Out << ' ' << PAL.getAsString(AttributeList::ReturnIndex);
41374137

41384138
// Only print addrspace(N) if necessary:
@@ -4161,7 +4161,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
41614161
Out << ", ...";
41624162

41634163
Out << ')';
4164-
if (PAL.hasAttributes(AttributeList::FunctionIndex))
4164+
if (PAL.hasFnAttrs())
41654165
Out << " #" << Machine.getAttributeGroupSlot(PAL.getFnAttrs());
41664166

41674167
writeOperandBundles(CI);
@@ -4177,7 +4177,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
41774177
PrintCallingConv(II->getCallingConv(), Out);
41784178
}
41794179

4180-
if (PAL.hasAttributes(AttributeList::ReturnIndex))
4180+
if (PAL.hasRetAttrs())
41814181
Out << ' ' << PAL.getAsString(AttributeList::ReturnIndex);
41824182

41834183
// Only print addrspace(N) if necessary:
@@ -4199,7 +4199,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
41994199
}
42004200

42014201
Out << ')';
4202-
if (PAL.hasAttributes(AttributeList::FunctionIndex))
4202+
if (PAL.hasFnAttrs())
42034203
Out << " #" << Machine.getAttributeGroupSlot(PAL.getFnAttrs());
42044204

42054205
writeOperandBundles(II);
@@ -4220,7 +4220,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
42204220
PrintCallingConv(CBI->getCallingConv(), Out);
42214221
}
42224222

4223-
if (PAL.hasAttributes(AttributeList::ReturnIndex))
4223+
if (PAL.hasRetAttrs())
42244224
Out << ' ' << PAL.getAsString(AttributeList::ReturnIndex);
42254225

42264226
// If possible, print out the short form of the callbr instruction. We can
@@ -4239,7 +4239,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
42394239
}
42404240

42414241
Out << ')';
4242-
if (PAL.hasAttributes(AttributeList::FunctionIndex))
4242+
if (PAL.hasFnAttrs())
42434243
Out << " #" << Machine.getAttributeGroupSlot(PAL.getFnAttrs());
42444244

42454245
writeOperandBundles(CBI);

llvm/lib/IR/Verifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1938,7 +1938,7 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
19381938
}
19391939
}
19401940

1941-
if (!Attrs.hasAttributes(AttributeList::FunctionIndex))
1941+
if (!Attrs.hasFnAttrs())
19421942
return;
19431943

19441944
verifyAttributeTypes(Attrs.getFnAttrs(), V);

0 commit comments

Comments
 (0)