[PATCH] D20352: Add XRay flags to Clang

Dean Michael Berris via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 7 01:49:48 PDT 2016


dberris updated this revision to Diff 63038.
dberris added a comment.

- Check first whether `D` is actually not nullptr


http://reviews.llvm.org/D20352

Files:
  lib/CodeGen/CodeGenFunction.cpp
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3193,12 +3193,17 @@
   return false;
 }
 
-static void linkXRayRuntimeDeps(const ToolChain &TC, ArgStringList &CmdArgs) {
+static void linkXRayRuntimeDeps(const ToolChain &TC, const ArgList &Args,
+                                ArgStringList &CmdArgs) {
   CmdArgs.push_back("--no-as-needed");
   CmdArgs.push_back("-lpthread");
   CmdArgs.push_back("-lrt");
   CmdArgs.push_back("-lm");
   CmdArgs.push_back("-latomic");
+  if (TC.GetCXXStdlibType(Args) == ToolChain::CST_Libcxx)
+    CmdArgs.push_back("-lc++");
+  else
+    CmdArgs.push_back("-lstdc++");
   if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
     CmdArgs.push_back("-ldl");
 }
@@ -9441,7 +9446,7 @@
         linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
 
       if (NeedsXRayDeps)
-        linkXRayRuntimeDeps(ToolChain, CmdArgs);
+        linkXRayRuntimeDeps(ToolChain, Args, CmdArgs);
 
       bool WantPthread = Args.hasArg(options::OPT_pthread) ||
                          Args.hasArg(options::OPT_pthreads);
Index: lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -691,7 +691,7 @@
     Fn->addFnAttr(llvm::Attribute::SafeStack);
 
   // Apply xray attributes to the function (as a string, for now)
-  if (ShouldXRayInstrumentFunction()) {
+  if (D && ShouldXRayInstrumentFunction()) {
     if (const auto *XRayAttr = D->getAttr<XRayInstrumentAttr>()) {
       if (XRayAttr->alwaysXRayInstrument())
         Fn->addFnAttr("function-instrument", "xray-always");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20352.63038.patch
Type: text/x-patch
Size: 1717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160707/2a82103b/attachment.bin>


More information about the cfe-commits mailing list