-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MSSA] Add logic for special handling of atomics/volatiles.
This patch makes MemorySSA recognize atomic/volatile loads, and makes MSSA treat said loads specially. This allows us to be a bit more aggressive in some cases. Administrative note: Revision was LGTM'ed by reames in person. Additionally, this doesn't include the `invariant.load` recognition in the differential revision, because I feel it's better to commit that separately. Will commit soon. Differential Revision: https://reviews.llvm.org/D16875 llvm-svn: 277637
- Loading branch information
1 parent
6af6f64
commit 82e355c
Showing
5 changed files
with
302 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
; RUN: opt -basicaa -print-memoryssa -verify-memoryssa -analyze < %s 2>&1 | FileCheck %s | ||
; | ||
; Things that BasicAA can prove points to constant memory should be | ||
; liveOnEntry, as well. | ||
|
||
declare void @clobberAllTheThings() | ||
|
||
@str = private unnamed_addr constant [2 x i8] c"hi" | ||
|
||
define i8 @foo() { | ||
; CHECK: 1 = MemoryDef(liveOnEntry) | ||
; CHECK-NEXT: call void @clobberAllTheThings() | ||
call void @clobberAllTheThings() | ||
%1 = getelementptr [2 x i8], [2 x i8]* @str, i64 0, i64 0 | ||
; CHECK: MemoryUse(liveOnEntry) | ||
; CHECK-NEXT: %2 = load i8 | ||
%2 = load i8, i8* %1, align 1 | ||
%3 = getelementptr [2 x i8], [2 x i8]* @str, i64 0, i64 1 | ||
; CHECK: MemoryUse(liveOnEntry) | ||
; CHECK-NEXT: %4 = load i8 | ||
%4 = load i8, i8* %3, align 1 | ||
%5 = add i8 %2, %4 | ||
ret i8 %5 | ||
} | ||
|
||
define i8 @select(i1 %b) { | ||
%1 = alloca i8, align 1 | ||
; CHECK: 1 = MemoryDef(liveOnEntry) | ||
; CHECK-NEXT: store i8 0 | ||
store i8 0, i8* %1, align 1 | ||
|
||
; CHECK: 2 = MemoryDef(1) | ||
; CHECK-NEXT: call void @clobberAllTheThings() | ||
call void @clobberAllTheThings() | ||
%2 = getelementptr [2 x i8], [2 x i8]* @str, i64 0, i64 0 | ||
%3 = select i1 %b, i8* %2, i8* %1 | ||
; CHECK: MemoryUse(2) | ||
; CHECK-NEXT: %4 = load i8 | ||
%4 = load i8, i8* %3, align 1 | ||
ret i8 %4 | ||
} |
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,30 @@ | ||
; RUN: opt -basicaa -print-memoryssa -verify-memoryssa -analyze < %s 2>&1 | FileCheck %s | ||
; | ||
; Currently, MemorySSA doesn't support invariant groups. So, we should ignore | ||
; invariant.group.barrier intrinsics entirely. We'll need to pay attention to | ||
; them when/if we decide to support invariant groups. | ||
|
||
@g = external global i32 | ||
|
||
define i32 @foo(i32* %a) { | ||
; CHECK: 1 = MemoryDef(liveOnEntry) | ||
; CHECK-NEXT: store i32 0 | ||
store i32 0, i32* %a, align 4, !llvm.invariant.group !0 | ||
|
||
; CHECK: 2 = MemoryDef(1) | ||
; CHECK-NEXT: store i32 1 | ||
store i32 1, i32* @g, align 4 | ||
|
||
%1 = bitcast i32* %a to i8* | ||
%a8 = call i8* @llvm.invariant.group.barrier(i8* %1) | ||
%a32 = bitcast i8* %a8 to i32* | ||
|
||
; CHECK: MemoryUse(2) | ||
; CHECK-NEXT: %2 = load i32 | ||
%2 = load i32, i32* %a32, align 4, !llvm.invariant.group !0 | ||
ret i32 %2 | ||
} | ||
|
||
declare i8* @llvm.invariant.group.barrier(i8*) | ||
|
||
!0 = !{!"group1"} |
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