forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Support] Assert that DomTree nodes share parent (llvm#101198)
A dominance query of a block that is in a different function is ill-defined, so assert that getNode() is only called for blocks that are in the same function. There are two cases, where this behavior did occur. LoopFuse didn't explicitly do this, but didn't invalidate the SCEV block dispositions, leaving dangling pointers to free'ed basic blocks behind, causing use-after-free. We do, however, want to be able to dereference basic blocks inside the dominator tree, so that we can refer to them by a number stored inside the basic block.
- Loading branch information
Showing
5 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
llvm/test/Transforms/AlignmentFromAssumptions/domtree-crash.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -passes=alignment-from-assumptions -S < %s | FileCheck %s | ||
|
||
; The alignment assumption is a global, which has users in a different | ||
; function. Test that in this case the dominator tree is only queried with | ||
; blocks from the same function. | ||
|
||
@global = external constant [192 x i8] | ||
|
||
define void @fn1() { | ||
; CHECK-LABEL: define void @fn1() { | ||
; CHECK-NEXT: call void @llvm.assume(i1 false) [ "align"(ptr @global, i64 1) ] | ||
; CHECK-NEXT: ret void | ||
; | ||
call void @llvm.assume(i1 false) [ "align"(ptr @global, i64 1) ] | ||
ret void | ||
} | ||
|
||
define void @fn2() { | ||
; CHECK-LABEL: define void @fn2() { | ||
; CHECK-NEXT: ret void | ||
; CHECK: [[LOOP:.*]]: | ||
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr @global, i64 0 | ||
; CHECK-NEXT: [[LOAD:%.*]] = load i64, ptr [[GEP]], align 1 | ||
; CHECK-NEXT: br label %[[LOOP]] | ||
; | ||
ret void | ||
|
||
loop: | ||
%gep = getelementptr inbounds i8, ptr @global, i64 0 | ||
%load = load i64, ptr %gep, align 1 | ||
br label %loop | ||
} |