Skip to content

Commit ab89fdc

Browse files
committed
Move check of module flags to verifier
1 parent 6a0bec4 commit ab89fdc

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

llvm/lib/IR/Verifier.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1734,8 +1734,29 @@ void Verifier::visitModuleFlags() {
17341734
// Scan each flag, and track the flags and requirements.
17351735
DenseMap<const MDString*, const MDNode*> SeenIDs;
17361736
SmallVector<const MDNode*, 16> Requirements;
1737-
for (const MDNode *MDN : Flags->operands())
1737+
uint64_t PAuthABIPlatform = -1;
1738+
uint64_t PAuthABIVersion = -1;
1739+
for (const MDNode *MDN : Flags->operands()) {
17381740
visitModuleFlag(MDN, SeenIDs, Requirements);
1741+
if (MDN->getNumOperands() != 3)
1742+
continue;
1743+
if (const auto *FlagName = dyn_cast_or_null<MDString>(MDN->getOperand(1))) {
1744+
if (FlagName->getString() == "aarch64-elf-pauthabi-platform") {
1745+
if (const auto *PAP =
1746+
mdconst::dyn_extract_or_null<ConstantInt>(MDN->getOperand(2)))
1747+
PAuthABIPlatform = PAP->getZExtValue();
1748+
} else if (FlagName->getString() == "aarch64-elf-pauthabi-version") {
1749+
if (const auto *PAV =
1750+
mdconst::dyn_extract_or_null<ConstantInt>(MDN->getOperand(2)))
1751+
PAuthABIVersion = PAV->getZExtValue();
1752+
}
1753+
}
1754+
}
1755+
1756+
if ((PAuthABIPlatform == uint64_t(-1)) != (PAuthABIVersion == uint64_t(-1)))
1757+
report_fatal_error(
1758+
"either both or no 'aarch64-elf-pauthabi-platform' and "
1759+
"'aarch64-elf-pauthabi-version' module flags must be present");
17391760

17401761
// Validate that the requirements in the module are valid.
17411762
for (const MDNode *Requirement : Requirements) {

llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,6 @@ void AArch64AsmPrinter::emitStartOfAsmFile(Module &M) {
277277
M.getModuleFlag("aarch64-elf-pauthabi-version")))
278278
PAuthABIVersion = PAV->getZExtValue();
279279

280-
if ((PAuthABIPlatform == uint64_t(-1)) != (PAuthABIVersion == uint64_t(-1)))
281-
report_fatal_error(
282-
"either both or no 'aarch64-elf-pauthabi-platform' and "
283-
"'aarch64-elf-pauthabi-version' module flags must be present");
284-
285280
// Emit a .note.gnu.property section with the flags.
286281
auto *TS =
287282
static_cast<AArch64TargetStreamer *>(OutStreamer->getTargetStreamer());

0 commit comments

Comments
 (0)