Skip to content

Commit

Permalink
[Verifier] Require Tapir instructions to have valid syncregions.
Browse files Browse the repository at this point in the history
  • Loading branch information
neboat committed Dec 7, 2024
1 parent ebc6f7f commit e578685
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions llvm/lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3160,6 +3160,8 @@ void Verifier::verifyTask(const DetachInst *DI) {
}

void Verifier::visitReattachInst(ReattachInst &RI) {
Check(isa<Instruction>(RI.getSyncRegion()),
"reattach has an invalid syncregion", RI);
if (DT.isReachableFromEntry(RI.getParent())) {
// Check that the continuation of the reattach has a detach predecessor.
const BasicBlock *Continue = RI.getDetachContinue();
Expand All @@ -3178,6 +3180,8 @@ void Verifier::visitReattachInst(ReattachInst &RI) {
}

void Verifier::visitSyncInst(SyncInst &SI) {
Check(isa<Instruction>(SI.getSyncRegion()), "sync has an invalid syncregion",
SI);
visitTerminator(SI);
}

Expand Down Expand Up @@ -3245,6 +3249,8 @@ void Verifier::verifyTaskFrame(const CallBase *TF) {
}

void Verifier::visitDetachInst(DetachInst &DI) {
Check(isa<Instruction>(DI.getSyncRegion()),
"detach has an invalid syncregion", DI);
if (DetachesVisited.insert(&DI).second)
verifyTask(&DI);

Expand Down
4 changes: 4 additions & 0 deletions llvm/test/Transforms/Tapir/simplify-none-syncregion.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
; Check that task-simplify handles sync regions that are not instructions, specifically when debugging.
;
; RUN: opt < %s -passes="function<eager-inv>(task-simplify)" -S | FileCheck %s
;
; The verifier has been changed to require valid syncregions, meaning this IR is no longer valid.
; Keeping this test around in case none syncregions are allowed in the future.
; XFAIL: *
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
target triple = "arm64-apple-macosx15.0.0"

Expand Down

0 comments on commit e578685

Please sign in to comment.