llvm-project/llvm/test/Transforms/WholeProgramDevirt/unique-retval-same-vtable.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

60 lines
2.4 KiB
LLVM

; Test for PR45393: Two virtual functions that return unique i1 values
; in the same vtable. Both calls are optimized to a comparison of
; this's vptr against the address of the vtable. When nesting these
; checks, LLVM would previously assume the nested check always fails,
; but that assumption does not hold if both checks refer to the same vtable.
; This tests checks that this case is handled correctly.
;
; RUN: opt -S -passes='wholeprogramdevirt,default<O2>' -wholeprogramdevirt-summary-action=import \
; RUN: -wholeprogramdevirt-read-summary=%p/Inputs/unique-retval-same-vtable.yaml \
; RUN: -o - %s | FileCheck %s
;
; Check that C::f() contains both possible return values.
; CHECK-LABEL: define {{.*}} @_ZNK1C1fEv
; CHECK-NOT: }
; CHECK: 20074028
; CHECK-NOT: }
; CHECK: 1008434
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%class.C = type { i32 (...)** }
define hidden i32 @_ZNK1C1fEv(%class.C* %this) {
entry:
%0 = bitcast %class.C* %this to i1 (%class.C*)***
%vtable = load i1 (%class.C*)**, i1 (%class.C*)*** %0
%1 = bitcast i1 (%class.C*)** %vtable to i8*
%2 = tail call i1 @llvm.type.test(i8* %1, metadata !"_ZTS1C")
tail call void @llvm.assume(i1 %2)
%vfn = getelementptr inbounds i1 (%class.C*)*, i1 (%class.C*)** %vtable, i64 2
%3 = load i1 (%class.C*)*, i1 (%class.C*)** %vfn
%call = tail call zeroext i1 %3(%class.C* %this)
br i1 %call, label %if.then, label %return
if.then:
%vtable2 = load i1 (%class.C*)**, i1 (%class.C*)*** %0
%4 = bitcast i1 (%class.C*)** %vtable2 to i8*
%5 = tail call i1 @llvm.type.test(i8* %4, metadata !"_ZTS1C")
tail call void @llvm.assume(i1 %5)
%vfn3 = getelementptr inbounds i1 (%class.C*)*, i1 (%class.C*)** %vtable2, i64 3
%6 = load i1 (%class.C*)*, i1 (%class.C*)** %vfn3
; The method being called here and the method being called before
; the branch above both return true in the same vtable and only that
; vtable. Therefore, if this call is reached, we must select
; 20074028. Earlier versions of LLVM mistakenly concluded that
; this code *never* selects 200744028.
%call4 = tail call zeroext i1 %6(%class.C* nonnull %this)
%. = select i1 %call4, i32 20074028, i32 3007762
br label %return
return:
%retval.0 = phi i32 [ %., %if.then ], [ 1008434, %entry ]
ret i32 %retval.0
}
declare i1 @llvm.type.test(i8*, metadata)
declare void @llvm.assume(i1)