Skip to content

Commit 8f7cfd4

Browse files
[Verifier] Modify TBAAVerifier helpers signatures to accept a nullable (NFC)
sanitizer-aarch64-linux-bootstrap-ubsan buildbot was previously failing. Resolves: https://lab.llvm.org/buildbot/#/builders/169/builds/15232.
1 parent 7196554 commit 8f7cfd4

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

llvm/include/llvm/IR/Verifier.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ class TBAAVerifier {
6060

6161
/// \name Helper functions used by \c visitTBAAMetadata.
6262
/// @{
63-
MDNode *getFieldNodeFromTBAABaseNode(Instruction &I, const MDNode *BaseNode,
64-
APInt &Offset, bool IsNewFormat);
65-
TBAAVerifier::TBAABaseNodeSummary verifyTBAABaseNode(Instruction &I,
63+
MDNode *getFieldNodeFromTBAABaseNode(const Instruction *I,
64+
const MDNode *BaseNode, APInt &Offset,
65+
bool IsNewFormat);
66+
TBAAVerifier::TBAABaseNodeSummary verifyTBAABaseNode(const Instruction *I,
6667
const MDNode *BaseNode,
6768
bool IsNewFormat);
68-
TBAABaseNodeSummary verifyTBAABaseNodeImpl(Instruction &I,
69+
TBAABaseNodeSummary verifyTBAABaseNodeImpl(const Instruction *I,
6970
const MDNode *BaseNode,
7071
bool IsNewFormat);
7172

@@ -77,7 +78,7 @@ class TBAAVerifier {
7778
: Diagnostic(Diagnostic) {}
7879
/// Visit an instruction, or a TBAA node itself as part of a metadata, and
7980
/// return true if it is valid, return false if an invalid TBAA is attached.
80-
LLVM_ABI bool visitTBAAMetadata(Instruction *I, const MDNode *MD);
81+
LLVM_ABI bool visitTBAAMetadata(const Instruction *I, const MDNode *MD);
8182
};
8283

8384
/// Check a function for errors, useful for use when debugging a

llvm/lib/IR/Verifier.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7674,10 +7674,10 @@ template <typename... Tys> void TBAAVerifier::CheckFailed(Tys &&... Args) {
76747674
/// TBAA scheme. This means \p BaseNode is either a scalar node, or a
76757675
/// struct-type node describing an aggregate data structure (like a struct).
76767676
TBAAVerifier::TBAABaseNodeSummary
7677-
TBAAVerifier::verifyTBAABaseNode(Instruction &I, const MDNode *BaseNode,
7677+
TBAAVerifier::verifyTBAABaseNode(const Instruction *I, const MDNode *BaseNode,
76787678
bool IsNewFormat) {
76797679
if (BaseNode->getNumOperands() < 2) {
7680-
CheckFailed("Base nodes must have at least two operands", &I, BaseNode);
7680+
CheckFailed("Base nodes must have at least two operands", I, BaseNode);
76817681
return {true, ~0u};
76827682
}
76837683

@@ -7693,8 +7693,8 @@ TBAAVerifier::verifyTBAABaseNode(Instruction &I, const MDNode *BaseNode,
76937693
}
76947694

76957695
TBAAVerifier::TBAABaseNodeSummary
7696-
TBAAVerifier::verifyTBAABaseNodeImpl(Instruction &I, const MDNode *BaseNode,
7697-
bool IsNewFormat) {
7696+
TBAAVerifier::verifyTBAABaseNodeImpl(const Instruction *I,
7697+
const MDNode *BaseNode, bool IsNewFormat) {
76987698
const TBAAVerifier::TBAABaseNodeSummary InvalidNode = {true, ~0u};
76997699

77007700
if (BaseNode->getNumOperands() == 2) {
@@ -7723,7 +7723,7 @@ TBAAVerifier::verifyTBAABaseNodeImpl(Instruction &I, const MDNode *BaseNode,
77237723
auto *TypeSizeNode = mdconst::dyn_extract_or_null<ConstantInt>(
77247724
BaseNode->getOperand(1));
77257725
if (!TypeSizeNode) {
7726-
CheckFailed("Type size nodes must be constants!", &I, BaseNode);
7726+
CheckFailed("Type size nodes must be constants!", I, BaseNode);
77277727
return InvalidNode;
77287728
}
77297729
}
@@ -7749,15 +7749,15 @@ TBAAVerifier::verifyTBAABaseNodeImpl(Instruction &I, const MDNode *BaseNode,
77497749
const MDOperand &FieldTy = BaseNode->getOperand(Idx);
77507750
const MDOperand &FieldOffset = BaseNode->getOperand(Idx + 1);
77517751
if (!isa<MDNode>(FieldTy)) {
7752-
CheckFailed("Incorrect field entry in struct type node!", &I, BaseNode);
7752+
CheckFailed("Incorrect field entry in struct type node!", I, BaseNode);
77537753
Failed = true;
77547754
continue;
77557755
}
77567756

77577757
auto *OffsetEntryCI =
77587758
mdconst::dyn_extract_or_null<ConstantInt>(FieldOffset);
77597759
if (!OffsetEntryCI) {
7760-
CheckFailed("Offset entries must be constants!", &I, BaseNode);
7760+
CheckFailed("Offset entries must be constants!", I, BaseNode);
77617761
Failed = true;
77627762
continue;
77637763
}
@@ -7767,7 +7767,7 @@ TBAAVerifier::verifyTBAABaseNodeImpl(Instruction &I, const MDNode *BaseNode,
77677767

77687768
if (OffsetEntryCI->getBitWidth() != BitWidth) {
77697769
CheckFailed(
7770-
"Bitwidth between the offsets and struct type entries must match", &I,
7770+
"Bitwidth between the offsets and struct type entries must match", I,
77717771
BaseNode);
77727772
Failed = true;
77737773
continue;
@@ -7782,7 +7782,7 @@ TBAAVerifier::verifyTBAABaseNodeImpl(Instruction &I, const MDNode *BaseNode,
77827782
!PrevOffset || PrevOffset->ule(OffsetEntryCI->getValue());
77837783

77847784
if (!IsAscending) {
7785-
CheckFailed("Offsets must be increasing!", &I, BaseNode);
7785+
CheckFailed("Offsets must be increasing!", I, BaseNode);
77867786
Failed = true;
77877787
}
77887788

@@ -7792,7 +7792,7 @@ TBAAVerifier::verifyTBAABaseNodeImpl(Instruction &I, const MDNode *BaseNode,
77927792
auto *MemberSizeNode = mdconst::dyn_extract_or_null<ConstantInt>(
77937793
BaseNode->getOperand(Idx + 2));
77947794
if (!MemberSizeNode) {
7795-
CheckFailed("Member size entries must be constants!", &I, BaseNode);
7795+
CheckFailed("Member size entries must be constants!", I, BaseNode);
77967796
Failed = true;
77977797
continue;
77987798
}
@@ -7844,7 +7844,7 @@ bool TBAAVerifier::isValidScalarTBAANode(const MDNode *MD) {
78447844
/// Offset in place to be the offset within the field node returned.
78457845
///
78467846
/// We assume we've okayed \p BaseNode via \c verifyTBAABaseNode.
7847-
MDNode *TBAAVerifier::getFieldNodeFromTBAABaseNode(Instruction &I,
7847+
MDNode *TBAAVerifier::getFieldNodeFromTBAABaseNode(const Instruction *I,
78487848
const MDNode *BaseNode,
78497849
APInt &Offset,
78507850
bool IsNewFormat) {
@@ -7864,7 +7864,7 @@ MDNode *TBAAVerifier::getFieldNodeFromTBAABaseNode(Instruction &I,
78647864
mdconst::extract<ConstantInt>(BaseNode->getOperand(Idx + 1));
78657865
if (OffsetEntryCI->getValue().ugt(Offset)) {
78667866
if (Idx == FirstFieldOpNo) {
7867-
CheckFailed("Could not find TBAA parent in struct type node", &I,
7867+
CheckFailed("Could not find TBAA parent in struct type node", I,
78687868
BaseNode, &Offset);
78697869
return nullptr;
78707870
}
@@ -7893,7 +7893,7 @@ static bool isNewFormatTBAATypeNode(llvm::MDNode *Type) {
78937893
return isa_and_nonnull<MDNode>(Type->getOperand(0));
78947894
}
78957895

7896-
bool TBAAVerifier::visitTBAAMetadata(Instruction *I, const MDNode *MD) {
7896+
bool TBAAVerifier::visitTBAAMetadata(const Instruction *I, const MDNode *MD) {
78977897
CheckTBAA(MD->getNumOperands() > 0, "TBAA metadata cannot have 0 operands", I,
78987898
MD);
78997899

@@ -7965,7 +7965,7 @@ bool TBAAVerifier::visitTBAAMetadata(Instruction *I, const MDNode *MD) {
79657965

79667966
for (/* empty */; BaseNode && !IsRootTBAANode(BaseNode);
79677967
BaseNode =
7968-
getFieldNodeFromTBAABaseNode(*I, BaseNode, Offset, IsNewFormat)) {
7968+
getFieldNodeFromTBAABaseNode(I, BaseNode, Offset, IsNewFormat)) {
79697969
if (!StructPath.insert(BaseNode).second) {
79707970
CheckFailed("Cycle detected in struct path", I, MD);
79717971
return false;
@@ -7974,7 +7974,7 @@ bool TBAAVerifier::visitTBAAMetadata(Instruction *I, const MDNode *MD) {
79747974
bool Invalid;
79757975
unsigned BaseNodeBitWidth;
79767976
std::tie(Invalid, BaseNodeBitWidth) =
7977-
verifyTBAABaseNode(*I, BaseNode, IsNewFormat);
7977+
verifyTBAABaseNode(I, BaseNode, IsNewFormat);
79787978

79797979
// If the base node is invalid in itself, then we've already printed all the
79807980
// errors we wanted to print.

0 commit comments

Comments
 (0)