craig.topper created this revision.
craig.topper added reviewers: kito-cheng, asb, jrtc27, reames.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck,
jdoerfert, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna,
psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01,
edward-jones, zzheng, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar,
kristof.beyls, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD, MaskRay.
Herald added a project: clang.
Can be disabled with -mno-default-build-attributes just like ARM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D148817
Files:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/riscv-default-build-attributes.s
Index: clang/test/Driver/riscv-default-build-attributes.s
===================================================================
--- /dev/null
+++ clang/test/Driver/riscv-default-build-attributes.s
@@ -0,0 +1,22 @@
+// Enabled by default for assembly
+// RUN: %clang --target=riscv64 -### %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix CHECK-ENABLED
+
+// Can be forced on or off for assembly.
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mno-default-build-attributes \
+// RUN: | FileCheck %s -check-prefix CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mdefault-build-attributes \
+// RUN: | FileCheck %s -check-prefix CHECK-ENABLED
+
+
+// Option ignored C/C++ (since we always emit hardware and ABI build attributes
+// during codegen).
+// RUN: %clang --target=riscv64 -### -x c %s -mdefault-build-attributes 2>&1 \
+// RUN: | FileCheck %s -check-prefix CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### -x c++ %s -mdefault-build-attributes 2>&1
\
+// RUN: | FileCheck %s -check-prefix CHECK-DISABLED
+
+// CHECK-DISABLED-NOT: "-riscv-add-build-attributes"
+// CHECK-ENABLED: "-riscv-add-build-attributes"
+// expected-warning {{argument unused during compilation:
'-mno-default-build-attributes'}}
+// expected-warning {{argument unused during compilation:
'-mno-default-build-attributes'}}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7903,6 +7903,12 @@
CmdArgs.push_back("-target-abi");
CmdArgs.push_back(ABIName.data());
+
+ if (Args.hasFlag(options::OPT_mdefault_build_attributes,
+ options::OPT_mno_default_build_attributes, true)) {
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back("-riscv-add-build-attributes");
+ }
}
void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
Index: clang/test/Driver/riscv-default-build-attributes.s
===================================================================
--- /dev/null
+++ clang/test/Driver/riscv-default-build-attributes.s
@@ -0,0 +1,22 @@
+// Enabled by default for assembly
+// RUN: %clang --target=riscv64 -### %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix CHECK-ENABLED
+
+// Can be forced on or off for assembly.
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mno-default-build-attributes \
+// RUN: | FileCheck %s -check-prefix CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mdefault-build-attributes \
+// RUN: | FileCheck %s -check-prefix CHECK-ENABLED
+
+
+// Option ignored C/C++ (since we always emit hardware and ABI build attributes
+// during codegen).
+// RUN: %clang --target=riscv64 -### -x c %s -mdefault-build-attributes 2>&1 \
+// RUN: | FileCheck %s -check-prefix CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### -x c++ %s -mdefault-build-attributes 2>&1 \
+// RUN: | FileCheck %s -check-prefix CHECK-DISABLED
+
+// CHECK-DISABLED-NOT: "-riscv-add-build-attributes"
+// CHECK-ENABLED: "-riscv-add-build-attributes"
+// expected-warning {{argument unused during compilation: '-mno-default-build-attributes'}}
+// expected-warning {{argument unused during compilation: '-mno-default-build-attributes'}}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7903,6 +7903,12 @@
CmdArgs.push_back("-target-abi");
CmdArgs.push_back(ABIName.data());
+
+ if (Args.hasFlag(options::OPT_mdefault_build_attributes,
+ options::OPT_mno_default_build_attributes, true)) {
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back("-riscv-add-build-attributes");
+ }
}
void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits