From 18d54cd28a13cee048f191bdfa51bcb5cfe725bd Mon Sep 17 00:00:00 2001 From: YunQiang Su Date: Mon, 6 Feb 2023 20:36:11 -0800 Subject: [PATCH 1/3] MIPS: fix build from IR files, nan2008 and FpAbi When we use llc or lld to compiler IR files, the features +nan2008 and +fpxx/+fp64 are not used. Thus wrong format files are produced. In IR files, the attributes are only set for function while not the whole compile units. So we extract the attributes from the first function and use it for the whole unit. isFPXXDefault: for o32, the FPXX should always be the default, no matter about the vendors. Of course some distributions with FP64 default enabled should be listed explicit. Let's add them in future if we know about one. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D140270 Signed-off-by: Lain Yang --- clang/lib/Driver/ToolChains/Arch/Mips.cpp | 5 ----- clang/test/Driver/mips-as.c | 10 +++++----- clang/test/Driver/mips-integrated-as.s | 6 +++--- llvm/lib/Target/Mips/MipsAsmPrinter.cpp | 10 +++++++--- llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll | 18 ++++++++++++++++++ 5 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll diff --git a/clang/lib/Driver/ToolChains/Arch/Mips.cpp b/clang/lib/Driver/ToolChains/Arch/Mips.cpp index c374d745da38..0bf89961a2e9 100644 --- a/clang/lib/Driver/ToolChains/Arch/Mips.cpp +++ b/clang/lib/Driver/ToolChains/Arch/Mips.cpp @@ -467,11 +467,6 @@ bool mips::isFP64ADefault(const llvm::Triple &Triple, StringRef CPUName) { bool mips::isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName, StringRef ABIName, mips::FloatABI FloatABI) { - if (Triple.getVendor() != llvm::Triple::ImaginationTechnologies && - Triple.getVendor() != llvm::Triple::MipsTechnologies && - !Triple.isAndroid()) - return false; - if (ABIName != "32") return false; diff --git a/clang/test/Driver/mips-as.c b/clang/test/Driver/mips-as.c index f4add636e9e8..14fbb18c9350 100644 --- a/clang/test/Driver/mips-as.c +++ b/clang/test/Driver/mips-as.c @@ -196,7 +196,7 @@ // RUN: %clang -target mips-linux-gnu -mno-mips16 -mips16 -### \ // RUN: -no-integrated-as -fno-pic -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-16 %s -// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mips16" +// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mips16" // // RUN: %clang -target mips-linux-gnu -mips16 -mno-mips16 -### \ // RUN: -no-integrated-as -fno-pic -c %s 2>&1 \ @@ -207,7 +207,7 @@ // RUN: %clang -target mips-linux-gnu -mno-micromips -mmicromips -### \ // RUN: -no-integrated-as -fno-pic -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-MICRO %s -// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmicromips" +// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mmicromips" // // RUN: %clang -target mips-linux-gnu -mmicromips -mno-micromips -### \ // RUN: -no-integrated-as -fno-pic -c %s 2>&1 \ @@ -218,7 +218,7 @@ // RUN: %clang -target mips-linux-gnu -mno-dsp -mdsp -### \ // RUN: -no-integrated-as -fno-pic -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-DSP %s -// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdsp" +// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdsp" // // RUN: %clang -target mips-linux-gnu -mdsp -mno-dsp -### \ // RUN: -no-integrated-as -fno-pic -c %s 2>&1 \ @@ -229,7 +229,7 @@ // RUN: %clang -target mips-linux-gnu -mno-dspr2 -mdspr2 -### \ // RUN: -no-integrated-as -fno-pic -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-DSPR2 %s -// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdspr2" +// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdspr2" // // RUN: %clang -target mips-linux-gnu -mdspr2 -mno-dspr2 -### \ // RUN: -no-integrated-as -fno-pic -c %s 2>&1 \ @@ -266,7 +266,7 @@ // RUN: %clang -target mips-linux-gnu -mno-msa -mmsa -### \ // RUN: -no-integrated-as -fno-pic -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-MSA %s -// MIPS-MSA: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmsa" +// MIPS-MSA: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mmsa" // // RUN: %clang -target mips-linux-gnu -mmsa -mno-msa -### \ // RUN: -no-integrated-as -fno-pic -c %s 2>&1 \ diff --git a/clang/test/Driver/mips-integrated-as.s b/clang/test/Driver/mips-integrated-as.s index 46ce5b6871f4..e248ba7f77e9 100644 --- a/clang/test/Driver/mips-integrated-as.s +++ b/clang/test/Driver/mips-integrated-as.s @@ -160,8 +160,8 @@ // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \ // RUN: FileCheck -check-prefix=FPXX-DEFAULT %s // FPXX-DEFAULT: -cc1as -// FPXX-DEFAULT-NOT: "-target-feature" "+fpxx" -// FPXX-DEFAULT-NOT: "-target-feature" "+nooddspreg" +// FPXX-DEFAULT: "-target-feature" "+fpxx" +// FPXX-DEFAULT: "-target-feature" "+nooddspreg" // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mfp32 2>&1 | \ // RUN: FileCheck -check-prefix=FP32 %s @@ -182,7 +182,7 @@ // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \ // RUN: FileCheck -check-prefix=ODDSPREG-DEFAULT %s // ODDSPREG-DEFAULT: -cc1as -// ODDSPREG-DEFAULT-NOT: "-target-feature" "{{[+-]}}nooddspreg" +// ODDSPREG-DEFAULT: "-target-feature" "+nooddspreg" // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -modd-spreg 2>&1 | \ // RUN: FileCheck -check-prefix=ODDSPREG-ON %s diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp index fcaf450cc511..6a03a48034cb 100644 --- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp +++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp @@ -777,14 +777,18 @@ void MipsAsmPrinter::emitStartOfAsmFile(Module &M) { // around it by re-initializing the PIC state here. TS.setPic(OutContext.getObjectFileInfo()->isPositionIndependent()); + // Try to get target-features from the first function. + StringRef FS = TM.getTargetFeatureString(); + Module::iterator F = M.begin(); + if (FS.empty() && M.size() && F->hasFnAttribute("target-features")) + FS = F->getFnAttribute("target-features").getValueAsString(); + // Compute MIPS architecture attributes based on the default subtarget - // that we'd have constructed. Module level directives aren't LTO - // clean anyhow. + // that we'd have constructed. // FIXME: For ifunc related functions we could iterate over and look // for a feature string that doesn't match the default one. const Triple &TT = TM.getTargetTriple(); StringRef CPU = MIPS_MC::selectMipsCPU(TT, TM.getTargetCPU()); - StringRef FS = TM.getTargetFeatureString(); const MipsTargetMachine &MTM = static_cast(TM); const MipsSubtarget STI(TT, CPU, FS, MTM.isLittleEndian(), MTM, None); diff --git a/llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll b/llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll new file mode 100644 index 000000000000..45def84b2174 --- /dev/null +++ b/llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll @@ -0,0 +1,18 @@ +;; When we compile object with "-flto", the info of "-mnan=2008" +;; and "-mfp32/-mfpxx/-mfp64" will be missing in the result IR file. +;; Thus the asm/obj files will have wrong format. +;; With D140270 we extract these info from the first function, +;; and set it for the whole compile unit. +; RUN: llc %s -o - | FileCheck %s + +target triple = "mipsel-unknown-linux-gnu" + +define dso_local void @test() #0 { + ret void +} + +attributes #0 = { "target-cpu"="mips32r2" "target-features"="+fp64,+mips32r2,+nan2008" } + + +; CHECK: .nan 2008 +; CHECK: .module fp=64 -- Gitee From 43bd07ad60d9e69f1c2207bfd6518c419991adb5 Mon Sep 17 00:00:00 2001 From: xwx1135370 Date: Mon, 6 Mar 2023 11:07:33 +0800 Subject: [PATCH 2/3] [R&D][BUILD] Failed with running mingw.py PR Description The python version is upgraded from 3.8 to 3.10, which causes the execution of mingw.py to fail Issue https://gitee.com/openharmony/third_party_llvm-project/issues/I6EF97?from=project-issue Test Full compilation Signed-off-by: xwx1135370 --- llvm-build/mingw.py | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm-build/mingw.py b/llvm-build/mingw.py index 5396ce8803ed..9d27a5e1eb6e 100755 --- a/llvm-build/mingw.py +++ b/llvm-build/mingw.py @@ -79,6 +79,7 @@ class LlvmMingw(): "LDFLAGS": common_flags, "CFLAGS": common_flags, "CXXFLAGS": common_flags, + "PATH": os.environ["PATH"], } def cmake_prebuilt_bin_dir(self): -- Gitee From 863df3c49f81ba32a87f5136bb48d222c4a5153e Mon Sep 17 00:00:00 2001 From: xwx1135370 Date: Mon, 6 Mar 2023 18:50:27 +0800 Subject: [PATCH 3/3] [LLDB] The forward message was not deleted Description Fix the forward information and executing the platform disconnect or detach are still not deleted. Issue https://gitee.com/openharmony/third_party_llvm-project/issues/I6K6CM Test 1. LLLDB command line debugging 2. Debugging Using the DevEco Signed-off-by: xwx1135370 --- lldb/source/Plugins/Platform/HOS/PlatformHOS.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/source/Plugins/Platform/HOS/PlatformHOS.cpp b/lldb/source/Plugins/Platform/HOS/PlatformHOS.cpp index de8989be4ab7..157e933b37c0 100644 --- a/lldb/source/Plugins/Platform/HOS/PlatformHOS.cpp +++ b/lldb/source/Plugins/Platform/HOS/PlatformHOS.cpp @@ -298,6 +298,9 @@ Status PlatformHOS::DisconnectRemote() { if (error.Success()) { m_device_id.clear(); m_sdk_version = 0; + if (m_remote_platform_sp) { + m_remote_platform_sp = nullptr; + } } return error; } -- Gitee