Successfully identified regression in *llvm* in CI configuration 
tcwg_bmk_llvm_apm/llvm-release-aarch64-spec2k6-Os.  So far, this commit has 
regressed CI configurations:
 - tcwg_bmk_llvm_apm/llvm-release-aarch64-spec2k6-Os

Culprit:
<cut>
commit 1828e57eb58685a6a7f6d4f4f698dfebf98ef789
Author: Sami Tolvanen <samitolva...@google.com>
Date:   Tue Aug 3 10:56:56 2021 -0700

    ThinLTO: Fix inline assembly references to static functions with CFI
    
    Create an internal alias with the original name for static functions
    that are renamed in promoteInternals to avoid breaking inline
    assembly references to them.
    
    Relands 700d07f8ce6f2879610fd6b6968b05c6f17bb915 with -msvc targets
    fixed.
    
    Link: https://github.com/ClangBuiltLinux/linux/issues/1354
    
    Reviewed By: nickdesaulniers, pcc
    
    Differential Revision: https://reviews.llvm.org/D104058
    
    (cherry picked from commit 7ce1c4da7726577986535cb7766d782f325145fe)
</cut>

Results regressed to (for first_bad == 1828e57eb58685a6a7f6d4f4f698dfebf98ef789)
# reset_artifacts:
-10
# build_abe binutils:
-9
# build_abe stage1 -- --set gcc_override_configure=--disable-libsanitizer:
-8
# build_abe linux:
-7
# build_abe glibc:
-6
# build_abe stage2 -- --set gcc_override_configure=--disable-libsanitizer:
-5
# build_llvm true:
-3
# true:
0
# benchmark -- -Os 
artifacts/build-1828e57eb58685a6a7f6d4f4f698dfebf98ef789/results_id:
1
# 453.povray,povray_base.default                                regressed by 102
# 470.lbm,lbm_base.default                                      regressed by 103
# 470.lbm,[.] LBM_performStreamCollide                          regressed by 118

from (for last_good == 7161e4f3345fda1b640a8250a4b34d23c74b0489)
# reset_artifacts:
-10
# build_abe binutils:
-9
# build_abe stage1 -- --set gcc_override_configure=--disable-libsanitizer:
-8
# build_abe linux:
-7
# build_abe glibc:
-6
# build_abe stage2 -- --set gcc_override_configure=--disable-libsanitizer:
-5
# build_llvm true:
-3
# true:
0
# benchmark -- -Os 
artifacts/build-7161e4f3345fda1b640a8250a4b34d23c74b0489/results_id:
1

Artifacts of last_good build: 
https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-release-aarch64-spec2k6-Os/1/artifact/artifacts/build-7161e4f3345fda1b640a8250a4b34d23c74b0489/
Results ID of last_good: 
apm_64/tcwg_bmk_llvm_apm/bisect-llvm-release-aarch64-spec2k6-Os/4779
Artifacts of first_bad build: 
https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-release-aarch64-spec2k6-Os/1/artifact/artifacts/build-1828e57eb58685a6a7f6d4f4f698dfebf98ef789/
Results ID of first_bad: 
apm_64/tcwg_bmk_llvm_apm/bisect-llvm-release-aarch64-spec2k6-Os/4788
Build top page/logs: 
https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-release-aarch64-spec2k6-Os/1/

Configuration details:


Reproduce builds:
<cut>
mkdir investigate-llvm-1828e57eb58685a6a7f6d4f4f698dfebf98ef789
cd investigate-llvm-1828e57eb58685a6a7f6d4f4f698dfebf98ef789

git clone https://git.linaro.org/toolchain/jenkins-scripts

mkdir -p artifacts/manifests
curl -o artifacts/manifests/build-baseline.sh 
https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-release-aarch64-spec2k6-Os/1/artifact/artifacts/manifests/build-baseline.sh
 --fail
curl -o artifacts/manifests/build-parameters.sh 
https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-release-aarch64-spec2k6-Os/1/artifact/artifacts/manifests/build-parameters.sh
 --fail
curl -o artifacts/test.sh 
https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-release-aarch64-spec2k6-Os/1/artifact/artifacts/test.sh
 --fail
chmod +x artifacts/test.sh

# Reproduce the baseline build (build all pre-requisites)
./jenkins-scripts/tcwg_bmk-build.sh @@ artifacts/manifests/build-baseline.sh

# Save baseline build state (which is then restored in artifacts/test.sh)
mkdir -p ./bisect
rsync -a --del --delete-excluded --exclude /bisect/ --exclude /artifacts/ 
--exclude /llvm/ ./ ./bisect/baseline/

cd llvm

# Reproduce first_bad build
git checkout --detach 1828e57eb58685a6a7f6d4f4f698dfebf98ef789
../artifacts/test.sh

# Reproduce last_good build
git checkout --detach 7161e4f3345fda1b640a8250a4b34d23c74b0489
../artifacts/test.sh

cd ..
</cut>

History of pending regressions and results: 
https://git.linaro.org/toolchain/ci/base-artifacts.git/log/?h=linaro-local/ci/tcwg_bmk_llvm_apm/llvm-release-aarch64-spec2k6-Os

Artifacts: 
https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-release-aarch64-spec2k6-Os/1/artifact/artifacts/
Build log: 
https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-release-aarch64-spec2k6-Os/1/consoleText

Full commit (up to 1000 lines):
<cut>
commit 1828e57eb58685a6a7f6d4f4f698dfebf98ef789
Author: Sami Tolvanen <samitolva...@google.com>
Date:   Tue Aug 3 10:56:56 2021 -0700

    ThinLTO: Fix inline assembly references to static functions with CFI
    
    Create an internal alias with the original name for static functions
    that are renamed in promoteInternals to avoid breaking inline
    assembly references to them.
    
    Relands 700d07f8ce6f2879610fd6b6968b05c6f17bb915 with -msvc targets
    fixed.
    
    Link: https://github.com/ClangBuiltLinux/linux/issues/1354
    
    Reviewed By: nickdesaulniers, pcc
    
    Differential Revision: https://reviews.llvm.org/D104058
    
    (cherry picked from commit 7ce1c4da7726577986535cb7766d782f325145fe)
---
 llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp   | 21 +++++++++++++++++++++
 llvm/test/ThinLTO/X86/devirt2.ll                   |  4 ++++
 .../cfi-icall-static-inline-asm.ll                 | 22 ++++++++++++++++++++++
 .../ThinLTOBitcodeWriter/split-internal2.ll        |  3 +++
 .../ThinLTOBitcodeWriter/split-vfunc-internal.ll   |  3 +++
 5 files changed, 53 insertions(+)

diff --git a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp 
b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
index 37329b489555..eea848d3eb2f 100644
--- a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
+++ b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
@@ -33,6 +33,19 @@ using namespace llvm;
 
 namespace {
 
+// Determine if a promotion alias should be created for a symbol name.
+static bool allowPromotionAlias(const std::string &Name) {
+  // Promotion aliases are used only in inline assembly. It's safe to
+  // simply skip unusual names. Subset of MCAsmInfo::isAcceptableChar()
+  // and MCAsmInfoXCOFF::isAcceptableChar().
+  for (const char &C : Name) {
+    if (isAlnum(C) || C == '_' || C == '.')
+      continue;
+    return false;
+  }
+  return true;
+}
+
 // Promote each local-linkage entity defined by ExportM and used by ImportM by
 // changing visibility and appending the given ModuleId.
 void promoteInternals(Module &ExportM, Module &ImportM, StringRef ModuleId,
@@ -55,6 +68,7 @@ void promoteInternals(Module &ExportM, Module &ImportM, 
StringRef ModuleId,
       }
     }
 
+    std::string OldName = Name.str();
     std::string NewName = (Name + ModuleId).str();
 
     if (const auto *C = ExportGV.getComdat())
@@ -69,6 +83,13 @@ void promoteInternals(Module &ExportM, Module &ImportM, 
StringRef ModuleId,
       ImportGV->setName(NewName);
       ImportGV->setVisibility(GlobalValue::HiddenVisibility);
     }
+
+    if (isa<Function>(&ExportGV) && allowPromotionAlias(OldName)) {
+      // Create a local alias with the original name to avoid breaking
+      // references from inline assembly.
+      std::string Alias = ".set " + OldName + "," + NewName + "\n";
+      ExportM.appendModuleInlineAsm(Alias);
+    }
   }
 
   if (!RenamedComdats.empty())
diff --git a/llvm/test/ThinLTO/X86/devirt2.ll b/llvm/test/ThinLTO/X86/devirt2.ll
index 42c15f1c1df5..6501a01a39df 100644
--- a/llvm/test/ThinLTO/X86/devirt2.ll
+++ b/llvm/test/ThinLTO/X86/devirt2.ll
@@ -131,10 +131,12 @@
 ; RUN:   -r=%t1.o,_ZN1D1mEi, \
 ; RUN:   -r=%t1.o,test2, \
 ; RUN:   -r=%t2.o,_ZN1A1nEi,p \
+; RUN:   -r=%t2.o,_ZN1A1nEi, \
 ; RUN:   -r=%t2.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t2.o,_ZN1C1fEi,p \
 ; RUN:   -r=%t2.o,_ZN1D1mEi,p \
 ; RUN:   -r=%t2.o,_ZN1E1mEi,p \
+; RUN:   -r=%t2.o,_ZN1E1mEi, \
 ; RUN:   -r=%t2.o,_ZTV1B, \
 ; RUN:   -r=%t2.o,_ZTV1C, \
 ; RUN:   -r=%t2.o,_ZTV1D, \
@@ -167,10 +169,12 @@
 ; RUN:   -r=%t1.o,_ZN1D1mEi, \
 ; RUN:   -r=%t1.o,test2, \
 ; RUN:   -r=%t2.o,_ZN1A1nEi,p \
+; RUN:   -r=%t2.o,_ZN1A1nEi, \
 ; RUN:   -r=%t2.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t2.o,_ZN1C1fEi,p \
 ; RUN:   -r=%t2.o,_ZN1D1mEi,p \
 ; RUN:   -r=%t2.o,_ZN1E1mEi,p \
+; RUN:   -r=%t2.o,_ZN1E1mEi, \
 ; RUN:   -r=%t2.o,_ZTV1B, \
 ; RUN:   -r=%t2.o,_ZTV1C, \
 ; RUN:   -r=%t2.o,_ZTV1D, \
diff --git 
a/llvm/test/Transforms/ThinLTOBitcodeWriter/cfi-icall-static-inline-asm.ll 
b/llvm/test/Transforms/ThinLTOBitcodeWriter/cfi-icall-static-inline-asm.ll
new file mode 100644
index 000000000000..c2de21ed4562
--- /dev/null
+++ b/llvm/test/Transforms/ThinLTOBitcodeWriter/cfi-icall-static-inline-asm.ll
@@ -0,0 +1,22 @@
+; REQUIRES: x86-registered-target
+; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o - %s | llvm-modextract -b -n 
0 -o - | llvm-dis | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK: module asm ".set a,a.[[HASH:[0-9a-f]+]]"
+
+define void @b() {
+  %f = alloca void ()*, align 8
+  ; CHECK: store{{.*}} @a.[[HASH]],{{.*}} %f
+  store void ()* @a, void ()** %f, align 8
+  ; CHECK: %1 = call void ()* asm sideeffect "leaq a(%rip)
+  %1 = call void ()* asm sideeffect "leaq a(%rip), $0\0A\09", 
"=r,~{dirflag},~{fpsr},~{flags}"()
+  ret void
+}
+
+; CHECK: define{{.*}} @a.[[HASH]](){{.*}} !type
+define internal void @a() !type !0 {
+  ret void
+}
+
+!0 = !{i64 0, !"typeid1"}
diff --git a/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll 
b/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll
index 98cc80e557f9..f50fe3f93b08 100644
--- a/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll
+++ b/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll
@@ -1,3 +1,4 @@
+; REQUIRES: x86-registered-target
 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
 ; RUN: llvm-modextract -b -n 0 -o %t0 %t
 ; RUN: llvm-modextract -b -n 1 -o %t1 %t
@@ -7,6 +8,8 @@
 ; RUN: llvm-bcanalyzer -dump %t0 | FileCheck --check-prefix=BCA0 %s
 ; RUN: llvm-bcanalyzer -dump %t1 | FileCheck --check-prefix=BCA1 %s
 
+target triple = "x86_64-unknown-linux-gnu"
+
 ; ERROR: llvm-modextract: error: module index out of range; bitcode file 
contains 2 module(s)
 
 ; BCA0: <GLOBALVAL_SUMMARY_BLOCK
diff --git a/llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll 
b/llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll
index d17cbefb0fb1..0d67b74ca5fc 100644
--- a/llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll
+++ b/llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll
@@ -1,7 +1,10 @@
+; REQUIRES: x86-registered-target
 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
 ; RUN: llvm-modextract -b -n 0 -o - %t | llvm-dis | FileCheck 
--check-prefix=M0 %s
 ; RUN: llvm-modextract -b -n 1 -o - %t | llvm-dis | FileCheck 
--check-prefix=M1 %s
 
+target triple = "x86_64-unknown-linux-gnu"
+
 define [1 x i8*]* @source() {
   ret [1 x i8*]* @g
 }
</cut>
_______________________________________________
linaro-toolchain mailing list
linaro-toolchain@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/linaro-toolchain

Reply via email to