diff options
author | Fangrui Song <maskray@google.com> | 2019-12-21 23:18:24 -0800 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2019-12-22 00:01:42 -0800 |
commit | 527b0f8c7448707aa6b8159e6e4707a49f1dcb87 (patch) | |
tree | 43ce9a40f1bbe61ee5de4dcf7b6ddd561ee56368 /clang/lib/Driver | |
parent | d0bfb3c583031f410e8219155f0cf9ee8fb08504 (diff) | |
download | bcm5719-llvm-527b0f8c7448707aa6b8159e6e4707a49f1dcb87.tar.gz bcm5719-llvm-527b0f8c7448707aa6b8159e6e4707a49f1dcb87.zip |
[Driver] Allow -mnop-mcount for SystemZ and -mfentry for X86 and SystemZ
gcc/config/{i386,s390} support -mnop-mcount. We currently only support
-mnop-mcount for SystemZ. The function attribute "mnop-mcount" is
ignored on other targets.
gcc/config/{i386,s390} support -mfentry. We currently only support
-mfentry for X86 and SystemZ. TargetOpcode::FENTRY_CALL is not handled
on other targets.
% clang -target aarch64 -pg -mfentry a.c -c
fatal error: error in backend: Not supported instr: <MCInst 21>
-mfentry, -mrecord-mcount, and -mnop-mcount were invented for Linux
ftrace. Linux uses $(call cc-option-yn,-mrecord-mcount) to detect if the
specific feature is available. Reject unsupported features so that Linux
build system will not wrongly consider them available and cause
build/runtime failures.
Note, GCC has stricter checks that we do not implement, e.g. -fpic/-fpie
-fnop-mcount is not allowed on x86, -fpic/-fpie -mfentry is not allowed
on x86-32.
Diffstat (limited to 'clang/lib/Driver')
-rw-r--r-- | clang/lib/Driver/ToolChains/Clang.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 03100948f56..1b8eca0ea0d 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4986,18 +4986,27 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, const XRayArgs &XRay = TC.getXRayArgs(); XRay.addArgs(TC, Args, CmdArgs, InputType); - if (TC.SupportsProfiling()) + if (TC.SupportsProfiling()) { Args.AddLastArg(CmdArgs, options::OPT_pg); - if (TC.SupportsProfiling()) - Args.AddLastArg(CmdArgs, options::OPT_mfentry); - - if (TC.SupportsProfiling()) - Args.AddLastArg(CmdArgs, options::OPT_mnop_mcount); - - if (TC.SupportsProfiling()) { + llvm::Triple::ArchType Arch = TC.getArch(); + if (Arg *A = Args.getLastArg(options::OPT_mfentry)) { + if (Arch == llvm::Triple::systemz || Arch == llvm::Triple::x86 || + Arch == llvm::Triple::x86_64) + A->render(Args, CmdArgs); + else + D.Diag(diag::err_drv_unsupported_opt_for_target) + << A->getAsString(Args) << TripleStr; + } + if (Arg *A = Args.getLastArg(options::OPT_mnop_mcount)) { + if (Arch == llvm::Triple::systemz) + A->render(Args, CmdArgs); + else + D.Diag(diag::err_drv_unsupported_opt_for_target) + << A->getAsString(Args) << TripleStr; + } if (Arg *A = Args.getLastArg(options::OPT_mrecord_mcount)) { - if (TC.getArch() == llvm::Triple::systemz) + if (Arch == llvm::Triple::systemz) A->render(Args, CmdArgs); else D.Diag(diag::err_drv_unsupported_opt_for_target) |