aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Verifier.cpp
diff options
context:
space:
mode:
authorStephen Tozer <stephen.tozer@sony.com>2025-04-22 18:14:25 +0200
committerGitHub <noreply@github.com>2025-04-22 17:14:25 +0100
commit928c33354ee88b98bcf785d8866171857a92dd82 (patch)
tree6d96d4768457ce3fdaeb39c2c9fdbd0b9f35da31 /llvm/lib/IR/Verifier.cpp
parentf6178cdad03468a9801a23f8f7e80927614fdb7e (diff)
downloadllvm-928c33354ee88b98bcf785d8866171857a92dd82.zip
llvm-928c33354ee88b98bcf785d8866171857a92dd82.tar.gz
llvm-928c33354ee88b98bcf785d8866171857a92dd82.tar.bz2
[DebugInfo] Handle additional types of stores in assignment tracking (#129070)
Fixes #126417. Currently, assignment tracking recognizes allocas, stores, and mem intrinsics as valid instructions to tag with DIAssignID, with allocas representing the allocation for a variable and the others representing instructions that may assign to the variable. There are other intrinsics that can perform these assignments however, and if we transform a store instruction into one of these intrinsics and correctly transfer the DIAssignID over, this results in a verifier error. The AssignmentTrackingAnalysis pass also does not know how to handle these intrinsics if they are untagged, as it does not know how to extract assignment information (base address, offset, size) from them. This patch adds _some_ support for some intrinsics that may perform assignments: masked store/scatter, and vp store/strided store/scatter. This patch does not add support for extracting assignment information from these, as they may store with either non-constant size or to non-contiguous blocks of memory; instead it adds support for recognizing untagged stores with "unknown" assignment info, for which we assume that the memory location of the associated variable should not be used, as we can't determine which fragments of it should or should not be used. In principle, it should be possible to handle the more complex cases mentioned above, but it would require more substantial changes to AssignmentTrackingAnalysis, and it is mostly only needed as a fallback if the DIAssignID is not preserved on these alternative stores.
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r--llvm/lib/IR/Verifier.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 8afe360..843a78c 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -4966,8 +4966,12 @@ void Verifier::visitProfMetadata(Instruction &I, MDNode *MD) {
void Verifier::visitDIAssignIDMetadata(Instruction &I, MDNode *MD) {
assert(I.hasMetadata(LLVMContext::MD_DIAssignID));
+ // DIAssignID metadata must be attached to either an alloca or some form of
+ // store/memory-writing instruction.
+ // FIXME: We allow all intrinsic insts here to avoid trying to enumerate all
+ // possible store intrinsics.
bool ExpectedInstTy =
- isa<AllocaInst>(I) || isa<StoreInst>(I) || isa<MemIntrinsic>(I);
+ isa<AllocaInst>(I) || isa<StoreInst>(I) || isa<IntrinsicInst>(I);
CheckDI(ExpectedInstTy, "!DIAssignID attached to unexpected instruction kind",
I, MD);
// Iterate over the MetadataAsValue uses of the DIAssignID - these should