Index: llvm/test/Transforms/PhaseOrdering/globalaa-retained.ll =================================================================== --- llvm/test/Transforms/PhaseOrdering/globalaa-retained.ll +++ llvm/test/Transforms/PhaseOrdering/globalaa-retained.ll @@ -5,6 +5,18 @@ @v = internal unnamed_addr global i32 0, align 4 @p = common global i32* null, align 8 + +; Invalidation might happen later in the pipeline than the +; optimization eliminating unnecessary loads/stores. Add empty +; functions before/after the function we're checking so that one of +; them will be processed by the whole set of FunctionPasses before @f. +; That will ensure the invalidation will happen before actual +; optimizations on @f start. +define void @bar() { +entry: + ret void +} + ; Function Attrs: norecurse nounwind define void @f(i32 %n) { entry: @@ -19,8 +31,17 @@ ret void } -; check variable v is loaded only once after optimization, which should be -; prove that globalsAA survives until the optimization that can use it to -; optimize away the duplicate load/stores on variable v. +; check variable v is loaded/stored only once after optimization, +; which should be prove that globalsAA survives until the optimization +; that can use it to optimize away the duplicate load/stores on +; variable v. ; CHECK: load i32, i32* @v, align 4 +; CHECK: store i32 {{.*}}, i32* @v, align 4 ; CHECK-NOT: load i32, i32* @v, align 4 +; CHECK-NOT: store i32 {{.*}}, i32* @v, align 4 + +; Same as @bar above, in case the functions are processed in reverse order. +define void @bar2() { +entry: + ret void +}