brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · 47042d2 Raw
100 lines · plain
1; This test verifies whether a stable function is encoded into the __llvm_merge section2; when the -codegen-data-generate flag is used under -enable-global-merge-func=true.3 4; RUN: rm -rf %t; split-file %s %t5 6; RUN: opt -module-summary -module-hash %t/foo.ll -o %t-foo.bc7; RUN: opt -module-summary -module-hash %t/goo.ll -o %t-goo.bc8 9; RUN: llvm-lto2 run -enable-global-merge-func=true -codegen-data-generate=false %t-foo.bc %t-goo.bc -o %tout-nowrite \10; RUN:    -r %t-foo.bc,_f1,px \11; RUN:    -r %t-goo.bc,_f2,px \12; RUN:    -r %t-foo.bc,_g,l -r %t-foo.bc,_g1,l -r %t-foo.bc,_g2,l \13; RUN:    -r %t-goo.bc,_g,l -r %t-goo.bc,_g1,l -r %t-goo.bc,_g2,l14; RUN: llvm-nm %tout-nowrite.1 | FileCheck %s --check-prefix=NOWRITE15; RUN: llvm-nm %tout-nowrite.2 | FileCheck %s --check-prefix=NOWRITE16 17; No merge instance is locally created as each module has a singltone function.18; NOWRITE-NOT: _f1.Tgm19; NOWRITE-NOT: _f2.Tgm20 21; RUN: llvm-lto2 run -enable-global-merge-func=true -codegen-data-generate=true %t-foo.bc %t-goo.bc -o %tout-nowrite \22; RUN:    -r %t-foo.bc,_f1,px \23; RUN:    -r %t-goo.bc,_f2,px \24; RUN:    -r %t-foo.bc,_g,l -r %t-foo.bc,_g1,l -r %t-foo.bc,_g2,l \25; RUN:    -r %t-goo.bc,_g,l -r %t-goo.bc,_g1,l -r %t-goo.bc,_g2,l26; RUN: llvm-nm %tout-nowrite.1 | FileCheck %s --check-prefix=WRITE27; RUN: llvm-nm %tout-nowrite.2 | FileCheck %s --check-prefix=WRITE28; RUN: llvm-objdump -h %tout-nowrite.1 | FileCheck %s --check-prefix=SECTNAME29; RUN: llvm-objdump -h %tout-nowrite.2 | FileCheck %s --check-prefix=SECTNAME30 31; On a write mode, no merging happens yet for each module.32; We only create stable functions and publish them into __llvm_merge section for each object.33; WRITE-NOT: _f1.Tgm34; WRITE-NOT: _f2.Tgm35; SECTNAME: __llvm_merge36 37; Merge the cgdata using llvm-cgdata.38; We now validate the content of the merged cgdata.39; Two functions have the same hash with only one different constant at the same location.40; RUN: llvm-cgdata --merge -o %tout.cgdata %tout-nowrite.1 %tout-nowrite.241; RUN: llvm-cgdata --convert %tout.cgdata   -o - | FileCheck %s42; RUN: llvm-cgdata --merge -o %tout-lazy.cgdata %tout-nowrite.1 %tout-nowrite.2 -indexed-codegen-data-lazy-loading43; RUN: llvm-cgdata --convert %tout-lazy.cgdata -indexed-codegen-data-lazy-loading -o - | FileCheck %s44 45; CHECK:      - Hash: [[#%d,HASH:]]46; CHECK-NEXT:   FunctionName: f147; CHECK-NEXT:   ModuleName: {{.*}}48; CHECK-NEXT:   InstCount: [[#%d,INSTCOUNT:]]49; CHECK-NEXT:   IndexOperandHashes:50; CHECK-NEXT:     - InstIndex: [[#%d,INSTINDEX:]]51; CHECK-NEXT:       OpndIndex: [[#%d,OPNDINDEX:]]52; CHECK-NEXT:       OpndHash: {{.*}}53 54; CHECK:      - Hash: [[#%d,HASH]]55; CHECK-NEXT:   FunctionName: f256; CHECK-NEXT:   ModuleName: {{.*}}57; CHECK-NEXT:   InstCount: [[#%d,INSTCOUNT]]58; CHECK-NEXT:   IndexOperandHashes:59; CHECK-NEXT:     - InstIndex: [[#%d,INSTINDEX]]60; CHECK-NEXT:       OpndIndex: [[#%d,OPNDINDEX]]61; CHECK-NEXT:       OpndHash: {{.*}}62 63;--- foo.ll64target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"65target triple = "arm64-unknown-ios12.0.0"66 67@g = external local_unnamed_addr global [0 x i32], align 468@g1 = external global i32, align 469@g2 = external global i32, align 470 71define i32 @f1(i32 %a) {72entry:73  %idxprom = sext i32 %a to i6474  %arrayidx = getelementptr inbounds [0 x i32], [0 x i32]* @g, i64 0, i64 %idxprom75  %0 = load i32, i32* %arrayidx, align 476  %1 = load volatile i32, i32* @g1, align 477  %mul = mul nsw i32 %1, %078  %add = add nsw i32 %mul, 179  ret i32 %add80}81 82;--- goo.ll83target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"84target triple = "arm64-unknown-ios12.0.0"85 86@g = external local_unnamed_addr global [0 x i32], align 487@g1 = external global i32, align 488@g2 = external global i32, align 489 90define i32 @f2(i32 %a) {91entry:92  %idxprom = sext i32 %a to i6493  %arrayidx = getelementptr inbounds [0 x i32], [0 x i32]* @g, i64 0, i64 %idxprom94  %0 = load i32, i32* %arrayidx, align 495  %1 = load volatile i32, i32* @g2, align 496  %mul = mul nsw i32 %1, %097  %add = add nsw i32 %mul, 198  ret i32 %add99}100