Skip to content

Commit

Permalink
don't use 'InsertionGuard' in 'llAssert' function
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev committed Nov 11, 2024
1 parent 4ccb41f commit 52f454c
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/Conversion/TritonGPUToLLVM/AssertOpToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,22 @@ struct AssertOpConversion : public ConvertOpToLLVMPattern<triton::AssertOp> {
return failure();
}
}
Block *thenBlock = llAssert(op, condition, adaptor.getMessage(), rewriter);
llAssert(op, condition, adaptor.getMessage(), rewriter);
if (isa<RankedTensorType>(op.getCondition().getType())) {
// Add a barrier to avoid a race condition in case an assert is followed
// by an op that may trap if the assert condition is true. Since the
// tensor in those two operations may have different layout we need to
// make sure all the threads are done executing the assert before going to
// the next op.
rewriter.setInsertionPointToStart(thenBlock);
barrier();
}
rewriter.eraseOp(op);
return success();
}
// op: the op at which the assert is inserted. Unlike printf, we need to
// know about the op to split the block.
Block *llAssert(Operation *op, Value condition, StringRef message,
ConversionPatternRewriter &rewriter) const {
ConversionPatternRewriter::InsertionGuard guard(rewriter);

void llAssert(Operation *op, Value condition, StringRef message,
ConversionPatternRewriter &rewriter) const {
auto ctx = rewriter.getContext();
auto loc = op->getLoc();

Expand Down Expand Up @@ -88,7 +85,7 @@ struct AssertOpConversion : public ConvertOpToLLVMPattern<triton::AssertOp> {
rewriter.create<cf::BranchOp>(loc, thenBlock);
rewriter.setInsertionPointToEnd(prevBlock);
rewriter.create<cf::CondBranchOp>(loc, condition, ifBlock, thenBlock);
return thenBlock;
rewriter.setInsertionPointToStart(thenBlock);
}

protected:
Expand Down

0 comments on commit 52f454c

Please sign in to comment.