Skip to content

Commit 36b5501

Browse files
committed
Emit error when taking the address of unrecheable blocks
1 parent 41fce5d commit 36b5501

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

mlir/lib/Target/LLVMIR/ModuleImport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2440,7 +2440,7 @@ LogicalResult ModuleImport::processFunction(llvm::Function *func) {
24402440
// Skip unreachable blocks.
24412441
if (!reachable.contains(&basicBlock)) {
24422442
if (basicBlock.hasAddressTaken())
2443-
emitWarning(funcOp.getLoc())
2443+
emitError(funcOp.getLoc())
24442444
<< "unreachable block '" << basicBlock.getName()
24452445
<< "' with address taken";
24462446
continue;

mlir/test/Target/LLVMIR/Import/import-failure.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,13 @@ bb2:
350350
declare i32 @g()
351351

352352
declare i32 @__gxx_personality_v0(...)
353+
354+
; // -----
355+
356+
@g = private global ptr blockaddress(@fn, %bb1)
357+
define void @fn() {
358+
ret void
359+
; CHECK: unreachable block 'bb1' with address taken
360+
bb1:
361+
ret void
362+
}

0 commit comments

Comments
 (0)