brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.2 KiB · b431747 Raw
94 lines · plain
1;; Test to make sure that the memprof ThinLTO backend finds the correct summary2;; when there was a naming conflict between an internal function in the original3;; module and an imported external function with the same name. The IR linking4;; will automatically append a "." followed by a numbered suffix to the existing5;; local name in that case. Note this can happen with C where the mangling would6;; be the same for the internal and external functions of the same name (C++7;; would have different mangling).8 9;; Note we don't need any MemProf related metadata for this to fail to find a10;; ValueInfo and crash if the wrong GUID is computed for the renamed local.11 12;; The original code looks something like:13;;14;; src1.c:15;; extern void external1();16;; extern void external2();17;; static void foo() {18;;   external2();19;; }20;; int main() {21;;   external1();22;;   foo();23;;   return 0;24;; }25;;26;; src2.c:27;; extern void external2();28;; void foo() {29;;   external2();30;; }31;; void external1() {32;;   foo();33;; }34;;35;; The assembly for src1 shown below was dumped after function importing.36 37; RUN: rm -rf %t && split-file %s %t && cd %t38; RUN: llvm-as src1.ll -o src1.o39; RUN: llvm-as src1.o.thinlto.ll -o src1.o.thinlto.bc40 41;; Simply check that we don't crash when trying to find the ValueInfo for each42;; function in the IR.43; RUN: opt -passes=memprof-context-disambiguation src1.o -S -memprof-import-summary=src1.o.thinlto.bc44 45;--- src1.ll46; ModuleID = 'src1.o'47source_filename = "src1.c"48target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"49target triple = "x86_64-unknown-linux-gnu"50 51define dso_local noundef i32 @main() {52entry:53  tail call void @external1()54  tail call void @foo.2()55  ret i32 056}57 58define internal void @foo.2() {59entry:60  tail call void @external2()61  ret void62}63 64declare void @external2()65 66define available_externally dso_local void @foo() !thinlto_src_module !1 !thinlto_src_file !2 {67entry:68  tail call void @external2()69  ret void70}71 72define available_externally dso_local void @external1() !thinlto_src_module !1 !thinlto_src_file !2 {73entry:74  tail call void @foo()75  ret void76}77 78!1 = !{!"src2.o"}79!2 = !{!"src2.c"}80 81;--- src1.o.thinlto.ll82; ModuleID = 'src1.o.thinlto.bc'83source_filename = "src1.o.thinlto.bc"84 85^0 = module: (path: "src1.o", hash: (2435941910, 498944982, 2551913764, 2759430100, 3918124321))86^1 = module: (path: "src2.o", hash: (1826286437, 1557684621, 1220464477, 2734102338, 1025249503))87^2 = module: (path: "src3.o", hash: (1085916433, 503665945, 2163560042, 340524, 2255774964))88^3 = gv: (guid: 1456206394295721279, summaries: (function: (module: ^0, flags: (linkage: internal, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0, importType: definition), insts: 2, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0)))) ;; src1.c:foo89^4 = gv: (guid: 6699318081062747564, summaries: (function: (module: ^1, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0, importType: definition), insts: 2, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0)))) ;; src2.c:foo90^5 = gv: (guid: 13087145834073153720, summaries: (function: (module: ^1, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0, importType: definition), insts: 2, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0), calls: ((callee: ^4, tail: 1))))) ;; src1.c:external191^6 = gv: (guid: 15822663052811949562, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0, importType: definition), insts: 3, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0), calls: ((callee: ^5, tail: 1), (callee: ^3, tail: 1))))) ;; src1.c:main92^8 = flags: 9793^9 = blockcount: 094