forked from OSchip/llvm-project
[ThinLTO/LowerTypeTests] Handle unpromoted local type ids
Summary: Fixes an issue that cropped up after the changes in D73242 to delay the lowering of type tests. LTT couldn't handle any type tests with non-string type id (which happens for local vtables, which we try to promote during the compile step but cannot always when there are no exported symbols). We can simply treat the same as having an Unknown resolution, which delays their lowering, still allowing such type tests to be used in subsequent optimization (e.g. planned usage during ICP). The final lowering which simply removes these handles them fine. Beefed up an existing ThinLTO test for such unpromoted type ids so that the internal vtable isn't removed before lower type tests, which hides the problem. Reviewers: evgeny777, pcc Subscribers: inglorion, hiraditya, steven_wu, dexonsmith, aganea, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D75201
This commit is contained in:
parent
7a25bd1d19
commit
873c0d0786
|
@ -1040,9 +1040,11 @@ void LowerTypeTestsModule::importTypeTest(CallInst *CI) {
|
|||
report_fatal_error("Second argument of llvm.type.test must be metadata");
|
||||
|
||||
auto TypeIdStr = dyn_cast<MDString>(TypeIdMDVal->getMetadata());
|
||||
// If this is a local unpromoted type, which doesn't have a metadata string,
|
||||
// treat as Unknown and delay lowering, so that we can still utilize it for
|
||||
// later optimizations.
|
||||
if (!TypeIdStr)
|
||||
report_fatal_error(
|
||||
"Second argument of llvm.type.test must be a metadata string");
|
||||
return;
|
||||
|
||||
TypeIdLowering TIL = importTypeId(TypeIdStr->getString());
|
||||
Value *Lowered = lowerTypeTestCall(TypeIdStr, CI, TIL);
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
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-grtev4-linux-gnu"
|
||||
|
||||
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @g, i8* null }]
|
||||
|
||||
%struct.D = type { i32 (...)** }
|
||||
|
||||
@_ZTV1D = internal constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* undef, i8* bitcast (i32 (%struct.D*, i32)* @_ZN1D1mEi to i8*)] }, !type !3
|
||||
|
@ -57,6 +59,23 @@ entry:
|
|||
; CHECK-IR-LABEL: ret i32
|
||||
; CHECK-IR-LABEL: }
|
||||
|
||||
; Function Attrs: inlinehint nounwind uwtable
|
||||
define internal void @_ZN1DC2Ev(%struct.D* %this) unnamed_addr align 2 {
|
||||
entry:
|
||||
%this.addr = alloca %struct.D*, align 8
|
||||
store %struct.D* %this, %struct.D** %this.addr, align 8
|
||||
%this1 = load %struct.D*, %struct.D** %this.addr
|
||||
%0 = bitcast %struct.D* %this1 to i32 (...)***
|
||||
store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1D, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
define internal void @g() section ".text.startup" {
|
||||
%d = alloca %struct.D, align 8
|
||||
call void @_ZN1DC2Ev(%struct.D* %d)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare i1 @llvm.type.test(i8*, metadata)
|
||||
declare void @llvm.assume(i1)
|
||||
|
||||
|
|
Loading…
Reference in New Issue