llvm-project/llvm/test/Analysis/GlobalsModRef/indirect-global.ll

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
960 B
LLVM
Raw Normal View History

; RUN: opt < %s -basic-aa -globals-aa -gvn -instcombine -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
; RUN: opt < %s -aa-pipeline=basic-aa,globals-aa -passes="require<globals-aa>,function(gvn,instcombine)" -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
[PM/AA] Disable the core unsafe aspect of GlobalsModRef in the face of basic changes to the IR such as folding pointers through PHIs, Selects, integer casts, store/load pairs, or outlining. This leaves the feature available behind a flag. This flag's default could be flipped if necessary, but the real-world performance impact of this particular feature of GMR may not be sufficiently significant for many folks to want to run the risk. Currently, the risk here is somewhat mitigated by half-hearted attempts to update GlobalsModRef when the rest of the optimizer changes something. However, I am currently trying to remove that update mechanism as it makes migrating the AA infrastructure to a form that can be readily shared between new and old pass managers very challenging. Without this update mechanism, it is possible that this still unlikely failure mode will start to trip people, and so I wanted to try to proactively avoid that. There is a lengthy discussion on the mailing list about why the core approach here is flawed, and likely would need to look totally different to be both reasonably effective and resilient to basic IR changes occuring. This patch is essentially the first of two which will enact the result of that discussion. The next patch will remove the current update mechanism. Thanks to lots of folks that helped look at this from different angles. Especial thanks to Michael Zolotukhin for doing some very prelimanary benchmarking of LTO without GlobalsModRef to get a rough idea of the impact we could be facing here. So far, it looks very small, but there are some concerns lingering from other benchmarking. The default here may get flipped if performance results end up pointing at this as a more significant issue. Also thanks to Pete and Gerolf for reviewing! Differential Revision: http://reviews.llvm.org/D11213 llvm-svn: 242512
2015-07-17 14:58:24 +08:00
;
; Note that this test relies on an unsafe feature of GlobalsModRef. While this
; test is correct and safe, GMR's technique for handling this isn't generally.
2006-10-02 06:35:45 +08:00
2008-02-14 14:56:27 +08:00
@G = internal global i32* null ; <i32**> [#uses=3]
2006-10-02 06:35:45 +08:00
declare i8* @malloc(i32)
2008-02-14 14:56:27 +08:00
define void @test() {
%a = call i8* @malloc(i32 4)
%A = bitcast i8* %a to i32*
2008-02-14 14:56:27 +08:00
store i32* %A, i32** @G
2006-10-02 06:35:45 +08:00
ret void
}
2008-02-14 14:56:27 +08:00
define i32 @test1(i32* %P) {
2012-04-24 18:45:44 +08:00
; CHECK: ret i32 0
%g1 = load i32*, i32** @G ; <i32*> [#uses=2]
%h1 = load i32, i32* %g1 ; <i32> [#uses=1]
2008-02-14 14:56:27 +08:00
store i32 123, i32* %P
%g2 = load i32*, i32** @G ; <i32*> [#uses=0]
%h2 = load i32, i32* %g1 ; <i32> [#uses=1]
2008-02-14 14:56:27 +08:00
%X = sub i32 %h1, %h2 ; <i32> [#uses=1]
ret i32 %X
2006-10-02 06:35:45 +08:00
}