Index: llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h =================================================================== --- llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h +++ llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h @@ -507,6 +507,10 @@ return ModulePathStringTable.count(M.getModuleIdentifier()); } + TypeIdSummary &getTypeIdSummary(StringRef TypeId) { + return TypeIdMap[TypeId]; + } + /// Remove entries in the GlobalValueMap that have empty summaries due to the /// eager nature of map entry creation during VST parsing. These would /// also be suppressed during combined index generation in mergeFrom(), Index: llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp =================================================================== --- llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp +++ llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp @@ -253,8 +253,14 @@ // Indirect function call index assignment counter for WebAssembly uint64_t IndirectIndex = 1; - // Mapping from type identifiers to the call sites that test them. - DenseMap> TypeTestCallSites; + // Mapping from type identifiers to the call sites that test them, as well as + // whether the type identifier needs to be exported to ThinLTO backends as + // part of the regular LTO phase of the ThinLTO pipeline (see exportTypeId). + struct TypeIdUserInfo { + std::vector CallSites; + bool IsExported = false; + }; + DenseMap TypeIdUsers; /// This structure describes how to lower type tests for a particular type /// identifier. It is either built directly from the global analysis (during @@ -291,6 +297,8 @@ Function *WeakInitializerFn = nullptr; + void exportTypeId(StringRef TypeId, const TypeIdLowering &TIL); + BitSetInfo buildBitSet(Metadata *TypeId, const DenseMap &GlobalLayout); @@ -687,6 +695,44 @@ } } +/// Export the given type identifier so that ThinLTO backends may import it. +/// Type identifiers are exported by adding coarse-grained information about how +/// to test the type identifier to the summary, and creating symbols in the +/// object file (aliases and absolute symbols) containing fine-grained +/// information about the type identifier. +void LowerTypeTestsModule::exportTypeId(StringRef TypeId, + const TypeIdLowering &TIL) { + TypeTestResolution &TTRes = Summary->getTypeIdSummary(TypeId).TTRes; + TTRes.TheKind = TIL.TheKind; + + auto ExportGlobal = [&](StringRef Name, Constant *C) { + GlobalAlias *GA = + GlobalAlias::create(Int8Ty, 0, GlobalValue::ExternalLinkage, + "__typeid_" + TypeId + "_" + Name, C, &M); + GA->setVisibility(GlobalValue::HiddenVisibility); + }; + + if (TIL.TheKind != TypeTestResolution::Unsat) + ExportGlobal("global_addr", TIL.OffsetedGlobal); + + if (TIL.TheKind == TypeTestResolution::ByteArray || + TIL.TheKind == TypeTestResolution::Inline || + TIL.TheKind == TypeTestResolution::AllOnes) { + ExportGlobal("align", ConstantExpr::getIntToPtr(TIL.AlignLog2, Int8PtrTy)); + ExportGlobal("size_m1", ConstantExpr::getIntToPtr(TIL.SizeM1, Int8PtrTy)); + TTRes.SizeM1BitWidth = TIL.SizeM1BitWidth; + } + + if (TIL.TheKind == TypeTestResolution::ByteArray) { + ExportGlobal("byte_array", TIL.TheByteArray); + ExportGlobal("bit_mask", TIL.BitMask); + } + + if (TIL.TheKind == TypeTestResolution::Inline) + ExportGlobal("inline_bits", + ConstantExpr::getIntToPtr(TIL.InlineBits, Int8PtrTy)); +} + void LowerTypeTestsModule::lowerTypeTestCalls( ArrayRef TypeIds, Constant *CombinedGlobalAddr, const DenseMap &GlobalLayout) { @@ -737,8 +783,13 @@ TIL.BitMask = BAI->MaskGlobal; } + TypeIdUserInfo &TIUI = TypeIdUsers[TypeId]; + + if (TIUI.IsExported) + exportTypeId(cast(TypeId)->getString(), TIL); + // Lower each call to llvm.type.test for this type identifier. - for (CallInst *CI : TypeTestCallSites[TypeId]) { + for (CallInst *CI : TIUI.CallSites) { ++NumTypeTestCallsLowered; Value *Lowered = lowerTypeTestCall(TypeId, CI, TIL); CI->replaceAllUsesWith(Lowered); @@ -1176,10 +1227,6 @@ LowerTypeTestsModule::LowerTypeTestsModule(Module &M, SummaryAction Action, ModuleSummaryIndex *Summary) : M(M), Action(Action), Summary(Summary) { - // FIXME: Use these fields. - (void)this->Action; - (void)this->Summary; - Triple TargetTriple(M.getTargetTriple()); LinkerSubsectionsViaSymbols = TargetTriple.isMacOSX(); Arch = TargetTriple.getArch(); @@ -1222,7 +1269,8 @@ bool LowerTypeTestsModule::lower() { Function *TypeTestFunc = M.getFunction(Intrinsic::getName(Intrinsic::type_test)); - if (!TypeTestFunc || TypeTestFunc->use_empty()) + if ((!TypeTestFunc || TypeTestFunc->use_empty()) && + Action != SummaryAction::Export) return false; // Equivalence class set containing type identifiers and the globals that @@ -1262,33 +1310,57 @@ } } - for (const Use &U : TypeTestFunc->uses()) { - auto CI = cast(U.getUser()); + auto AddTypeIdUse = [&](Metadata *TypeId) -> TypeIdUserInfo & { + // Add the call site to the list of call sites for this type identifier. We + // also use TypeIdUsers to keep track of whether we have seen this type + // identifier before. If we have, we don't need to re-add the referenced + // globals to the equivalence class. + auto Ins = TypeIdUsers.insert({TypeId, {}}); + if (Ins.second) { + // Add the type identifier to the equivalence class. + GlobalClassesTy::iterator GCI = GlobalClasses.insert(TypeId); + GlobalClassesTy::member_iterator CurSet = GlobalClasses.findLeader(GCI); + + // Add the referenced globals to the type identifier's equivalence class. + for (GlobalTypeMember *GTM : TypeIdInfo[TypeId].RefGlobals) + CurSet = GlobalClasses.unionSets( + CurSet, GlobalClasses.findLeader(GlobalClasses.insert(GTM))); + } - auto BitSetMDVal = dyn_cast(CI->getArgOperand(1)); - if (!BitSetMDVal) - report_fatal_error("Second argument of llvm.type.test must be metadata"); - auto BitSet = BitSetMDVal->getMetadata(); + return Ins.first->second; + }; - // Add the call site to the list of call sites for this type identifier. We - // also use TypeTestCallSites to keep track of whether we have seen this - // type identifier before. If we have, we don't need to re-add the - // referenced globals to the equivalence class. - std::pair>::iterator, bool> - Ins = TypeTestCallSites.insert( - std::make_pair(BitSet, std::vector())); - Ins.first->second.push_back(CI); - if (!Ins.second) - continue; + if (TypeTestFunc) { + for (const Use &U : TypeTestFunc->uses()) { + auto CI = cast(U.getUser()); + + auto TypeIdMDVal = dyn_cast(CI->getArgOperand(1)); + if (!TypeIdMDVal) + report_fatal_error("Second argument of llvm.type.test must be metadata"); + auto TypeId = TypeIdMDVal->getMetadata(); + AddTypeIdUse(TypeId).CallSites.push_back(CI); + } + } + + if (Action == SummaryAction::Export) { + DenseMap> MetadataByGUID; + for (auto &P : TypeIdInfo) { + if (auto *TypeId = dyn_cast(P.first)) + MetadataByGUID[GlobalValue::getGUID(TypeId->getString())].push_back( + TypeId); + } - // Add the type identifier to the equivalence class. - GlobalClassesTy::iterator GCI = GlobalClasses.insert(BitSet); - GlobalClassesTy::member_iterator CurSet = GlobalClasses.findLeader(GCI); - - // Add the referenced globals to the type identifier's equivalence class. - for (GlobalTypeMember *GTM : TypeIdInfo[BitSet].RefGlobals) - CurSet = GlobalClasses.unionSets( - CurSet, GlobalClasses.findLeader(GlobalClasses.insert(GTM))); + for (auto &P : *Summary) { + for (auto &S : P.second) { + auto *FS = dyn_cast(S.get()); + if (!FS) + continue; + // FIXME: Only add live functions. + for (GlobalValue::GUID G : FS->type_tests()) + for (Metadata *MD : MetadataByGUID[G]) + AddTypeIdUse(MD).IsExported = true; + } + } } if (GlobalClasses.empty()) Index: llvm/trunk/test/Transforms/LowerTypeTests/Inputs/use-typeid1-typeid2.yaml =================================================================== --- llvm/trunk/test/Transforms/LowerTypeTests/Inputs/use-typeid1-typeid2.yaml +++ llvm/trunk/test/Transforms/LowerTypeTests/Inputs/use-typeid1-typeid2.yaml @@ -0,0 +1,5 @@ +--- +GlobalValueMap: + 42: + - TypeTests: [14276520915468743435, 15427464259790519041] # guid("typeid1"), guid("typeid2") +... Index: llvm/trunk/test/Transforms/LowerTypeTests/export-allones.ll =================================================================== --- llvm/trunk/test/Transforms/LowerTypeTests/export-allones.ll +++ llvm/trunk/test/Transforms/LowerTypeTests/export-allones.ll @@ -0,0 +1,159 @@ +; RUN: opt -S -lowertypetests -lowertypetests-summary-action=export -lowertypetests-read-summary=%S/Inputs/use-typeid1-typeid2.yaml -lowertypetests-write-summary=%t < %s | FileCheck %s +; RUN: FileCheck --check-prefix=SUMMARY %s < %t + +@foo = constant [2048 x i8] zeroinitializer, !type !0, !type !1, !type !2, !type !3, !type !4, !type !5, !type !6, !type !7, !type !8, !type !9, !type !10, !type !11, !type !12, !type !13, !type !14, !type !15, !type !16, !type !17, !type !18, !type !19, !type !20, !type !21, !type !22, !type !23, !type !24, !type !25, !type !26, !type !27, !type !28, !type !29, !type !30, !type !31, !type !32, !type !33, !type !34, !type !35, !type !36, !type !37, !type !38, !type !39, !type !40, !type !41, !type !42, !type !43, !type !44, !type !45, !type !46, !type !47, !type !48, !type !49, !type !50, !type !51, !type !52, !type !53, !type !54, !type !55, !type !56, !type !57, !type !58, !type !59, !type !60, !type !61, !type !62, !type !63, !type !64, !type !65, !type !66, !type !67, !type !68, !type !69, !type !70, !type !71, !type !72, !type !73, !type !74, !type !75, !type !76, !type !77, !type !78, !type !79, !type !80, !type !81, !type !82, !type !83, !type !84, !type !85, !type !86, !type !87, !type !88, !type !89, !type !90, !type !91, !type !92, !type !93, !type !94, !type !95, !type !96, !type !97, !type !98, !type !99, !type !100, !type !101, !type !102, !type !103, !type !104, !type !105, !type !106, !type !107, !type !108, !type !109, !type !110, !type !111, !type !112, !type !113, !type !114, !type !115, !type !116, !type !117, !type !118, !type !119, !type !120, !type !121, !type !122, !type !123, !type !124, !type !125, !type !126, !type !127, !type !128, !type !129, !type !130 + +!0 = !{i32 0, !"typeid1"} +!1 = !{i32 2, !"typeid1"} + +!2 = !{i32 4, !"typeid2"} +!3 = !{i32 8, !"typeid2"} +!4 = !{i32 12, !"typeid2"} +!5 = !{i32 16, !"typeid2"} +!6 = !{i32 20, !"typeid2"} +!7 = !{i32 24, !"typeid2"} +!8 = !{i32 28, !"typeid2"} +!9 = !{i32 32, !"typeid2"} +!10 = !{i32 36, !"typeid2"} +!11 = !{i32 40, !"typeid2"} +!12 = !{i32 44, !"typeid2"} +!13 = !{i32 48, !"typeid2"} +!14 = !{i32 52, !"typeid2"} +!15 = !{i32 56, !"typeid2"} +!16 = !{i32 60, !"typeid2"} +!17 = !{i32 64, !"typeid2"} +!18 = !{i32 68, !"typeid2"} +!19 = !{i32 72, !"typeid2"} +!20 = !{i32 76, !"typeid2"} +!21 = !{i32 80, !"typeid2"} +!22 = !{i32 84, !"typeid2"} +!23 = !{i32 88, !"typeid2"} +!24 = !{i32 92, !"typeid2"} +!25 = !{i32 96, !"typeid2"} +!26 = !{i32 100, !"typeid2"} +!27 = !{i32 104, !"typeid2"} +!28 = !{i32 108, !"typeid2"} +!29 = !{i32 112, !"typeid2"} +!30 = !{i32 116, !"typeid2"} +!31 = !{i32 120, !"typeid2"} +!32 = !{i32 124, !"typeid2"} +!33 = !{i32 128, !"typeid2"} +!34 = !{i32 132, !"typeid2"} +!35 = !{i32 136, !"typeid2"} +!36 = !{i32 140, !"typeid2"} +!37 = !{i32 144, !"typeid2"} +!38 = !{i32 148, !"typeid2"} +!39 = !{i32 152, !"typeid2"} +!40 = !{i32 156, !"typeid2"} +!41 = !{i32 160, !"typeid2"} +!42 = !{i32 164, !"typeid2"} +!43 = !{i32 168, !"typeid2"} +!44 = !{i32 172, !"typeid2"} +!45 = !{i32 176, !"typeid2"} +!46 = !{i32 180, !"typeid2"} +!47 = !{i32 184, !"typeid2"} +!48 = !{i32 188, !"typeid2"} +!49 = !{i32 192, !"typeid2"} +!50 = !{i32 196, !"typeid2"} +!51 = !{i32 200, !"typeid2"} +!52 = !{i32 204, !"typeid2"} +!53 = !{i32 208, !"typeid2"} +!54 = !{i32 212, !"typeid2"} +!55 = !{i32 216, !"typeid2"} +!56 = !{i32 220, !"typeid2"} +!57 = !{i32 224, !"typeid2"} +!58 = !{i32 228, !"typeid2"} +!59 = !{i32 232, !"typeid2"} +!60 = !{i32 236, !"typeid2"} +!61 = !{i32 240, !"typeid2"} +!62 = !{i32 244, !"typeid2"} +!63 = !{i32 248, !"typeid2"} +!64 = !{i32 252, !"typeid2"} +!65 = !{i32 256, !"typeid2"} +!66 = !{i32 260, !"typeid2"} +!67 = !{i32 264, !"typeid2"} +!68 = !{i32 268, !"typeid2"} +!69 = !{i32 272, !"typeid2"} +!70 = !{i32 276, !"typeid2"} +!71 = !{i32 280, !"typeid2"} +!72 = !{i32 284, !"typeid2"} +!73 = !{i32 288, !"typeid2"} +!74 = !{i32 292, !"typeid2"} +!75 = !{i32 296, !"typeid2"} +!76 = !{i32 300, !"typeid2"} +!77 = !{i32 304, !"typeid2"} +!78 = !{i32 308, !"typeid2"} +!79 = !{i32 312, !"typeid2"} +!80 = !{i32 316, !"typeid2"} +!81 = !{i32 320, !"typeid2"} +!82 = !{i32 324, !"typeid2"} +!83 = !{i32 328, !"typeid2"} +!84 = !{i32 332, !"typeid2"} +!85 = !{i32 336, !"typeid2"} +!86 = !{i32 340, !"typeid2"} +!87 = !{i32 344, !"typeid2"} +!88 = !{i32 348, !"typeid2"} +!89 = !{i32 352, !"typeid2"} +!90 = !{i32 356, !"typeid2"} +!91 = !{i32 360, !"typeid2"} +!92 = !{i32 364, !"typeid2"} +!93 = !{i32 368, !"typeid2"} +!94 = !{i32 372, !"typeid2"} +!95 = !{i32 376, !"typeid2"} +!96 = !{i32 380, !"typeid2"} +!97 = !{i32 384, !"typeid2"} +!98 = !{i32 388, !"typeid2"} +!99 = !{i32 392, !"typeid2"} +!100 = !{i32 396, !"typeid2"} +!101 = !{i32 400, !"typeid2"} +!102 = !{i32 404, !"typeid2"} +!103 = !{i32 408, !"typeid2"} +!104 = !{i32 412, !"typeid2"} +!105 = !{i32 416, !"typeid2"} +!106 = !{i32 420, !"typeid2"} +!107 = !{i32 424, !"typeid2"} +!108 = !{i32 428, !"typeid2"} +!109 = !{i32 432, !"typeid2"} +!110 = !{i32 436, !"typeid2"} +!111 = !{i32 440, !"typeid2"} +!112 = !{i32 444, !"typeid2"} +!113 = !{i32 448, !"typeid2"} +!114 = !{i32 452, !"typeid2"} +!115 = !{i32 456, !"typeid2"} +!116 = !{i32 460, !"typeid2"} +!117 = !{i32 464, !"typeid2"} +!118 = !{i32 468, !"typeid2"} +!119 = !{i32 472, !"typeid2"} +!120 = !{i32 476, !"typeid2"} +!121 = !{i32 480, !"typeid2"} +!122 = !{i32 484, !"typeid2"} +!123 = !{i32 488, !"typeid2"} +!124 = !{i32 492, !"typeid2"} +!125 = !{i32 496, !"typeid2"} +!126 = !{i32 500, !"typeid2"} +!127 = !{i32 504, !"typeid2"} +!128 = !{i32 508, !"typeid2"} +!129 = !{i32 512, !"typeid2"} +!130 = !{i32 516, !"typeid2"} + +; CHECK: [[G:@[0-9]+]] = private constant { [2048 x i8] } zeroinitializer + +; CHECK: @__typeid_typeid1_global_addr = hidden alias i8, getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0, i32 0) +; CHECK: @__typeid_typeid1_align = hidden alias i8, inttoptr (i8 1 to i8*) +; CHECK: @__typeid_typeid1_size_m1 = hidden alias i8, inttoptr (i8 1 to i8*) + +; CHECK: @__typeid_typeid2_global_addr = hidden alias i8, getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0, i64 4) +; CHECK: @__typeid_typeid2_align = hidden alias i8, inttoptr (i8 2 to i8*) +; CHECK: @__typeid_typeid2_size_m1 = hidden alias i8, inttoptr (i32 128 to i8*) + +; CHECK: @foo = alias [2048 x i8], getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0) + +; SUMMARY: TypeIdMap: +; SUMMARY-NEXT: typeid1: +; SUMMARY-NEXT: TTRes: +; SUMMARY-NEXT: Kind: AllOnes +; SUMMARY-NEXT: SizeM1BitWidth: 7 +; SUMMARY-NEXT: typeid2: +; SUMMARY-NEXT: TTRes: +; SUMMARY-NEXT: Kind: AllOnes +; SUMMARY-NEXT: SizeM1BitWidth: 32 Index: llvm/trunk/test/Transforms/LowerTypeTests/export-bytearray.ll =================================================================== --- llvm/trunk/test/Transforms/LowerTypeTests/export-bytearray.ll +++ llvm/trunk/test/Transforms/LowerTypeTests/export-bytearray.ll @@ -0,0 +1,38 @@ +; RUN: opt -S -lowertypetests -lowertypetests-summary-action=export -lowertypetests-read-summary=%S/Inputs/use-typeid1-typeid2.yaml -lowertypetests-write-summary=%t < %s | FileCheck %s +; RUN: FileCheck --check-prefix=SUMMARY %s < %t + +@foo = constant [2048 x i8] zeroinitializer, !type !0, !type !1, !type !2, !type !3 + +!0 = !{i32 0, !"typeid1"} +!1 = !{i32 130, !"typeid1"} +!2 = !{i32 4, !"typeid2"} +!3 = !{i32 1032, !"typeid2"} + +; CHECK: [[G:@[0-9]+]] = private constant { [2048 x i8] } zeroinitializer +; CHECK: [[B:@[0-9]+]] = private constant [258 x i8] c"\03\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\01" + +; CHECK: @__typeid_typeid1_global_addr = hidden alias i8, getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0, i32 0) +; CHECK: @__typeid_typeid1_align = hidden alias i8, inttoptr (i8 1 to i8*) +; CHECK: @__typeid_typeid1_size_m1 = hidden alias i8, inttoptr (i8 65 to i8*) +; CHECK: @__typeid_typeid1_byte_array = hidden alias i8, i8* @bits.1 +; CHECK: @__typeid_typeid1_bit_mask = hidden alias i8, inttoptr (i8 2 to i8*) + +; CHECK: @__typeid_typeid2_global_addr = hidden alias i8, getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0, i64 4) +; CHECK: @__typeid_typeid2_align = hidden alias i8, inttoptr (i8 2 to i8*) +; CHECK: @__typeid_typeid2_size_m1 = hidden alias i8, inttoptr (i32 257 to i8*) +; CHECK: @__typeid_typeid2_byte_array = hidden alias i8, i8* @bits +; CHECK: @__typeid_typeid2_bit_mask = hidden alias i8, inttoptr (i8 1 to i8*) + +; CHECK: @foo = alias [2048 x i8], getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0) +; CHECK: @bits = private alias i8, getelementptr inbounds ([258 x i8], [258 x i8]* [[B]], i64 0, i64 0) +; CHECK: @bits.1 = private alias i8, getelementptr inbounds ([258 x i8], [258 x i8]* [[B]], i64 0, i64 0) + +; SUMMARY: TypeIdMap: +; SUMMARY-NEXT: typeid1: +; SUMMARY-NEXT: TTRes: +; SUMMARY-NEXT: Kind: ByteArray +; SUMMARY-NEXT: SizeM1BitWidth: 7 +; SUMMARY-NEXT: typeid2: +; SUMMARY-NEXT: TTRes: +; SUMMARY-NEXT: Kind: ByteArray +; SUMMARY-NEXT: SizeM1BitWidth: 32 Index: llvm/trunk/test/Transforms/LowerTypeTests/export-inline.ll =================================================================== --- llvm/trunk/test/Transforms/LowerTypeTests/export-inline.ll +++ llvm/trunk/test/Transforms/LowerTypeTests/export-inline.ll @@ -0,0 +1,33 @@ +; RUN: opt -S -lowertypetests -lowertypetests-summary-action=export -lowertypetests-read-summary=%S/Inputs/use-typeid1-typeid2.yaml -lowertypetests-write-summary=%t < %s | FileCheck %s +; RUN: FileCheck --check-prefix=SUMMARY %s < %t + +@foo = constant [2048 x i8] zeroinitializer, !type !0, !type !1, !type !2, !type !3 + +!0 = !{i32 0, !"typeid1"} +!1 = !{i32 6, !"typeid1"} +!2 = !{i32 4, !"typeid2"} +!3 = !{i32 136, !"typeid2"} + +; CHECK: [[G:@[0-9]+]] = private constant { [2048 x i8] } zeroinitializer + +; CHECK: @__typeid_typeid1_global_addr = hidden alias i8, getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0, i32 0) +; CHECK: @__typeid_typeid1_align = hidden alias i8, inttoptr (i8 1 to i8*) +; CHECK: @__typeid_typeid1_size_m1 = hidden alias i8, inttoptr (i8 3 to i8*) +; CHECK: @__typeid_typeid1_inline_bits = hidden alias i8, inttoptr (i32 9 to i8*) + +; CHECK: @__typeid_typeid2_global_addr = hidden alias i8, getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0, i64 4) +; CHECK: @__typeid_typeid2_align = hidden alias i8, inttoptr (i8 2 to i8*) +; CHECK: @__typeid_typeid2_size_m1 = hidden alias i8, inttoptr (i8 33 to i8*) +; CHECK: @__typeid_typeid2_inline_bits = hidden alias i8, inttoptr (i64 8589934593 to i8*) + +; CHECK: @foo = alias [2048 x i8], getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0) + +; SUMMARY: TypeIdMap: +; SUMMARY-NEXT: typeid1: +; SUMMARY-NEXT: TTRes: +; SUMMARY-NEXT: Kind: Inline +; SUMMARY-NEXT: SizeM1BitWidth: 5 +; SUMMARY-NEXT: typeid2: +; SUMMARY-NEXT: TTRes: +; SUMMARY-NEXT: Kind: Inline +; SUMMARY-NEXT: SizeM1BitWidth: 6 Index: llvm/trunk/test/Transforms/LowerTypeTests/export-single.ll =================================================================== --- llvm/trunk/test/Transforms/LowerTypeTests/export-single.ll +++ llvm/trunk/test/Transforms/LowerTypeTests/export-single.ll @@ -0,0 +1,17 @@ +; RUN: opt -S -lowertypetests -lowertypetests-summary-action=export -lowertypetests-read-summary=%S/Inputs/use-typeid1-typeid2.yaml -lowertypetests-write-summary=%t < %s | FileCheck %s +; RUN: FileCheck --check-prefix=SUMMARY %s < %t + +@foo = constant i32 42, !type !0 + +!0 = !{i32 0, !"typeid1"} + +; CHECK: [[G:@[0-9]+]] = private constant { i32 } { i32 42 } + +; CHECK: @__typeid_typeid1_global_addr = hidden alias i8, bitcast ({ i32 }* [[G]] to i8*) +; CHECK: @foo = alias i32, getelementptr inbounds ({ i32 }, { i32 }* [[G]], i32 0, i32 0) + +; SUMMARY: TypeIdMap: +; SUMMARY-NEXT: typeid1: +; SUMMARY-NEXT: TTRes: +; SUMMARY-NEXT: Kind: Single +; SUMMARY-NEXT: SizeM1BitWidth: 0