[llvm] [Dwarf] Support `__ptrauth` qualifier (PR #82363)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 20 06:36:37 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 5b342e6041f8567a39354ae3c5346cf74b3bb84f 9b2b8950033cb91593d192942de5adf1ba4cb985 -- llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfo.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/lib/IR/Verifier.cpp llvm/unittests/IR/MetadataTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index 4e279195ff..eec150636f 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -1052,25 +1052,26 @@ private:
bool ShouldCreate = true);
TempDIDerivedType cloneImpl() const {
- return getTemporary(
- getContext(), getTag(), getName(), getFile(), getLine(), getScope(),
- getBaseType(), getSizeInBits(), getAlignInBits(), getOffsetInBits(),
- getDWARFAddressSpace(), getPtrAuthData(), getFlags(), getExtraData(),
- getAnnotations());
+ return getTemporary(getContext(), getTag(), getName(), getFile(), getLine(),
+ getScope(), getBaseType(), getSizeInBits(),
+ getAlignInBits(), getOffsetInBits(),
+ getDWARFAddressSpace(), getPtrAuthData(), getFlags(),
+ getExtraData(), getAnnotations());
}
public:
- DEFINE_MDNODE_GET(
- DIDerivedType,
- (unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
- Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
- uint32_t AlignInBits, uint64_t OffsetInBits,
- std::optional<unsigned> DWARFAddressSpace,
- std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
- Metadata *ExtraData = nullptr, Metadata *Annotations = nullptr),
- (Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits,
- OffsetInBits, DWARFAddressSpace, PtrAuthData, Flags, ExtraData,
- Annotations))
+ DEFINE_MDNODE_GET(DIDerivedType,
+ (unsigned Tag, MDString *Name, Metadata *File,
+ unsigned Line, Metadata *Scope, Metadata *BaseType,
+ uint64_t SizeInBits, uint32_t AlignInBits,
+ uint64_t OffsetInBits,
+ std::optional<unsigned> DWARFAddressSpace,
+ std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
+ Metadata *ExtraData = nullptr,
+ Metadata *Annotations = nullptr),
+ (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
+ AlignInBits, OffsetInBits, DWARFAddressSpace, PtrAuthData,
+ Flags, ExtraData, Annotations))
DEFINE_MDNODE_GET(DIDerivedType,
(unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
@@ -1105,19 +1106,22 @@ public:
std::optional<unsigned> getPtrAuthKey() const {
if (auto PtrAuthData = getPtrAuthData())
return (unsigned)PtrAuthData->Payload.Data.Key;
- else return std::nullopt;
+ else
+ return std::nullopt;
}
/// \returns The PointerAuth address discrimination bit.
std::optional<bool> isPtrAuthAddressDiscriminated() const {
if (auto PtrAuthData = getPtrAuthData())
return (bool)PtrAuthData->Payload.Data.IsAddressDiscriminated;
- else return std::nullopt;
+ else
+ return std::nullopt;
}
/// \returns The PointerAuth extra discriminator.
std::optional<unsigned> getPtrAuthExtraDiscriminator() const {
if (auto PtrAuthData = getPtrAuthData())
return (unsigned)PtrAuthData->Payload.Data.ExtraDiscriminator;
- else return std::nullopt;
+ else
+ return std::nullopt;
}
/// \returns The PointerAuth IsaPointer bit.
std::optional<bool> isPtrAuthIsaPointer() const {
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 787e35fc43..2842cb15e7 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -307,8 +307,8 @@ DIDerivedType *DIBuilder::createPtrAuthQualifiedType(
VMContext, dwarf::DW_TAG_LLVM_ptrauth_type, "", nullptr, 0, nullptr,
FromTy, 0, 0, 0, std::nullopt,
std::optional<DIDerivedType::PtrAuthData>({Key, IsAddressDiscriminated,
- ExtraDiscriminator, IsaPointer,
- AuthenticatesNullValues}),
+ ExtraDiscriminator, IsaPointer,
+ AuthenticatesNullValues}),
DINode::FlagZero);
}
@@ -331,8 +331,8 @@ DIDerivedType *DIBuilder::createMemberPointerType(DIType *PointeeTy,
DINode::DIFlags Flags) {
return DIDerivedType::get(VMContext, dwarf::DW_TAG_ptr_to_member_type, "",
nullptr, 0, nullptr, PointeeTy, SizeInBits,
- AlignInBits, 0, std::nullopt, std::nullopt,
- Flags, Base);
+ AlignInBits, 0, std::nullopt, std::nullopt, Flags,
+ Base);
}
DIDerivedType *
@@ -396,11 +396,10 @@ DIDerivedType *DIBuilder::createVariantMemberType(
DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
Constant *Discriminant, DINode::DIFlags Flags, DIType *Ty) {
- return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
- LineNumber, getNonCompileUnitScope(Scope), Ty,
- SizeInBits, AlignInBits, OffsetInBits, std::nullopt,
- std::nullopt, Flags,
- getConstantOrNull(Discriminant));
+ return DIDerivedType::get(
+ VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
+ getNonCompileUnitScope(Scope), Ty, SizeInBits, AlignInBits, OffsetInBits,
+ std::nullopt, std::nullopt, Flags, getConstantOrNull(Discriminant));
}
DIDerivedType *DIBuilder::createBitFieldMemberType(
@@ -572,11 +571,10 @@ DIDerivedType *DIBuilder::createSetType(DIScope *Scope, StringRef Name,
DIFile *File, unsigned LineNo,
uint64_t SizeInBits,
uint32_t AlignInBits, DIType *Ty) {
- auto *R =
- DIDerivedType::get(VMContext, dwarf::DW_TAG_set_type, Name, File, LineNo,
- getNonCompileUnitScope(Scope), Ty, SizeInBits,
- AlignInBits, 0, std::nullopt, std::nullopt,
- DINode::FlagZero);
+ auto *R = DIDerivedType::get(VMContext, dwarf::DW_TAG_set_type, Name, File,
+ LineNo, getNonCompileUnitScope(Scope), Ty,
+ SizeInBits, AlignInBits, 0, std::nullopt,
+ std::nullopt, DINode::FlagZero);
trackIfUnresolved(R);
return R;
}
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index 38a96e4e30..2b799eea7d 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -731,15 +731,13 @@ Constant *DIDerivedType::getDiscriminantValue() const {
return nullptr;
}
-DIDerivedType *
-DIDerivedType::getImpl(LLVMContext &Context, unsigned Tag, MDString *Name,
- Metadata *File, unsigned Line, Metadata *Scope,
- Metadata *BaseType, uint64_t SizeInBits,
- uint32_t AlignInBits, uint64_t OffsetInBits,
- std::optional<unsigned> DWARFAddressSpace,
- std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
- Metadata *ExtraData, Metadata *Annotations,
- StorageType Storage, bool ShouldCreate) {
+DIDerivedType *DIDerivedType::getImpl(
+ LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
+ unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
+ uint32_t AlignInBits, uint64_t OffsetInBits,
+ std::optional<unsigned> DWARFAddressSpace,
+ std::optional<PtrAuthData> PtrAuthData, DIFlags Flags, Metadata *ExtraData,
+ Metadata *Annotations, StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DIDerivedType,
(Tag, Name, File, Line, Scope, BaseType, SizeInBits,
diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h
index 5d2ae08c35..3a6d48c03a 100644
--- a/llvm/lib/IR/LLVMContextImpl.h
+++ b/llvm/lib/IR/LLVMContextImpl.h
@@ -562,8 +562,7 @@ template <> struct MDNodeKeyImpl<DIDerivedType> {
OffsetInBits(N->getOffsetInBits()), AlignInBits(N->getAlignInBits()),
DWARFAddressSpace(N->getDWARFAddressSpace()),
PtrAuthData(N->getPtrAuthData()), Flags(N->getFlags()),
- ExtraData(N->getRawExtraData()),
- Annotations(N->getRawAnnotations()) {}
+ ExtraData(N->getRawExtraData()), Annotations(N->getRawAnnotations()) {}
bool isKeyOf(const DIDerivedType *RHS) const {
return Tag == RHS->getTag() && Name == RHS->getRawName() &&
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp
index 5d27bec03c..20d4090135 100644
--- a/llvm/unittests/IR/MetadataTest.cpp
+++ b/llvm/unittests/IR/MetadataTest.cpp
@@ -1915,10 +1915,10 @@ TEST_F(DIDerivedTypeTest, get) {
"something", File, 1, getSubprogram(),
BaseType, 2, 3, 4, DWARFAddressSpace,
std::nullopt, Flags5, ExtraData));
- EXPECT_NE(
- N, DIDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something",
- File, 1, Scope, getBasicType("basic2"), 2, 3, 4,
- DWARFAddressSpace, std::nullopt, Flags5, ExtraData));
+ EXPECT_NE(N, DIDerivedType::get(
+ Context, dwarf::DW_TAG_pointer_type, "something", File, 1,
+ Scope, getBasicType("basic2"), 2, 3, 4, DWARFAddressSpace,
+ std::nullopt, Flags5, ExtraData));
EXPECT_NE(N, DIDerivedType::get(Context, dwarf::DW_TAG_pointer_type,
"something", File, 1, Scope, BaseType, 3, 3,
4, DWARFAddressSpace, std::nullopt, Flags5,
@@ -1935,10 +1935,10 @@ TEST_F(DIDerivedTypeTest, get) {
"something", File, 1, Scope, BaseType, 2, 3,
4, DWARFAddressSpace + 1, std::nullopt,
Flags5, ExtraData));
- EXPECT_NE(N1, DIDerivedType::get(Context, dwarf::DW_TAG_LLVM_ptrauth_type,
- "", File, 1, Scope, N, 2, 3, 4,
- DWARFAddressSpace, std::nullopt, Flags5,
- ExtraData));
+ EXPECT_NE(N1,
+ DIDerivedType::get(Context, dwarf::DW_TAG_LLVM_ptrauth_type, "",
+ File, 1, Scope, N, 2, 3, 4, DWARFAddressSpace,
+ std::nullopt, Flags5, ExtraData));
EXPECT_NE(N, DIDerivedType::get(Context, dwarf::DW_TAG_pointer_type,
"something", File, 1, Scope, BaseType, 2, 3,
4, DWARFAddressSpace, std::nullopt, Flags4,
``````````
</details>
https://github.com/llvm/llvm-project/pull/82363
More information about the llvm-commits
mailing list