StephenFan updated this revision to Diff 411730. StephenFan added a comment.
Address @jrtc27 's comments Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D120639/new/ https://reviews.llvm.org/D120639 Files: clang/lib/Driver/ToolChains/Gnu.cpp clang/test/Driver/riscv-gnutools.c Index: clang/test/Driver/riscv-gnutools.c =================================================================== --- clang/test/Driver/riscv-gnutools.c +++ clang/test/Driver/riscv-gnutools.c @@ -16,9 +16,14 @@ // RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fno-integrated-as %s -### -c -march=rv32g \ // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s +// Check default when -mno-relax specified +// RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree -mno-relax -fno-integrated-as %s -### -c \ +// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32-NO-RELAX %s + // CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac" // CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32imafdc" // CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g" +// CHECK-RV32-NO-RELAX: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac" "-mno-relax" // 64-bit checks @@ -35,6 +40,11 @@ // RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree -fno-integrated-as %s -### -c -march=rv64g \ // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s +// Check default when -mno-relax specified +// RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree -mno-relax -fno-integrated-as %s -### -c \ +// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64-NO-RELAX %s + // CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64imac" // CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64imafdc" // CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g" +// CHECK-RV64-NO-RELAX: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64imac" "-mno-relax" Index: clang/lib/Driver/ToolChains/Gnu.cpp =================================================================== --- clang/lib/Driver/ToolChains/Gnu.cpp +++ clang/lib/Driver/ToolChains/Gnu.cpp @@ -761,6 +761,8 @@ StringRef MArchName = riscv::getRISCVArch(Args, getToolChain().getTriple()); CmdArgs.push_back("-march"); CmdArgs.push_back(MArchName.data()); + if (!Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax)) + CmdArgs.push_back("-mno-relax"); break; } case llvm::Triple::sparc:
Index: clang/test/Driver/riscv-gnutools.c =================================================================== --- clang/test/Driver/riscv-gnutools.c +++ clang/test/Driver/riscv-gnutools.c @@ -16,9 +16,14 @@ // RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fno-integrated-as %s -### -c -march=rv32g \ // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s +// Check default when -mno-relax specified +// RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree -mno-relax -fno-integrated-as %s -### -c \ +// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32-NO-RELAX %s + // CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac" // CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32imafdc" // CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g" +// CHECK-RV32-NO-RELAX: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac" "-mno-relax" // 64-bit checks @@ -35,6 +40,11 @@ // RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree -fno-integrated-as %s -### -c -march=rv64g \ // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s +// Check default when -mno-relax specified +// RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree -mno-relax -fno-integrated-as %s -### -c \ +// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64-NO-RELAX %s + // CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64imac" // CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64imafdc" // CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g" +// CHECK-RV64-NO-RELAX: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64imac" "-mno-relax" Index: clang/lib/Driver/ToolChains/Gnu.cpp =================================================================== --- clang/lib/Driver/ToolChains/Gnu.cpp +++ clang/lib/Driver/ToolChains/Gnu.cpp @@ -761,6 +761,8 @@ StringRef MArchName = riscv::getRISCVArch(Args, getToolChain().getTriple()); CmdArgs.push_back("-march"); CmdArgs.push_back(MArchName.data()); + if (!Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax)) + CmdArgs.push_back("-mno-relax"); break; } case llvm::Triple::sparc:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits