mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-28 22:20:37 +00:00
IR: Add MDCompileUnit::replace*()
Add `MDCompileUnit::replaceGlobalVariables()` and `MDCompileUnit::replaceSubprograms()`. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229743 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a9d82a512f
commit
70ee038129
@ -850,6 +850,16 @@ public:
|
|||||||
return getOperandAs<MDString>(3);
|
return getOperandAs<MDString>(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Replace arrays.
|
||||||
|
///
|
||||||
|
/// If this \a isUniqued() and not \a isResolved(), it will be RAUW'ed and
|
||||||
|
/// deleted on a uniquing collision. In practice, uniquing collisions on \a
|
||||||
|
/// MDCompileUnit should be fairly rare.
|
||||||
|
/// @{
|
||||||
|
void replaceSubprograms(MDTuple *N) { replaceOperandWith(6, N); }
|
||||||
|
void replaceGlobalVariables(MDTuple *N) { replaceOperandWith(7, N); }
|
||||||
|
/// @}
|
||||||
|
|
||||||
static bool classof(const Metadata *MD) {
|
static bool classof(const Metadata *MD) {
|
||||||
return MD->getMetadataID() == MDCompileUnitKind;
|
return MD->getMetadataID() == MDCompileUnitKind;
|
||||||
}
|
}
|
||||||
|
@ -1043,6 +1043,38 @@ TEST_F(MDCompileUnitTest, get) {
|
|||||||
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
|
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(MDCompileUnitTest, replaceArrays) {
|
||||||
|
unsigned SourceLanguage = 1;
|
||||||
|
Metadata *File = MDTuple::getDistinct(Context, None);
|
||||||
|
StringRef Producer = "some producer";
|
||||||
|
bool IsOptimized = false;
|
||||||
|
StringRef Flags = "flag after flag";
|
||||||
|
unsigned RuntimeVersion = 2;
|
||||||
|
StringRef SplitDebugFilename = "another/file";
|
||||||
|
unsigned EmissionKind = 3;
|
||||||
|
Metadata *EnumTypes = MDTuple::getDistinct(Context, None);
|
||||||
|
Metadata *RetainedTypes = MDTuple::getDistinct(Context, None);
|
||||||
|
Metadata *ImportedEntities = MDTuple::getDistinct(Context, None);
|
||||||
|
auto *N = MDCompileUnit::get(
|
||||||
|
Context, SourceLanguage, File, Producer, IsOptimized, Flags,
|
||||||
|
RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
|
||||||
|
RetainedTypes, nullptr, nullptr, ImportedEntities);
|
||||||
|
|
||||||
|
auto *Subprograms = MDTuple::getDistinct(Context, None);
|
||||||
|
EXPECT_EQ(nullptr, N->getSubprograms());
|
||||||
|
N->replaceSubprograms(Subprograms);
|
||||||
|
EXPECT_EQ(Subprograms, N->getSubprograms());
|
||||||
|
N->replaceSubprograms(nullptr);
|
||||||
|
EXPECT_EQ(nullptr, N->getSubprograms());
|
||||||
|
|
||||||
|
auto *GlobalVariables = MDTuple::getDistinct(Context, None);
|
||||||
|
EXPECT_EQ(nullptr, N->getGlobalVariables());
|
||||||
|
N->replaceGlobalVariables(GlobalVariables);
|
||||||
|
EXPECT_EQ(GlobalVariables, N->getGlobalVariables());
|
||||||
|
N->replaceGlobalVariables(nullptr);
|
||||||
|
EXPECT_EQ(nullptr, N->getGlobalVariables());
|
||||||
|
}
|
||||||
|
|
||||||
typedef MetadataTest MDSubprogramTest;
|
typedef MetadataTest MDSubprogramTest;
|
||||||
|
|
||||||
TEST_F(MDSubprogramTest, get) {
|
TEST_F(MDSubprogramTest, get) {
|
||||||
|
Loading…
Reference in New Issue
Block a user