Files
clang-p2996/llvm/test/Transforms/CalledValuePropagation/simple-memory.ll
Bjorn Pettersson 3f8027fb67 [test] Update some test cases to use -passes when specifying the pipeline
This updates transform test cases for
  ADCE
  AddDiscriminators
  AggressiveInstCombine
  AlignmentFromAssumptions
  ArgumentPromotion
  BDCE
  CalledValuePropagation
  DCE
  Reg2Mem
  WholeProgramDevirt
to use the -passes syntax when specifying the pipeline.

Given that LLVM_ENABLE_NEW_PASS_MANAGER isn't set to off (which is
a deprecated feature) the updated test cases already used the new
pass manager, but they were using the legacy syntax when specifying
the passes to run. This patch can be seen as a step toward deprecating
that interface.

This patch also removes some redundant RUN lines. Here I am
referring to test cases that had multiple RUN lines verifying both
the legacy "-passname" syntax and the new "-passes=passname" syntax.
Since we switched the default pass manager to "new PM" both RUN lines
have verified the new PM version of the pass (more or less wasting
time running the same test twice), unless LLVM_ENABLE_NEW_PASS_MANAGER
is set to "off". It is assumed that it is enough to run these tests
with the new pass manager now.

Differential Revision: https://reviews.llvm.org/D108472
2021-09-29 21:51:08 +02:00

63 lines
1.8 KiB
LLVM

; RUN: opt -passes=called-value-propagation -S < %s | FileCheck %s
target triple = "aarch64-unknown-linux-gnueabi"
@global_function = internal unnamed_addr global void ()* null, align 8
@global_array = common unnamed_addr global i64* null, align 8
; This test checks that we propagate the functions through an internal global
; variable, and attach !callees metadata to the call. Such metadata can enable
; optimizations of this code sequence.
;
; For example, since both of the targeted functions have the "nounwind" and
; "readnone" function attributes, LICM can be made to move the call and the
; function pointer load outside the loop. This would then enable the loop
; vectorizer to vectorize the sum reduction.
;
; CHECK: call void %tmp0(), !callees ![[MD:[0-9]+]]
; CHECK: ![[MD]] = !{void ()* @invariant_1, void ()* @invariant_2}
;
define i64 @test_memory_entry(i64 %n, i1 %flag) {
entry:
br i1 %flag, label %then, label %else
then:
store void ()* @invariant_1, void ()** @global_function
br label %merge
else:
store void ()* @invariant_2, void ()** @global_function
br label %merge
merge:
%tmp1 = call i64 @test_memory(i64 %n)
ret i64 %tmp1
}
define internal i64 @test_memory(i64 %n) {
entry:
%array = load i64*, i64** @global_array
br label %for.body
for.body:
%i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
%r = phi i64 [ 0, %entry ], [ %tmp3, %for.body ]
%tmp0 = load void ()*, void ()** @global_function
call void %tmp0()
%tmp1 = getelementptr inbounds i64, i64* %array, i64 %i
%tmp2 = load i64, i64* %tmp1
%tmp3 = add i64 %tmp2, %r
%i.next = add nuw nsw i64 %i, 1
%cond = icmp slt i64 %i.next, %n
br i1 %cond, label %for.body, label %for.end
for.end:
%tmp4 = phi i64 [ %tmp3, %for.body ]
ret i64 %tmp4
}
declare void @invariant_1() #0
declare void @invariant_2() #0
attributes #0 = { nounwind readnone }