r342715 - [XRay][clang] Propagate -fxray-instrumentation-bundle to -cc1

2018-09-21 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Fri Sep 21 01:32:49 2018
New Revision: 342715

URL: http://llvm.org/viewvc/llvm-project?rev=342715=rev
Log:
[XRay][clang] Propagate -fxray-instrumentation-bundle to -cc1

Summary:
Add a test and ensure that we propagate the
-fxray-instrumentation-bundle flag from the driver invocation to the
-cc1 options.

Reviewers: mboerger, tejohnson

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D52342

Added:
cfe/trunk/test/Driver/XRay/xray-instrumentation-bundles-flags.cpp
Modified:
cfe/trunk/include/clang/Basic/XRayInstr.h
cfe/trunk/lib/Driver/XRayArgs.cpp

Modified: cfe/trunk/include/clang/Basic/XRayInstr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/XRayInstr.h?rev=342715=342714=342715=diff
==
--- cfe/trunk/include/clang/Basic/XRayInstr.h (original)
+++ cfe/trunk/include/clang/Basic/XRayInstr.h Fri Sep 21 01:32:49 2018
@@ -60,6 +60,8 @@ struct XRayInstrSet {
 
   bool empty() const { return Mask == 0; }
 
+  bool full() const { return Mask == XRayInstrKind::All; }
+
   XRayInstrMask Mask = 0;
 };
 

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=342715=342714=342715=diff
==
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Fri Sep 21 01:32:49 2018
@@ -215,4 +215,19 @@ void XRayArgs::addArgs(const ToolChain &
 ModeOpt += Mode;
 CmdArgs.push_back(Args.MakeArgString(ModeOpt));
   }
+
+  SmallString<64> Bundle("-fxray-instrumentation-bundle=");
+  if (InstrumentationBundle.full()) {
+Bundle += "all";
+  } else if (InstrumentationBundle.empty()) {
+Bundle += "none";
+  } else {
+if (InstrumentationBundle.has(XRayInstrKind::Function))
+  Bundle += "function";
+if (InstrumentationBundle.has(XRayInstrKind::Custom))
+  Bundle += "custom";
+if (InstrumentationBundle.has(XRayInstrKind::Typed))
+  Bundle += "typed";
+  }
+  CmdArgs.push_back(Args.MakeArgString(Bundle));
 }

Added: cfe/trunk/test/Driver/XRay/xray-instrumentation-bundles-flags.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-instrumentation-bundles-flags.cpp?rev=342715=auto
==
--- cfe/trunk/test/Driver/XRay/xray-instrumentation-bundles-flags.cpp (added)
+++ cfe/trunk/test/Driver/XRay/xray-instrumentation-bundles-flags.cpp Fri Sep 
21 01:32:49 2018
@@ -0,0 +1,11 @@
+// This test ensures that when we invoke the clang compiler, that the -cc1
+// options include the -fxray-instrumentation-bundle= flag we provide in the
+// invocation.
+//
+// RUN: %clang -fxray-instrument -fxray-instrumentation-bundle=function -### \
+// RUN: -x c++ -std=c++11 -emit-llvm -c -o - %s 2>&1 \
+// RUN: | FileCheck %s
+// CHECK:  -fxray-instrumentation-bundle=function
+//
+// REQUIRES-ANY: linux, freebsd
+// REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r342200 - [XRay][clang] Emit "never-instrument" attribute

2018-09-13 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Sep 13 18:59:12 2018
New Revision: 342200

URL: http://llvm.org/viewvc/llvm-project?rev=342200=rev
Log:
[XRay][clang] Emit "never-instrument" attribute

Summary:
Before this change, we only emit the XRay attributes in LLVM IR when the
-fxray-instrument flag is provided. This may cause issues with thinlto
when the final binary is being built/linked with -fxray-instrument, and
the constitutent LLVM IR gets re-lowered with xray instrumentation.

With this change, we can honour the "never-instrument "attributes
provided in the source code and preserve those in the IR. This way, even
in thinlto builds, we retain the attributes which say whether functions
should never be XRay instrumented.

This change addresses llvm.org/PR38922.

Reviewers: mboerger, eizan

Subscribers: mehdi_amini, dexonsmith, cfe-commits, llvm-commits

Differential Revision: https://reviews.llvm.org/D52015

Added:
cfe/trunk/test/CodeGen/xray-attributes-noxray-supported.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/xray-attributes-supported.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=342200=342199=342200=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Sep 13 18:59:12 2018
@@ -901,21 +901,21 @@ void CodeGenFunction::StartFunction(Glob
   }
 
   // Apply xray attributes to the function (as a string, for now)
-  bool InstrumentXray = ShouldXRayInstrumentFunction() &&
-CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
-XRayInstrKind::Function);
-  if (D && InstrumentXray) {
+  if (D) {
 if (const auto *XRayAttr = D->getAttr()) {
-  if (XRayAttr->alwaysXRayInstrument())
-Fn->addFnAttr("function-instrument", "xray-always");
-  if (XRayAttr->neverXRayInstrument())
-Fn->addFnAttr("function-instrument", "xray-never");
-  if (const auto *LogArgs = D->getAttr()) {
-Fn->addFnAttr("xray-log-args",
-  llvm::utostr(LogArgs->getArgumentCount()));
+  if (CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+  XRayInstrKind::Function)) {
+if (XRayAttr->alwaysXRayInstrument() && ShouldXRayInstrumentFunction())
+  Fn->addFnAttr("function-instrument", "xray-always");
+if (XRayAttr->neverXRayInstrument())
+  Fn->addFnAttr("function-instrument", "xray-never");
+if (const auto *LogArgs = D->getAttr())
+  if (ShouldXRayInstrumentFunction())
+Fn->addFnAttr("xray-log-args",
+  llvm::utostr(LogArgs->getArgumentCount()));
   }
 } else {
-  if (!CGM.imbueXRayAttrs(Fn, Loc))
+  if (ShouldXRayInstrumentFunction() && !CGM.imbueXRayAttrs(Fn, Loc))
 Fn->addFnAttr(
 "xray-instruction-threshold",
 llvm::itostr(CGM.getCodeGenOpts().XRayInstructionThreshold));

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=342200=342199=342200=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Sep 13 18:59:12 2018
@@ -1967,9 +1967,6 @@ bool CodeGenModule::isInSanitizerBlackli
 
 bool CodeGenModule::imbueXRayAttrs(llvm::Function *Fn, SourceLocation Loc,
StringRef Category) const {
-  if (!LangOpts.XRayInstrument)
-return false;
-
   const auto  = getContext().getXRayFilter();
   using ImbueAttr = XRayFunctionFilter::ImbueAttribute;
   auto Attr = ImbueAttr::NONE;

Added: cfe/trunk/test/CodeGen/xray-attributes-noxray-supported.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-attributes-noxray-supported.cpp?rev=342200=auto
==
--- cfe/trunk/test/CodeGen/xray-attributes-noxray-supported.cpp (added)
+++ cfe/trunk/test/CodeGen/xray-attributes-noxray-supported.cpp Thu Sep 13 
18:59:12 2018
@@ -0,0 +1,29 @@
+// We want to ensure that the "never instrument" attributes show up even if we
+// explicitly turn off XRay instrumentation.
+//
+// RUN: %clang_cc1 %s -fno-xray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fno-xray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple arm-unknown-linux-gnu -target-abi apcs-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fno-xray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fno-xray-instrument -std=c++11 -x c++ -emit-llvm 

r339662 - [XRay][clang] Add more test cases of -fxray-modes= (NFC)

2018-08-14 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Tue Aug 14 02:16:37 2018
New Revision: 339662

URL: http://llvm.org/viewvc/llvm-project?rev=339662=rev
Log:
[XRay][clang] Add more test cases of -fxray-modes= (NFC)

This confirms expectations for multiple values provided through the
driver when selecting specific modes and the order of appearance of
individual values for the `-fxray-modes=` flag.

This change just adds more test cases to an existing test file.

Modified:
cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp

Modified: cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp?rev=339662=339661=339662=diff
==
--- cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp Tue Aug 14 02:16:37 2018
@@ -26,6 +26,20 @@
 // RUN: %clang -v -o /dev/null -fxray-instrument -fxray-modes=none,all \
 // RUN: -### %s \
 // RUN: 2>&1 | FileCheck --check-prefixes FDR,BASIC %s
+//
+// We also should support having the individual modes be concatenated.
+//
+// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-modes=none \
+// RUN: -fxray-modes=xray-fdr \
+// RUN: -### %s \
+// RUN: 2>&1 | FileCheck --check-prefixes FDR %s
+//
+// Order also matters.
+//
+// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-modes=xray-fdr \
+// RUN: -fxray-modes=none \
+// RUN: -### %s \
+// RUN: 2>&1 | FileCheck --check-prefixes NONE %s
 
 // BASIC: libclang_rt.xray-basic
 // FDR: libclang_rt.xray-fdr


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330310 - OpenBSD add C++ runtime in a driver's standpoint

2018-04-19 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Wed Apr 18 23:55:30 2018
New Revision: 330310

URL: http://llvm.org/viewvc/llvm-project?rev=330310=rev
Log:
OpenBSD add C++ runtime in a driver's standpoint

Summary: - Since 6.2 release, on supporters platforms clang is shipped with 
both libcxx and libcxxabi.

Reviewers: dberris, alekseyshl, EricWF

Reviewed By: dberris

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D45662

Modified:
cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
cfe/trunk/lib/Driver/ToolChains/OpenBSD.h

Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp?rev=330310=330309=330310=diff
==
--- cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp Wed Apr 18 23:55:30 2018
@@ -259,6 +259,14 @@ OpenBSD::OpenBSD(const Driver , const
   getFilePaths().push_back("/usr/lib");
 }
 
+void OpenBSD::AddCXXStdlibLibArgs(const ArgList ,
+  ArgStringList ) const {
+  bool Profiling = Args.hasArg(options::OPT_pg);
+
+  CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
+  CmdArgs.push_back(Profiling ? "-lc++abi_p" : "-lc++abi");
+}
+
 Tool *OpenBSD::buildAssembler() const {
   return new tools::openbsd::Assembler(*this);
 }

Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/OpenBSD.h?rev=330310=330309=330310=diff
==
--- cfe/trunk/lib/Driver/ToolChains/OpenBSD.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.h Wed Apr 18 23:55:30 2018
@@ -58,6 +58,8 @@ public:
   bool IsMathErrnoDefault() const override { return false; }
   bool IsObjCNonFragileABIDefault() const override { return true; }
   bool isPIEDefault() const override { return true; }
+  void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
+   llvm::opt::ArgStringList ) const override;
 
   unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
 return 2;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329989 - [XRay][clang] Make -fxray-modes= additive

2018-04-13 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Apr 12 22:59:57 2018
New Revision: 329989

URL: http://llvm.org/viewvc/llvm-project?rev=329989=rev
Log:
[XRay][clang] Make -fxray-modes= additive

Summary:
This allows us to do the following:

  clang -fxray-modes=none ... -fxray-modes=xray-basic

It's important to be able to do this in cases where we'd like to
specialise the configuration for the invocation of the compiler, in
various scripting environments.

This is related to llvm.org/PR37066, a follow-up to D45474.

Reviewers: eizan, kpw, pelikan

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D45610

Modified:
cfe/trunk/lib/Driver/XRayArgs.cpp
cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=329989=329988=329989=diff
==
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Thu Apr 12 22:59:57 2018
@@ -146,21 +146,16 @@ XRayArgs::XRayArgs(const ToolChain ,
   llvm::copy(XRaySupportedModes, std::back_inserter(Modes));
 else
   for (const auto  : SpecifiedModes) {
-if (Arg == "none") {
-  Modes.clear();
-  break;
-}
-if (Arg == "all") {
-  Modes.clear();
-  llvm::copy(XRaySupportedModes, std::back_inserter(Modes));
-  break;
-}
-
 // Parse CSV values for -fxray-modes=...
 llvm::SmallVector ModeParts;
 llvm::SplitString(Arg, ModeParts, ",");
 for (const auto  : ModeParts)
-  Modes.push_back(M);
+  if (M == "none")
+Modes.clear();
+  else if (M == "all")
+llvm::copy(XRaySupportedModes, std::back_inserter(Modes));
+  else
+Modes.push_back(M);
   }
 
 // Then we want to sort and unique the modes we've collected.
@@ -205,4 +200,10 @@ void XRayArgs::addArgs(const ToolChain &
 ExtraDepOpt += Dep;
 CmdArgs.push_back(Args.MakeArgString(ExtraDepOpt));
   }
+
+  for (const auto  : Modes) {
+SmallString<64> ModeOpt("-fxray-modes=");
+ModeOpt += Mode;
+CmdArgs.push_back(Args.MakeArgString(ModeOpt));
+  }
 }

Modified: cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp?rev=329989=329988=329989=diff
==
--- cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp Thu Apr 12 22:59:57 2018
@@ -14,6 +14,18 @@
 // RUN: 2>&1 | FileCheck --check-prefixes FDR,BASIC %s
 // RUN: %clang -v -o /dev/null -fxray-instrument -fxray-modes=none -### %s \
 // RUN: 2>&1 | FileCheck --check-prefixes NONE %s
+//
+// We also should support overriding the modes in an additive manner.
+//
+// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-modes=none,xray-fdr \
+// RUN: -### %s \
+// RUN: 2>&1 | FileCheck --check-prefixes FDR %s
+// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-modes=xray-fdr,none \
+// RUN: -### %s \
+// RUN: 2>&1 | FileCheck --check-prefixes NONE %s
+// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-modes=none,all \
+// RUN: -### %s \
+// RUN: 2>&1 | FileCheck --check-prefixes FDR,BASIC %s
 
 // BASIC: libclang_rt.xray-basic
 // FDR: libclang_rt.xray-fdr


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329985 - [XRay][clang] Add flag to choose instrumentation bundles

2018-04-12 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Apr 12 19:31:58 2018
New Revision: 329985

URL: http://llvm.org/viewvc/llvm-project?rev=329985=rev
Log:
[XRay][clang] Add flag to choose instrumentation bundles

Summary:
This change addresses http://llvm.org/PR36926 by allowing users to pick
which instrumentation bundles to use, when instrumenting with XRay. In
particular, the flag `-fxray-instrumentation-bundle=` has four valid
values:

- `all`: the default, emits all instrumentation kinds
- `none`: equivalent to -fnoxray-instrument
- `function`: emits the entry/exit instrumentation
- `custom`: emits the custom event instrumentation

These can be combined either as comma-separated values, or as
repeated flag values.

Reviewers: echristo, kpw, eizan, pelikan

Reviewed By: pelikan

Subscribers: mgorny, cfe-commits

Differential Revision: https://reviews.llvm.org/D44970

Added:
cfe/trunk/include/clang/Basic/XRayInstr.h
cfe/trunk/lib/Basic/XRayInstr.cpp
cfe/trunk/test/CodeGen/xray-instrumentation-bundles.cpp
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/XRayArgs.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/Basic/CMakeLists.txt
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Driver/XRayArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Added: cfe/trunk/include/clang/Basic/XRayInstr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/XRayInstr.h?rev=329985=auto
==
--- cfe/trunk/include/clang/Basic/XRayInstr.h (added)
+++ cfe/trunk/include/clang/Basic/XRayInstr.h Thu Apr 12 19:31:58 2018
@@ -0,0 +1,68 @@
+//===--- XRayInstr.h *- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+/// \file
+/// \brief Defines the clang::XRayInstrKind enum.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_XRAYINSTR_H
+#define LLVM_CLANG_BASIC_XRAYINSTR_H
+
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/MathExtras.h"
+#include 
+#include 
+
+namespace clang {
+
+using XRayInstrMask = uint32_t;
+
+namespace XRayInstrKind {
+
+// TODO: Auto-generate these as we add more instrumentation kinds.
+enum XRayInstrOrdinal : XRayInstrMask {
+  XRIO_Function,
+  XRIO_Custom,
+  XRIO_Count
+};
+
+constexpr XRayInstrMask None = 0;
+constexpr XRayInstrMask Function = 1U << XRIO_Function;
+constexpr XRayInstrMask Custom = 1U << XRIO_Custom;
+constexpr XRayInstrMask All = Function | Custom;
+
+} // namespace XRayInstrKind
+
+struct XRayInstrSet {
+  bool has(XRayInstrMask K) const {
+assert(llvm::isPowerOf2_32(K));
+return Mask & K;
+  }
+
+  bool hasOneOf(XRayInstrMask K) const { return Mask & K; }
+
+  void set(XRayInstrMask K, bool Value) {
+assert(llvm::isPowerOf2_32(K));
+Mask = Value ? (Mask | K) : (Mask & ~K);
+  }
+
+  void clear(XRayInstrMask K = XRayInstrKind::All) { Mask &= ~K; }
+
+  bool empty() const { return Mask == 0; }
+
+  XRayInstrMask Mask = 0;
+};
+
+XRayInstrMask parseXRayInstrValue(StringRef Value);
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_XRAYINSTR_H

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329985=329984=329985=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Apr 12 19:31:58 2018
@@ -1125,6 +1125,11 @@ def fxray_link_deps : Flag<["-"], "fxray
 def fnoxray_link_deps : Flag<["-"], "fnoxray-link-deps">, Group,
   Flags<[CC1Option]>;
 
+def fxray_instrumentation_bundle :
+  JoinedOrSeparate<["-"], "fxray-instrumentation-bundle=">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Select which XRay instrumentation points to emit. Options: all, 
none, function, custom. Default is 'all'.">;
+
 def ffine_grained_bitfield_accesses : Flag<["-"],
   "ffine-grained-bitfield-accesses">, Group, Flags<[CC1Option]>,
   HelpText<"Use separate accesses for bitfields with legal widths and 
alignments.">;

Modified: cfe/trunk/include/clang/Driver/XRayArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/XRayArgs.h?rev=329985=329984=329985=diff
==
--- cfe/trunk/include/clang/Driver/XRayArgs.h (original)
+++ cfe/trunk/include/clang/Driver/XRayArgs.h Thu Apr 12 19:31:58 2018
@@ -9,6 +9,7 @@
 #ifndef LLVM_CLANG_DRIVER_XRAYARGS_H
 #define 

r329779 - Adding fuzzer flags support to OpenBSD driver

2018-04-10 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Tue Apr 10 22:40:47 2018
New Revision: 329779

URL: http://llvm.org/viewvc/llvm-project?rev=329779=rev
Log:
Adding fuzzer flags support to OpenBSD driver

Summary: - Following-up the sanitizer's part commit 
https://reviews.llvm.org/rCRT329631, we enable fuzzer flags.

Reviewers: brad, thakis, dberris

Reviewed By: dberris

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D44878

Modified:
cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp?rev=329779=329778=329779=diff
==
--- cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp Tue Apr 10 22:40:47 2018
@@ -241,8 +241,11 @@ SanitizerMask OpenBSD::getSupportedSanit
   // For future use, only UBsan at the moment
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
 
-  if (IsX86 || IsX86_64)
+  if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Vptr;
+Res |= SanitizerKind::Fuzzer;
+Res |= SanitizerKind::FuzzerNoLink;
+  }
 
   return Res;
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329773 - [XRay][clang] Only enable test for supported platforms

2018-04-10 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Tue Apr 10 18:47:40 2018
New Revision: 329773

URL: http://llvm.org/viewvc/llvm-project?rev=329773=rev
Log:
[XRay][clang] Only enable test for supported platforms

This is a follow-up to D45474.

Modified:
cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp

Modified: cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp?rev=329773=329772=329773=diff
==
--- cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp Tue Apr 10 18:47:40 2018
@@ -19,3 +19,5 @@
 // FDR: libclang_rt.xray-fdr
 // NONE-NOT: libclang_rt.xray-basic
 // NONE-NOT: libclang_rt.xray-fdr
+// REQUIRES-ANY: linux, freebsd
+// REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329772 - [XRay][clang+compiler-rt] Support build-time mode selection

2018-04-10 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Tue Apr 10 18:28:25 2018
New Revision: 329772

URL: http://llvm.org/viewvc/llvm-project?rev=329772=rev
Log:
[XRay][clang+compiler-rt] Support build-time mode selection

Summary:
This patch implements the `-fxray-modes=` flag which allows users
building with XRay instrumentation to decide which modes to pre-package
into the binary being linked. The default is the status quo, which will
link all the available modes.

For this to work we're also breaking apart the mode implementations
(xray-fdr and xray-basic) from the main xray runtime. This gives more
granular control of which modes are pre-packaged, and picked from
clang's invocation.

This fixes llvm.org/PR37066.

Note that in the future, we may change the default for clang to only
contain the profiling implementation under development in D44620, when
that implementation is ready.

Reviewers: echristo, eizan, chandlerc

Reviewed By: echristo

Subscribers: mgorny, mgrang, cfe-commits, llvm-commits

Differential Revision: https://reviews.llvm.org/D45474

Added:
cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/XRayArgs.h
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/XRayArgs.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329772=329771=329772=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Apr 10 18:28:25 2018
@@ -1108,6 +1108,10 @@ def fxray_attr_list :
   JoinedOrSeparate<["-"], "fxray-attr-list=">,
   Group, Flags<[CC1Option]>,
   HelpText<"Filename defining the list of functions/types for imbuing XRay 
attributes.">;
+def fxray_modes :
+  JoinedOrSeparate<["-"], "fxray-modes=">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"List of modes to link in by default into XRay instrumented 
binaries.">;
 
 def fxray_always_emit_customevents : Flag<["-"], 
"fxray-always-emit-customevents">, Group,
   Flags<[CC1Option]>,

Modified: cfe/trunk/include/clang/Driver/XRayArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/XRayArgs.h?rev=329772=329771=329772=diff
==
--- cfe/trunk/include/clang/Driver/XRayArgs.h (original)
+++ cfe/trunk/include/clang/Driver/XRayArgs.h Tue Apr 10 18:28:25 2018
@@ -23,6 +23,7 @@ class XRayArgs {
   std::vector NeverInstrumentFiles;
   std::vector AttrListFiles;
   std::vector ExtraDeps;
+  std::vector Modes;
   bool XRayInstrument = false;
   int InstructionThreshold = 200;
   bool XRayAlwaysEmitCustomEvents = false;
@@ -35,6 +36,8 @@ public:
llvm::opt::ArgStringList , types::ID InputType) const;
 
   bool needsXRayRt() const { return XRayInstrument && XRayRT; }
+  llvm::ArrayRef modeList() const { return Modes; }
+
 };
 
 } // namespace driver

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=329772=329771=329772=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Tue Apr 10 18:28:25 2018
@@ -713,6 +713,8 @@ bool tools::addXRayRuntime(const ToolCha
   if (TC.getXRayArgs().needsXRayRt()) {
 CmdArgs.push_back("-whole-archive");
 CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+for (const auto  : TC.getXRayArgs().modeList())
+  CmdArgs.push_back(TC.getCompilerRTArgString(Args, Mode, false));
 CmdArgs.push_back("-no-whole-archive");
 return true;
   }

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=329772=329771=329772=diff
==
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Tue Apr 10 18:28:25 2018
@@ -27,6 +27,7 @@ namespace {
 constexpr char XRayInstrumentOption[] = "-fxray-instrument";
 constexpr char XRayInstructionThresholdOption[] =
 "-fxray-instruction-threshold=";
+constexpr const char *const XRaySupportedModes[] = {"xray-fdr", "xray-basic"};
 } // namespace
 
 XRayArgs::XRayArgs(const ToolChain , const ArgList ) {
@@ -51,13 +52,14 @@ XRayArgs::XRayArgs(const ToolChain ,
   }
 } else if (Triple.getOS() == llvm::Triple::FreeBSD ||
Triple.getOS() == llvm::Triple::OpenBSD) {
-if (Triple.getArch() != llvm::Triple::x86_64) {
-  D.Diag(diag::err_drv_clang_unsupported)
-  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
-}
+  if (Triple.getArch() != llvm::Triple::x86_64) {
+

r329543 - [XRay][llvm+clang] Consolidate attribute list files

2018-04-08 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Sun Apr  8 21:02:09 2018
New Revision: 329543

URL: http://llvm.org/viewvc/llvm-project?rev=329543=rev
Log:
[XRay][llvm+clang] Consolidate attribute list files

Summary:
This change consolidates the always/never lists that may be provided to
clang to externally control which functions should be XRay instrumented
by imbuing attributes. The files follow the same format as defined in
https://clang.llvm.org/docs/SanitizerSpecialCaseList.html for the
sanitizer blacklist.

We also deprecate the existing `-fxray-instrument-always=` and
`-fxray-instrument-never=` flags, in favour of `-fxray-attr-list=`.

This fixes http://llvm.org/PR34721.

Reviewers: echristo, vlad.tsyrklevich, eugenis

Reviewed By: vlad.tsyrklevich

Subscribers: llvm-commits, cfe-commits

Differential Revision: https://reviews.llvm.org/D45357

Added:
cfe/trunk/test/CodeGen/xray-attr-list.cpp
cfe/trunk/test/CodeGen/xray-never-instrument.cpp
Modified:
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Basic/XRayLists.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/XRayArgs.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Basic/XRayLists.cpp
cfe/trunk/lib/Driver/XRayArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/xray-always-instrument.cpp
cfe/trunk/test/CodeGen/xray-imbue-arg1.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=329543=329542=329543=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Sun Apr  8 21:02:09 2018
@@ -148,13 +148,20 @@ public:
   /// \brief Paths to the XRay "always instrument" files specifying which
   /// objects (files, functions, variables) should be imbued with the XRay
   /// "always instrument" attribute.
+  /// WARNING: This is a deprecated field and will go away in the future.
   std::vector XRayAlwaysInstrumentFiles;
 
   /// \brief Paths to the XRay "never instrument" files specifying which
   /// objects (files, functions, variables) should be imbued with the XRay
   /// "never instrument" attribute.
+  /// WARNING: This is a deprecated field and will go away in the future.
   std::vector XRayNeverInstrumentFiles;
 
+  /// \brief Paths to the XRay attribute list files, specifying which objects
+  /// (files, functions, variables) should be imbued with the appropriate XRay
+  /// attribute(s).
+  std::vector XRayAttrListFiles;
+
   clang::ObjCRuntime ObjCRuntime;
 
   std::string ObjCConstantStringClass;

Modified: cfe/trunk/include/clang/Basic/XRayLists.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/XRayLists.h?rev=329543=329542=329543=diff
==
--- cfe/trunk/include/clang/Basic/XRayLists.h (original)
+++ cfe/trunk/include/clang/Basic/XRayLists.h Sun Apr  8 21:02:09 2018
@@ -26,12 +26,13 @@ namespace clang {
 class XRayFunctionFilter {
   std::unique_ptr AlwaysInstrument;
   std::unique_ptr NeverInstrument;
+  std::unique_ptr AttrList;
   SourceManager 
 
 public:
   XRayFunctionFilter(ArrayRef AlwaysInstrumentPaths,
  ArrayRef NeverInstrumentPaths,
- SourceManager );
+ ArrayRef AttrListPaths, SourceManager );
 
   enum class ImbueAttribute {
 NONE,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329543=329542=329543=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Sun Apr  8 21:02:09 2018
@@ -1095,11 +1095,15 @@ def fxray_instruction_threshold_ :
 def fxray_always_instrument :
   JoinedOrSeparate<["-"], "fxray-always-instrument=">,
   Group, Flags<[CC1Option]>,
-  HelpText<"Filename defining the whitelist for imbuing the 'always 
instrument' XRay attribute.">;
+  HelpText<"DEPRECATED: Filename defining the whitelist for imbuing the 
'always instrument' XRay attribute.">;
 def fxray_never_instrument :
   JoinedOrSeparate<["-"], "fxray-never-instrument=">,
   Group, Flags<[CC1Option]>,
-  HelpText<"Filename defining the whitelist for imbuing the 'never instrument' 
XRay attribute.">;
+  HelpText<"DEPRECATED: Filename defining the whitelist for imbuing the 'never 
instrument' XRay attribute.">;
+def fxray_attr_list :
+  JoinedOrSeparate<["-"], "fxray-attr-list=">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Filename defining the list of functions/types for imbuing XRay 
attributes.">;
 
 def fxray_always_emit_customevents : Flag<["-"], 
"fxray-always-emit-customevents">, Group,
   Flags<[CC1Option]>,

Modified: 

r329378 - [XRay][clang] Only run driver test for Linux and FreeBSD

2018-04-06 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Apr  5 23:09:57 2018
New Revision: 329378

URL: http://llvm.org/viewvc/llvm-project?rev=329378=rev
Log:
[XRay][clang] Only run driver test for Linux and FreeBSD

This is a follow-up to D45354, which we should have only been running on
Linux and FreeBSD for specific targets.

Differential Revision: https://reviews.llvm.org/D45354

Modified:
cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp

Modified: cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp?rev=329378=329377=329378=diff
==
--- cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp Thu Apr  5 23:09:57 2018
@@ -4,3 +4,5 @@
 // RUN: 2>&1 | FileCheck --check-prefix ENABLE %s
 // ENABLE: clang_rt.xray
 // DISABLE-NOT: clang_rt.xray
+// REQUIRES-ANY: linux, freebsd
+// REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329376 - [XRay][clang] Add a flag to enable/disable linking XRay deps explicitly

2018-04-05 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Apr  5 22:28:54 2018
New Revision: 329376

URL: http://llvm.org/viewvc/llvm-project?rev=329376=rev
Log:
[XRay][clang] Add a flag to enable/disable linking XRay deps explicitly

Summary:
This change introduces `-fxray-link-deps` and `-fnoxray-link-deps`. The
`-fnoxray-link-deps` allows for directly controlling which specific XRay
runtime to link. The default is for clang to link the XRay runtime that
is shipped with the compiler (if there are any), but users may want to
explicitly add the XRay dependencies from other locations or other
means.

Reviewers: eizan, echristo, chandlerc

Reviewed By: eizan

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D45354

Added:
cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/XRayArgs.h
cfe/trunk/lib/Driver/XRayArgs.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329376=329375=329376=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Apr  5 22:28:54 2018
@@ -1107,6 +1107,12 @@ def fxray_always_emit_customevents : Fla
 def fnoxray_always_emit_customevents : Flag<["-"], 
"fno-xray-always-emit-customevents">, Group,
   Flags<[CC1Option]>;
 
+def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group,
+  Flags<[CC1Option]>,
+  HelpText<"Tells clang to add the link dependencies for XRay.">;
+def fnoxray_link_deps : Flag<["-"], "fnoxray-link-deps">, Group,
+  Flags<[CC1Option]>;
+
 def ffine_grained_bitfield_accesses : Flag<["-"],
   "ffine-grained-bitfield-accesses">, Group, Flags<[CC1Option]>,
   HelpText<"Use separate accesses for bitfields with legal widths and 
alignments.">;

Modified: cfe/trunk/include/clang/Driver/XRayArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/XRayArgs.h?rev=329376=329375=329376=diff
==
--- cfe/trunk/include/clang/Driver/XRayArgs.h (original)
+++ cfe/trunk/include/clang/Driver/XRayArgs.h Thu Apr  5 22:28:54 2018
@@ -25,6 +25,7 @@ class XRayArgs {
   bool XRayInstrument = false;
   int InstructionThreshold = 200;
   bool XRayAlwaysEmitCustomEvents = false;
+  bool XRayRT = true;
 
 public:
   /// Parses the XRay arguments from an argument list.
@@ -32,7 +33,7 @@ public:
   void addArgs(const ToolChain , const llvm::opt::ArgList ,
llvm::opt::ArgStringList , types::ID InputType) const;
 
-  bool needsXRayRt() const { return XRayInstrument; }
+  bool needsXRayRt() const { return XRayInstrument && XRayRT; }
 };
 
 } // namespace driver

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=329376=329375=329376=diff
==
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Thu Apr  5 22:28:54 2018
@@ -76,6 +76,10 @@ XRayArgs::XRayArgs(const ToolChain ,
  options::OPT_fnoxray_always_emit_customevents, false))
   XRayAlwaysEmitCustomEvents = true;
 
+if (!Args.hasFlag(options::OPT_fxray_link_deps,
+  options::OPT_fnoxray_link_deps, true))
+  XRayRT = false;
+
 // Validate the always/never attribute files. We also make sure that they
 // are treated as actual dependencies.
 for (const auto  :

Added: cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp?rev=329376=auto
==
--- cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp (added)
+++ cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp Thu Apr  5 22:28:54 2018
@@ -0,0 +1,6 @@
+// RUN: %clang -v -o /dev/null -fxray-instrument -fnoxray-link-deps %s -### \
+// RUN: 2>&1 | FileCheck --check-prefix DISABLE %s
+// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-link-deps %s -### \
+// RUN: 2>&1 | FileCheck --check-prefix ENABLE %s
+// ENABLE: clang_rt.xray
+// DISABLE-NOT: clang_rt.xray


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329372 - [XRay][clang] Consolidate runtime and link-time flag processing (NFC)

2018-04-05 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Apr  5 20:53:04 2018
New Revision: 329372

URL: http://llvm.org/viewvc/llvm-project?rev=329372=rev
Log:
[XRay][clang] Consolidate runtime and link-time flag processing (NFC)

Summary:
This change fixes http://llvm.org/PR36985 to define a single place in
CommonArgs.{h,cpp} where XRay runtime flags and link-time dependencies
are processed for all toolchains that support XRay instrumentation. This
is a refactoring of the same functionality spread across multiple
toolchain definitions.

Reviewers: echristo, devnexen, eizan

Reviewed By: eizan

Subscribers: emaste, cfe-commits

Differential Revision: https://reviews.llvm.org/D45243

Modified:
cfe/trunk/include/clang/Driver/XRayArgs.h
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp

Modified: cfe/trunk/include/clang/Driver/XRayArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/XRayArgs.h?rev=329372=329371=329372=diff
==
--- cfe/trunk/include/clang/Driver/XRayArgs.h (original)
+++ cfe/trunk/include/clang/Driver/XRayArgs.h Thu Apr  5 20:53:04 2018
@@ -31,6 +31,8 @@ public:
   XRayArgs(const ToolChain , const llvm::opt::ArgList );
   void addArgs(const ToolChain , const llvm::opt::ArgList ,
llvm::opt::ArgStringList , types::ID InputType) const;
+
+  bool needsXRayRt() const { return XRayInstrument; }
 };
 
 } // namespace driver

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=329372=329371=329372=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Thu Apr  5 20:53:04 2018
@@ -31,6 +31,7 @@
 #include "clang/Driver/SanitizerArgs.h"
 #include "clang/Driver/ToolChain.h"
 #include "clang/Driver/Util.h"
+#include "clang/Driver/XRayArgs.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
@@ -705,6 +706,33 @@ bool tools::addSanitizerRuntimes(const T
   return !StaticRuntimes.empty() || !NonWholeStaticRuntimes.empty();
 }
 
+bool tools::addXRayRuntime(const ToolChain, const ArgList , 
ArgStringList ) {
+  if (Args.hasArg(options::OPT_shared))
+return false;
+
+  if (TC.getXRayArgs().needsXRayRt()) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+
+  return false;
+}
+
+void tools::linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  if (TC.getTriple().getOS() != llvm::Triple::OpenBSD)
+CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+
+  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD &&
+  TC.getTriple().getOS() != llvm::Triple::NetBSD &&
+  TC.getTriple().getOS() != llvm::Triple::OpenBSD)
+CmdArgs.push_back("-ldl");
+}
+
 bool tools::areOptimizationsEnabled(const ArgList ) {
   // Find the last -O arg and see if it is non-zero.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group))

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.h?rev=329372=329371=329372=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.h Thu Apr  5 20:53:04 2018
@@ -35,6 +35,12 @@ bool addSanitizerRuntimes(const ToolChai
 void linkSanitizerRuntimeDeps(const ToolChain ,
   llvm::opt::ArgStringList );
 
+bool addXRayRuntime(const ToolChain , const llvm::opt::ArgList ,
+llvm::opt::ArgStringList );
+
+void linkXRayRuntimeDeps(const ToolChain ,
+ llvm::opt::ArgStringList );
+
 void AddRunTimeLibs(const ToolChain , const Driver ,
 llvm::opt::ArgStringList ,
 const llvm::opt::ArgList );

Modified: cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp?rev=329372=329371=329372=diff
==
--- cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp Thu Apr  5 20:53:04 2018
@@ -117,30 +117,6 @@ void freebsd::Assembler::ConstructJob(Co
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
-static bool addXRayRuntime(const ToolChain , const ArgList ,
-   

r329183 - [XRay][clang] Allow clang to build XRay instrumented binaries in OpenBSD

2018-04-04 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Wed Apr  4 05:47:49 2018
New Revision: 329183

URL: http://llvm.org/viewvc/llvm-project?rev=329183=rev
Log:
[XRay][clang] Allow clang to build XRay instrumented binaries in OpenBSD

Summary:
This patch was originally reviewed in D45126. It enables clang to add
the XRay runtime and the link-time dependencies for XRay instrumentation
in OpenBSD.

Landing for devnexen.

Reviewers: brad, dberris

Subscribers: dberris, krytarowski, cfe-commits

Author: devnexen

Differential Revision: https://reviews.llvm.org/D45126

Modified:
cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
cfe/trunk/lib/Driver/XRayArgs.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp?rev=329183=329182=329183=diff
==
--- cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp Wed Apr  4 05:47:49 2018
@@ -22,6 +22,29 @@ using namespace clang::driver::toolchain
 using namespace clang;
 using namespace llvm::opt;
 
+static bool addXRayRuntime(const ToolChain , const ArgList ,
+   ArgStringList ) {
+  if (Args.hasArg(options::OPT_shared))
+return false;
+
+  if (Args.hasFlag(options::OPT_fxray_instrument,
+   options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lm");
+  CmdArgs.push_back("-lpthread");
+}
+
 void openbsd::Assembler::ConstructJob(Compilation , const JobAction ,
   const InputInfo ,
   const InputInfoList ,
@@ -180,6 +203,7 @@ void openbsd::Linker::ConstructJob(Compi
 options::OPT_Z_Flag, options::OPT_r});
 
   bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
+  bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
@@ -195,6 +219,10 @@ void openbsd::Linker::ConstructJob(Compi
   CmdArgs.push_back(ToolChain.getCompilerRTArgString(Args, "builtins", 
false));
   linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
 }
+if (NeedsXRayDeps) {
+  CmdArgs.push_back(ToolChain.getCompilerRTArgString(Args, "builtins", 
false));
+  linkXRayRuntimeDeps(ToolChain, Args, CmdArgs);
+}
 // FIXME: For some reason GCC passes -lgcc before adding
 // the default system libraries. Just mimic this for now.
 CmdArgs.push_back("-lgcc");

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=329183=329182=329183=diff
==
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Wed Apr  4 05:47:49 2018
@@ -49,7 +49,8 @@ XRayArgs::XRayArgs(const ToolChain ,
 D.Diag(diag::err_drv_clang_unsupported)
 << (std::string(XRayInstrumentOption) + " on " + Triple.str());
   }
-} else if (Triple.getOS() == llvm::Triple::FreeBSD) {
+} else if (Triple.getOS() == llvm::Triple::FreeBSD ||
+   Triple.getOS() == llvm::Triple::OpenBSD) {
 if (Triple.getArch() != llvm::Triple::x86_64) {
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r319388 - [XRay][clang] Introduce -fxray-always-emit-customevents

2017-11-29 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Wed Nov 29 16:04:54 2017
New Revision: 319388

URL: http://llvm.org/viewvc/llvm-project?rev=319388=rev
Log:
[XRay][clang] Introduce -fxray-always-emit-customevents

Summary:
The -fxray-always-emit-customevents flag instructs clang to always emit
the LLVM IR for calls to the `__xray_customevent(...)` built-in
function. The default behaviour currently respects whether the function
has an `[[clang::xray_never_instrument]]` attribute, and thus not lower
the appropriate IR code for the custom event built-in.

This change allows users calling through to the
`__xray_customevent(...)` built-in to always see those calls lowered to
the corresponding LLVM IR to lay down instrumentation points for these
custom event calls.

Using this flag enables us to emit even just the user-provided custom
events even while never instrumenting the start/end of the function
where they appear. This is useful in cases where "phase markers" using
__xray_customevent(...) can have very few instructions, must never be
instrumented when entered/exited.

Reviewers: rnk, dblaikie, kpw

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D40601

Added:
cfe/trunk/test/CodeGen/xray-always-emit-customevent.cpp
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/XRayArgs.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Driver/XRayArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=319388=319387=319388=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Wed Nov 29 16:04:54 2017
@@ -272,6 +272,9 @@ LANGOPT(SanitizeAddressFieldPadding, 2,
"aggressive, 2: more aggressive)")
 
 LANGOPT(XRayInstrument, 1, 0, "controls whether to do XRay instrumentation")
+LANGOPT(XRayAlwaysEmitCustomEvents, 1, 0,
+"controls whether to always emit intrinsic calls to "
+"__xray_customevent(...) builtin.")
 
 BENIGN_LANGOPT(AllowEditorPlaceholders, 1, 0,
"allow editor placeholders in source")

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=319388=319387=319388=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Nov 29 16:04:54 2017
@@ -1060,6 +1060,12 @@ def fxray_never_instrument :
   Group, Flags<[CC1Option]>,
   HelpText<"Filename defining the whitelist for imbuing the 'never instrument' 
XRay attribute.">;
 
+def fxray_always_emit_customevents : Flag<["-"], 
"fxray-always-emit-customevents">, Group,
+  Flags<[CC1Option]>,
+  HelpText<"Determine whether to always emit __xray_customevent(...) calls 
even if the function it appears in is not always instrumented.">;
+def fnoxray_always_emit_customevents : Flag<["-"], 
"fno-xray-always-emit-customevents">, Group,
+  Flags<[CC1Option]>;
+
 def ffine_grained_bitfield_accesses : Flag<["-"],
   "ffine-grained-bitfield-accesses">, Group, Flags<[CC1Option]>,
   HelpText<"Use separate accesses for bitfields with legal widths and 
alignments.">;

Modified: cfe/trunk/include/clang/Driver/XRayArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/XRayArgs.h?rev=319388=319387=319388=diff
==
--- cfe/trunk/include/clang/Driver/XRayArgs.h (original)
+++ cfe/trunk/include/clang/Driver/XRayArgs.h Wed Nov 29 16:04:54 2017
@@ -24,6 +24,7 @@ class XRayArgs {
   std::vector ExtraDeps;
   bool XRayInstrument = false;
   int InstructionThreshold = 200;
+  bool XRayAlwaysEmitCustomEvents = false;
 
 public:
   /// Parses the XRay arguments from an argument list.

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=319388=319387=319388=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Nov 29 16:04:54 2017
@@ -84,6 +84,9 @@ CODEGENOPT(InstrumentFunctionEntryBare ,
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
 
+///< Set when -fxray-always-emit-customevents is enabled.
+CODEGENOPT(XRayAlwaysEmitCustomEvents , 

r317877 - Revert "[XRay][darwin] Initial XRay in Darwin Support"

2017-11-09 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Nov  9 23:00:55 2017
New Revision: 317877

URL: http://llvm.org/viewvc/llvm-project?rev=317877=rev
Log:
Revert "[XRay][darwin] Initial XRay in Darwin Support"

This reverts r317875.

Modified:
cfe/trunk/include/clang/Driver/XRayArgs.h
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Driver/XRayArgs.cpp

Modified: cfe/trunk/include/clang/Driver/XRayArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/XRayArgs.h?rev=317877=317876=317877=diff
==
--- cfe/trunk/include/clang/Driver/XRayArgs.h (original)
+++ cfe/trunk/include/clang/Driver/XRayArgs.h Thu Nov  9 23:00:55 2017
@@ -30,7 +30,6 @@ public:
   XRayArgs(const ToolChain , const llvm::opt::ArgList );
   void addArgs(const ToolChain , const llvm::opt::ArgList ,
llvm::opt::ArgStringList , types::ID InputType) const;
-  bool needsXRayRt() const { return XRayInstrument; }
 };
 
 } // namespace driver

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=317877=317876=317877=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Thu Nov  9 23:00:55 2017
@@ -18,7 +18,6 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
-#include "clang/Driver/XRayArgs.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/Path.h"
@@ -1099,11 +1098,6 @@ void DarwinClang::AddLinkRuntimeLibArgs(
   if (Sanitize.needsEsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "esan");
 
-  const XRayArgs& XRay = getXRayArgs();
-  if (XRay.needsXRayRt() && isTargetMacOS()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.xray_osx.a", RLO_AlwaysLink);
-  }
-
   // Otherwise link libSystem, then the dynamic runtime library, and finally 
any
   // target specific static runtime library.
   CmdArgs.push_back("-lSystem");

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=317877=317876=317877=diff
==
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Thu Nov  9 23:00:55 2017
@@ -51,15 +51,6 @@ XRayArgs::XRayArgs(const ToolChain ,
 D.Diag(diag::err_drv_clang_unsupported)
 << (std::string(XRayInstrumentOption) + " on " + Triple.str());
   }
-else if (Triple.getOS() == llvm::Triple::Darwin)
-  // Experimental support for macos.
-  switch (Triple.getArch()) {
-  case llvm::Triple::x86_64:
-break;
-  default:
-D.Diag(diag::err_drv_clang_unsupported)
-<< (std::string(XRayInstrumentOption) + " on " + Triple.str());
-  }
 else
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on non-Linux target OS");


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r317875 - [XRay][darwin] Initial XRay in Darwin Support

2017-11-09 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Nov  9 21:50:13 2017
New Revision: 317875

URL: http://llvm.org/viewvc/llvm-project?rev=317875=rev
Log:
[XRay][darwin] Initial XRay in Darwin Support

Summary:
This change implements the changes required in both clang and
compiler-rt to allow building XRay-instrumented binaries in Darwin. For
now we limit this to x86_64. We also start building the XRay runtime
library in compiler-rt for osx.

A caveat to this is that we don't have the tests set up and running
yet, which we'll do in a set of follow-on changes.

This patch uses the monorepo layout for the coordinated change across
multiple projects.

Reviewers: kubamracek

Subscribers: mgorny, cfe-commits, llvm-commits

Differential Revision: https://reviews.llvm.org/D39114

Modified:
cfe/trunk/include/clang/Driver/XRayArgs.h
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Driver/XRayArgs.cpp

Modified: cfe/trunk/include/clang/Driver/XRayArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/XRayArgs.h?rev=317875=317874=317875=diff
==
--- cfe/trunk/include/clang/Driver/XRayArgs.h (original)
+++ cfe/trunk/include/clang/Driver/XRayArgs.h Thu Nov  9 21:50:13 2017
@@ -30,6 +30,7 @@ public:
   XRayArgs(const ToolChain , const llvm::opt::ArgList );
   void addArgs(const ToolChain , const llvm::opt::ArgList ,
llvm::opt::ArgStringList , types::ID InputType) const;
+  bool needsXRayRt() const { return XRayInstrument; }
 };
 
 } // namespace driver

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=317875=317874=317875=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Thu Nov  9 21:50:13 2017
@@ -18,6 +18,7 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
+#include "clang/Driver/XRayArgs.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/Path.h"
@@ -1098,6 +1099,11 @@ void DarwinClang::AddLinkRuntimeLibArgs(
   if (Sanitize.needsEsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "esan");
 
+  const XRayArgs& XRay = getXRayArgs();
+  if (XRay.needsXRayRt() && isTargetMacOS()) {
+AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.xray_osx.a", RLO_AlwaysLink);
+  }
+
   // Otherwise link libSystem, then the dynamic runtime library, and finally 
any
   // target specific static runtime library.
   CmdArgs.push_back("-lSystem");

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=317875=317874=317875=diff
==
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Thu Nov  9 21:50:13 2017
@@ -51,6 +51,15 @@ XRayArgs::XRayArgs(const ToolChain ,
 D.Diag(diag::err_drv_clang_unsupported)
 << (std::string(XRayInstrumentOption) + " on " + Triple.str());
   }
+else if (Triple.getOS() == llvm::Triple::Darwin)
+  // Experimental support for macos.
+  switch (Triple.getArch()) {
+  case llvm::Triple::x86_64:
+break;
+  default:
+D.Diag(diag::err_drv_clang_unsupported)
+<< (std::string(XRayInstrumentOption) + " on " + Triple.str());
+  }
 else
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on non-Linux target OS");


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314194 - [XRay] Avoid actual linking when testing the driver

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 21:29:25 2017
New Revision: 314194

URL: http://llvm.org/viewvc/llvm-project?rev=314194=rev
Log:
[XRay] Avoid actual linking when testing the driver

Use -### in the command to see just look for the output of -v.

Follow-up to D38226.

Modified:
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp

Modified: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314194=314193=314194=diff
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp Mon Sep 25 21:29:25 2017
@@ -1,9 +1,9 @@
-// RUN: %clangxx -shared -o /dev/null -v -fxray-instrument %s
-// RUN: %clangxx -shared -o /dev/null -v -fxray-instrument %s 2>&1 | \
+// RUN: %clangxx -shared -o /dev/null -v -fxray-instrument %s -###
+// RUN: %clangxx -shared -o /dev/null -v -fxray-instrument %s -### 2>&1 | \
 // RUN: FileCheck %s --check-prefix=SHARED
-// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s -DMAIN
-// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
-// RUN: FileCheck %s --check-prefix=STATIC
+// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s -### -DMAIN
+// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s -### 2>&1 -DMAIN 
\
+// RUN: | FileCheck %s --check-prefix=STATIC
 //
 // SHARED-NOT: {{clang_rt\.xray-}}
 // STATIC: {{clang_rt\.xray-}}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314193 - [XRay] Run command once without piping to FileCheck

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 21:17:37 2017
New Revision: 314193

URL: http://llvm.org/viewvc/llvm-project?rev=314193=rev
Log:
[XRay] Run command once without piping to FileCheck

This allows us to debug the failures that come up from the build bots.

Follow-up to D38226.

Modified:
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp

Modified: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314193=314192=314193=diff
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp Mon Sep 25 21:17:37 2017
@@ -1,5 +1,7 @@
+// RUN: %clangxx -shared -o /dev/null -v -fxray-instrument %s
 // RUN: %clangxx -shared -o /dev/null -v -fxray-instrument %s 2>&1 | \
 // RUN: FileCheck %s --check-prefix=SHARED
+// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s -DMAIN
 // RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
 // RUN: FileCheck %s --check-prefix=STATIC
 //


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314191 - [XRay] Only run shared tests when 'enable_shared' is true

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 21:07:45 2017
New Revision: 314191

URL: http://llvm.org/viewvc/llvm-project?rev=314191=rev
Log:
[XRay] Only run shared tests when 'enable_shared' is true

Follow-up to D38226.

Modified:
cfe/trunk/test/Driver/XRay/lit.local.cfg
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp

Modified: cfe/trunk/test/Driver/XRay/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/lit.local.cfg?rev=314191=314190=314191=diff
==
--- cfe/trunk/test/Driver/XRay/lit.local.cfg (original)
+++ cfe/trunk/test/Driver/XRay/lit.local.cfg Mon Sep 25 21:07:45 2017
@@ -19,3 +19,6 @@ if len(triple_set.intersection(supported
 # Do not run for 'android' despite being linux.
 if len(triple_set.intersection(supported_oses)) == 0 or 'android' in 
triple_set:
   config.unsupported = True
+
+if config.enable_shared:
+  config.available_features.update(['enable_shared'])

Modified: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314191=314190=314191=diff
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp Mon Sep 25 21:07:45 2017
@@ -6,7 +6,7 @@
 // SHARED-NOT: {{clang_rt\.xray-}}
 // STATIC: {{clang_rt\.xray-}}
 //
-// REQUIRES: linux
+// REQUIRES: linux, enable_shared
 int foo() { return 42; }
 
 #ifdef MAIN


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314190 - [XRay] Remove -fPIC from shared build test.

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 21:00:41 2017
New Revision: 314190

URL: http://llvm.org/viewvc/llvm-project?rev=314190=rev
Log:
[XRay] Remove -fPIC from shared build test.

Follow-up to D38226.

Modified:
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp

Modified: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314190=314189=314190=diff
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp Mon Sep 25 21:00:41 2017
@@ -1,4 +1,4 @@
-// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \
+// RUN: %clangxx -shared -o /dev/null -v -fxray-instrument %s 2>&1 | \
 // RUN: FileCheck %s --check-prefix=SHARED
 // RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
 // RUN: FileCheck %s --check-prefix=STATIC


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314189 - [XRay] Stop running tests for 'amd64', and remove -fPIE from tests.

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 20:45:37 2017
New Revision: 314189

URL: http://llvm.org/viewvc/llvm-project?rev=314189=rev
Log:
[XRay] Stop running tests for 'amd64', and remove -fPIE from tests.

Follow-up to D38226.

Modified:
cfe/trunk/test/Driver/XRay/lit.local.cfg
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp

Modified: cfe/trunk/test/Driver/XRay/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/lit.local.cfg?rev=314189=314188=314189=diff
==
--- cfe/trunk/test/Driver/XRay/lit.local.cfg (original)
+++ cfe/trunk/test/Driver/XRay/lit.local.cfg Mon Sep 25 20:45:37 2017
@@ -3,8 +3,8 @@ config.available_features.update(target_
 
 # Only run the tests in platforms where XRay instrumentation is supported.
 supported_targets = [
-'amd64', 'x86_64', 'x86_64h', 'arm', 'aarch64', 'arm64', 'powerpc64le',
-'mips', 'mipsel', 'mips64', 'mips64el'
+'x86_64', 'x86_64h', 'arm', 'aarch64', 'arm64', 'powerpc64le', 'mips',
+'mipsel', 'mips64', 'mips64el'
 ]
 
 # Only on platforms we support.

Modified: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314189=314188=314189=diff
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp Mon Sep 25 20:45:37 2017
@@ -2,8 +2,6 @@
 // RUN: FileCheck %s --check-prefix=SHARED
 // RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
 // RUN: FileCheck %s --check-prefix=STATIC
-// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \
-// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC
 //
 // SHARED-NOT: {{clang_rt\.xray-}}
 // STATIC: {{clang_rt\.xray-}}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314188 - [XRay][Driver] Do not link in XRay runtime in shared libs

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 20:18:11 2017
New Revision: 314188

URL: http://llvm.org/viewvc/llvm-project?rev=314188=rev
Log:
[XRay][Driver] Do not link in XRay runtime in shared libs

Summary:
This change ensures that we don't link in the XRay runtime when building
shared libraries with clang. This doesn't prevent us from building
shared libraris tht have XRay instrumentation sleds, but it does prevent
us from linking in the static XRay runtime into a shared library.

The XRay runtime currently doesn't support dynamic registration of
instrumentation sleds in shared objects, which we'll start enabling in
the future. That work has to happen in the back-end and in the runtime.

Reviewers: rnk, pelikan

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D38226

Added:
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/XRay/lit.local.cfg

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=314188=314187=314188=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Mon Sep 25 20:18:11 2017
@@ -206,6 +206,10 @@ void tools::gcc::Linker::RenderExtraTool
 
 static bool addXRayRuntime(const ToolChain , const ArgList ,
ArgStringList ) {
+  // Do not add the XRay runtime to shared libraries.
+  if (Args.hasArg(options::OPT_shared))
+return false;
+
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-whole-archive");
@@ -213,6 +217,7 @@ static bool addXRayRuntime(const ToolCha
 CmdArgs.push_back("-no-whole-archive");
 return true;
   }
+
   return false;
 }
 

Modified: cfe/trunk/test/Driver/XRay/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/lit.local.cfg?rev=314188=314187=314188=diff
==
--- cfe/trunk/test/Driver/XRay/lit.local.cfg (original)
+++ cfe/trunk/test/Driver/XRay/lit.local.cfg Mon Sep 25 20:18:11 2017
@@ -1,2 +1,21 @@
 target_triple_components = config.target_triple.split('-')
 config.available_features.update(target_triple_components)
+
+# Only run the tests in platforms where XRay instrumentation is supported.
+supported_targets = [
+'amd64', 'x86_64', 'x86_64h', 'arm', 'aarch64', 'arm64', 'powerpc64le',
+'mips', 'mipsel', 'mips64', 'mips64el'
+]
+
+# Only on platforms we support.
+supported_oses = [
+'linux'
+]
+
+triple_set = set(target_triple_components)
+if len(triple_set.intersection(supported_targets)) == 0:
+  config.unsupported = True
+
+# Do not run for 'android' despite being linux.
+if len(triple_set.intersection(supported_oses)) == 0 or 'android' in 
triple_set:
+  config.unsupported = True

Added: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314188=auto
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (added)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp Mon Sep 25 20:18:11 2017
@@ -0,0 +1,16 @@
+// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=SHARED
+// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
+// RUN: FileCheck %s --check-prefix=STATIC
+// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \
+// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC
+//
+// SHARED-NOT: {{clang_rt\.xray-}}
+// STATIC: {{clang_rt\.xray-}}
+//
+// REQUIRES: linux
+int foo() { return 42; }
+
+#ifdef MAIN
+int main() { return foo(); }
+#endif


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314178 - Revert "[XRay][Driver] Do not link in XRay runtime in shared libs"

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 17:41:08 2017
New Revision: 314178

URL: http://llvm.org/viewvc/llvm-project?rev=314178=rev
Log:
Revert "[XRay][Driver] Do not link in XRay runtime in shared libs"

Reverts r314177.

Removed:
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=314178=314177=314178=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Mon Sep 25 17:41:08 2017
@@ -206,10 +206,6 @@ void tools::gcc::Linker::RenderExtraTool
 
 static bool addXRayRuntime(const ToolChain , const ArgList ,
ArgStringList ) {
-  // Do not add the XRay runtime to shared libraries.
-  if (Args.hasArg(options::OPT_shared))
-return false;
-
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-whole-archive");
@@ -217,7 +213,6 @@ static bool addXRayRuntime(const ToolCha
 CmdArgs.push_back("-no-whole-archive");
 return true;
   }
-
   return false;
 }
 

Removed: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314177=auto
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (removed)
@@ -1,14 +0,0 @@
-// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \
-// RUN: FileCheck %s --check-prefix=SHARED
-// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
-// RUN: FileCheck %s --check-prefix=STATIC
-// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \
-// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC
-//
-// SHARED-NOT: {{clang_rt\.xray-}}
-// STATIC: {{clang_rt\.xray-}}
-int foo() { return 42; }
-
-#ifdef MAIN
-int main() { return foo(); }
-#endif


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314177 - [XRay][Driver] Do not link in XRay runtime in shared libs

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 16:40:33 2017
New Revision: 314177

URL: http://llvm.org/viewvc/llvm-project?rev=314177=rev
Log:
[XRay][Driver] Do not link in XRay runtime in shared libs

Summary:
This change ensures that we don't link in the XRay runtime when building
shared libraries with clang. This doesn't prevent us from building
shared libraris tht have XRay instrumentation sleds, but it does prevent
us from linking in the static XRay runtime into a shared library.

The XRay runtime currently doesn't support dynamic registration of
instrumentation sleds in shared objects, which we'll start enabling in
the future. That work has to happen in the back-end and in the runtime.

Reviewers: rnk, pelikan

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D38226

Added:
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=314177=314176=314177=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Mon Sep 25 16:40:33 2017
@@ -206,6 +206,10 @@ void tools::gcc::Linker::RenderExtraTool
 
 static bool addXRayRuntime(const ToolChain , const ArgList ,
ArgStringList ) {
+  // Do not add the XRay runtime to shared libraries.
+  if (Args.hasArg(options::OPT_shared))
+return false;
+
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-whole-archive");
@@ -213,6 +217,7 @@ static bool addXRayRuntime(const ToolCha
 CmdArgs.push_back("-no-whole-archive");
 return true;
   }
+
   return false;
 }
 

Added: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314177=auto
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (added)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp Mon Sep 25 16:40:33 2017
@@ -0,0 +1,14 @@
+// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=SHARED
+// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
+// RUN: FileCheck %s --check-prefix=STATIC
+// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \
+// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC
+//
+// SHARED-NOT: {{clang_rt\.xray-}}
+// STATIC: {{clang_rt\.xray-}}
+int foo() { return 42; }
+
+#ifdef MAIN
+int main() { return foo(); }
+#endif


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r305544 - [XRay][clang] Support capturing the implicit `this` argument to C++ class member functions

2017-06-15 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Jun 15 22:22:09 2017
New Revision: 305544

URL: http://llvm.org/viewvc/llvm-project?rev=305544=rev
Log:
[XRay][clang] Support capturing the implicit `this` argument to C++ class 
member functions

Summary:
Before this change, we couldn't capture the `this` pointer that's
implicitly the first argument of class member functions. There are some
interesting things we can do with capturing even just this single
argument for zero-argument member functions.

Reviewers: rnk, pelikan

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D34052

Added:
cfe/trunk/test/Sema/xray-log-args-class.cpp
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=305544=305543=305544=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Jun 15 22:22:09 2017
@@ -313,8 +313,8 @@ static bool checkAttrMutualExclusion(Sem
 /// \returns true if IdxExpr is a valid index.
 template 
 static bool checkFunctionOrMethodParameterIndex(
-Sema , const Decl *D, const AttrInfo& Attr,
-unsigned AttrArgNum, const Expr *IdxExpr, uint64_t ) {
+Sema , const Decl *D, const AttrInfo , unsigned AttrArgNum,
+const Expr *IdxExpr, uint64_t , bool AllowImplicitThis = false) {
   assert(isFunctionOrMethodOrBlock(D));
 
   // In C++ the implicit 'this' function parameter also counts.
@@ -341,7 +341,7 @@ static bool checkFunctionOrMethodParamet
 return false;
   }
   Idx--; // Convert to zero-based.
-  if (HasImplicitThisParam) {
+  if (HasImplicitThisParam && !AllowImplicitThis) {
 if (Idx == 0) {
   S.Diag(getAttrLoc(Attr),
  diag::err_attribute_invalid_implicit_this_argument)
@@ -4604,14 +4604,16 @@ static void handleTypeTagForDatatypeAttr
 static void handleXRayLogArgsAttr(Sema , Decl *D,
   const AttributeList ) {
   uint64_t ArgCount;
+
   if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 1, Attr.getArgAsExpr(0),
-   ArgCount))
+   ArgCount,
+   true /* AllowImplicitThis*/))
 return;
 
   // ArgCount isn't a parameter index [0;n), it's a count [1;n] - hence + 1.
   D->addAttr(::new (S.Context)
- XRayLogArgsAttr(Attr.getRange(), S.Context, ++ArgCount,
- Attr.getAttributeSpellingListIndex()));
+ XRayLogArgsAttr(Attr.getRange(), S.Context, ++ArgCount,
+ Attr.getAttributeSpellingListIndex()));
 }
 
 
//===--===//

Added: cfe/trunk/test/Sema/xray-log-args-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/xray-log-args-class.cpp?rev=305544=auto
==
--- cfe/trunk/test/Sema/xray-log-args-class.cpp (added)
+++ cfe/trunk/test/Sema/xray-log-args-class.cpp Thu Jun 15 22:22:09 2017
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+
+class Class {
+  [[clang::xray_always_instrument, clang::xray_log_args(1)]] void Method();
+  [[clang::xray_log_args(-1)]] void Invalid(); // expected-error 
{{'xray_log_args' attribute parameter 1 is out of bounds}}
+  [[clang::xray_log_args("invalid")]] void InvalidStringArg(); // 
expected-error {{'xray_log_args'}}
+};


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302492 - [XRay] Add __xray_customeevent(...) as a clang-supported builtin

2017-05-08 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon May  8 19:45:40 2017
New Revision: 302492

URL: http://llvm.org/viewvc/llvm-project?rev=302492=rev
Log:
[XRay] Add __xray_customeevent(...) as a clang-supported builtin

Summary:
We define the `__xray_customeevent` builtin that gets translated to
IR calls to the correct intrinsic. The default implementation of this is
a no-op function. The codegen side of this follows the following logic:

- When `-fxray-instrument` is not provided in the driver, we elide all
calls to `__xray_customevent`.
- When `-fxray-instrument` is enabled and a function is marked as "never
instrumented", we elide all calls to `__xray_customevent` in that
function; if either marked as "always instrumented" or subject to
threshold-based instrumentation, we emit a call to the
`llvm.xray.customevent` intrinsic from LLVM for each
`__xray_customevent` occurrence in the function.

This change depends on D27503 (to land in LLVM first).

Reviewers: echristo, rsmith

Subscribers: mehdi_amini, pelikan, lrl, cfe-commits

Differential Revision: https://reviews.llvm.org/D30018

Added:
cfe/trunk/test/CodeGen/xray-customevent.cpp
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=302492=302491=302492=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Mon May  8 19:45:40 2017
@@ -1409,6 +1409,9 @@ LANGBUILTIN(to_private, "v*v*", "tn", OC
 BUILTIN(__builtin_os_log_format_buffer_size, "zcC*.", "p:0:nut")
 BUILTIN(__builtin_os_log_format, "v*v*cC*.", "p:0:nt")
 
+// Builtins for XRay
+BUILTIN(__xray_customevent, "vcC*z", "")
+
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=302492=302491=302492=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon May  8 19:45:40 2017
@@ -2769,6 +2769,32 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 return RValue::get(ConstantInt::get(ConvertType(E->getType()),
 Layout.size().getQuantity()));
   }
+
+  case Builtin::BI__xray_customevent: {
+if (!ShouldXRayInstrumentFunction())
+  return RValue::getIgnored();
+if (const auto *XRayAttr = CurFuncDecl->getAttr()) {
+  if (XRayAttr->neverXRayInstrument())
+return RValue::getIgnored();
+}
+Function *F = CGM.getIntrinsic(Intrinsic::xray_customevent);
+auto FTy = F->getFunctionType();
+auto Arg0 = E->getArg(0);
+auto Arg0Val = EmitScalarExpr(Arg0);
+auto Arg0Ty = Arg0->getType();
+auto PTy0 = FTy->getParamType(0);
+if (PTy0 != Arg0Val->getType()) {
+  if (Arg0Ty->isArrayType())
+Arg0Val = EmitArrayToPointerDecay(Arg0).getPointer();
+  else
+Arg0Val = Builder.CreatePointerCast(Arg0Val, PTy0);
+}
+auto Arg1 = EmitScalarExpr(E->getArg(1));
+auto PTy1 = FTy->getParamType(1);
+if (PTy1 != Arg1->getType())
+  Arg1 = Builder.CreateTruncOrBitCast(Arg1, PTy1);
+return RValue::get(Builder.CreateCall(F, {Arg0Val, Arg1}));
+  }
   }
 
   // If this is an alias for a lib function (e.g. __builtin_sin), emit

Added: cfe/trunk/test/CodeGen/xray-customevent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-customevent.cpp?rev=302492=auto
==
--- cfe/trunk/test/CodeGen/xray-customevent.cpp (added)
+++ cfe/trunk/test/CodeGen/xray-customevent.cpp Mon May  8 19:45:40 2017
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @_Z16alwaysInstrumentv
+[[clang::xray_always_instrument]] void alwaysInstrument() {
+  static constexpr char kPhase[] = "instrument";
+  __xray_customevent(kPhase, 10);
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i32 10)
+}
+
+// CHECK-LABEL: @_Z15neverInstrumentv
+[[clang::xray_never_instrument]] void neverInstrument() {
+  static constexpr char kPhase[] = "never";
+  __xray_customevent(kPhase, 5);
+  // CHECK-NOT: call void @llvm.xray.customevent(i8*{{.*}}, i32 5)
+}
+
+// CHECK-LABEL: @_Z21conditionalInstrumenti
+[[clang::xray_always_instrument]] void conditionalInstrument(int v) {
+  static constexpr char kTrue[] = "true";
+  static constexpr char kUntrue[] = "untrue";
+  if (v % 2)
+__xray_customevent(kTrue, 4);
+  else
+__xray_customevent(kUntrue, 6);
+
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i32 4)
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i32 6)
+}



r299127 - fixup: use CHECK for non-atttribute sets

2017-03-30 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Mar 30 17:46:49 2017
New Revision: 299127

URL: http://llvm.org/viewvc/llvm-project?rev=299127=rev
Log:
fixup: use CHECK for non-atttribute sets

Modified:
cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp

Modified: cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp?rev=299127=299126=299127=diff
==
--- cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp (original)
+++ cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp Thu Mar 30 17:46:49 
2017
@@ -8,7 +8,7 @@ int foo() {
   return 2;
 }
 
-// CHECK-DAG: define i32 @_Z3foov() #[[THRESHOLD:[0-9]+]] {
-// CHECK-DAG: define i32 @_Z3barv() #[[NEVERATTR:[0-9]+]] {
+// CHECK: define i32 @_Z3foov() #[[THRESHOLD:[0-9]+]] {
+// CHECK: define i32 @_Z3barv() #[[NEVERATTR:[0-9]+]] {
 // CHECK-DAG: attributes #[[THRESHOLD]] = {{.*}} 
"xray-instruction-threshold"="1" {{.*}}
 // CHECK-DAG: attributes #[[NEVERATTR]] = {{.*}} 
"function-instrument"="xray-never" {{.*}}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r299126 - [XRay][clang] Fix the -fxray-instruction-threshold flag processing

2017-03-30 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Mar 30 17:46:45 2017
New Revision: 299126

URL: http://llvm.org/viewvc/llvm-project?rev=299126=rev
Log:
[XRay][clang] Fix the -fxray-instruction-threshold flag processing

Summary:
The refactoring introduced a regression in the flag processing for
-fxray-instruction-threshold which causes it to not get passed properly.
This change should restore the previous behaviour.

Reviewers: rnk, pelikan

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D31491

Added:
cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp
Modified:
cfe/trunk/lib/Driver/XRayArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=299126=299125=299126=diff
==
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Thu Mar 30 17:46:45 2017
@@ -16,8 +16,8 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/SpecialCaseList.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/SpecialCaseList.h"
 
 using namespace clang;
 using namespace clang::driver;
@@ -91,8 +91,8 @@ void XRayArgs::addArgs(const ToolChain &
 return;
 
   CmdArgs.push_back(XRayInstrumentOption);
-  CmdArgs.push_back(Args.MakeArgString(XRayInstructionThresholdOption +
-   llvm::to_string(InstructionThreshold)));
+  CmdArgs.push_back(Args.MakeArgString(Twine(XRayInstructionThresholdOption) +
+   Twine(InstructionThreshold)));
 
   for (const auto  : AlwaysInstrumentFiles) {
 SmallString<64> AlwaysInstrumentOpt(XRayAlwaysInstrumentOption);

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=299126=299125=299126=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Mar 30 17:46:45 2017
@@ -721,7 +721,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
   Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
   Opts.XRayInstructionThreshold =
-  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.CallFEntry = Args.hasArg(OPT_mfentry);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
@@ -2308,9 +2308,11 @@ static void ParseLangArgs(LangOptions 
   getLastArgIntValue(Args, OPT_fsanitize_address_field_padding, 0, Diags);
   Opts.SanitizerBlacklistFiles = Args.getAllArgValues(OPT_fsanitize_blacklist);
 
-  // -fxray-{always,never}-instrument= filenames.
+  // -fxray-instrument
   Opts.XRayInstrument =
   Args.hasFlag(OPT_fxray_instrument, OPT_fnoxray_instrument, false);
+
+  // -fxray-{always,never}-instrument= filenames.
   Opts.XRayAlwaysInstrumentFiles =
   Args.getAllArgValues(OPT_fxray_always_instrument);
   Opts.XRayNeverInstrumentFiles =

Added: cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp?rev=299126=auto
==
--- cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp (added)
+++ cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp Thu Mar 30 17:46:45 
2017
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fxray-instrument -fxray-instruction-threshold=1 -x c++ 
-std=c++11 -emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+int foo() {
+  return 1;
+}
+
+[[clang::xray_never_instrument]] int bar() {
+  return 2;
+}
+
+// CHECK-DAG: define i32 @_Z3foov() #[[THRESHOLD:[0-9]+]] {
+// CHECK-DAG: define i32 @_Z3barv() #[[NEVERATTR:[0-9]+]] {
+// CHECK-DAG: attributes #[[THRESHOLD]] = {{.*}} 
"xray-instruction-threshold"="1" {{.*}}
+// CHECK-DAG: attributes #[[NEVERATTR]] = {{.*}} 
"function-instrument"="xray-never" {{.*}}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D30388: [XRay] Add -fxray-{always,never}-instrument= flags to clang

2017-03-29 Thread Dean Michael Berris via cfe-commits
Fix committed in r299044.

On Thu, Mar 30, 2017 at 12:12 PM Dean Michael Berris 
wrote:

> Oops, thanks -- yes, I'll make that change now.
>
> On Thu, Mar 30, 2017 at 12:03 PM Andrew Ford via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
> andrewford added a comment.
>
> Hi, this breaks the android build due to use of std::to_string.
> llvm::to_string should be used instead.  I would fix it myself, but don't
> have commit access.  Thanks in advance!
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D30388
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r299044 - [XRay][clang] Use llvm::to_string instead of std::string

2017-03-29 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Wed Mar 29 20:05:09 2017
New Revision: 299044

URL: http://llvm.org/viewvc/llvm-project?rev=299044=rev
Log:
[XRay][clang] Use llvm::to_string instead of std::string

This should unbreak some bots.

Follow-up on D30388.

Modified:
cfe/trunk/lib/Driver/XRayArgs.cpp

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=299044=299043=299044=diff
==
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Wed Mar 29 20:05:09 2017
@@ -17,6 +17,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/SpecialCaseList.h"
+#include "llvm/Support/ScopedPrinter.h"
 
 using namespace clang;
 using namespace clang::driver;
@@ -91,7 +92,7 @@ void XRayArgs::addArgs(const ToolChain &
 
   CmdArgs.push_back(XRayInstrumentOption);
   CmdArgs.push_back(Args.MakeArgString(XRayInstructionThresholdOption +
-   std::to_string(InstructionThreshold)));
+   llvm::to_string(InstructionThreshold)));
 
   for (const auto  : AlwaysInstrumentFiles) {
 SmallString<64> AlwaysInstrumentOpt(XRayAlwaysInstrumentOption);


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D30388: [XRay] Add -fxray-{always,never}-instrument= flags to clang

2017-03-29 Thread Dean Michael Berris via cfe-commits
Oops, thanks -- yes, I'll make that change now.

On Thu, Mar 30, 2017 at 12:03 PM Andrew Ford via Phabricator <
revi...@reviews.llvm.org> wrote:

> andrewford added a comment.
>
> Hi, this breaks the android build due to use of std::to_string.
> llvm::to_string should be used instead.  I would fix it myself, but don't
> have commit access.  Thanks in advance!
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D30388
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r299041 - [XRay] Add -fxray-{always, never}-instrument= flags to clang

2017-03-29 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Wed Mar 29 19:29:36 2017
New Revision: 299041

URL: http://llvm.org/viewvc/llvm-project?rev=299041=rev
Log:
[XRay] Add -fxray-{always,never}-instrument= flags to clang

Summary:
The -fxray-always-instrument= and -fxray-never-instrument= flags take
filenames that are used to imbue the XRay instrumentation attributes
using a whitelist mechanism (similar to the sanitizer special cases
list). We use the same syntax and semantics as the sanitizer blacklists
files in the implementation.

As implemented, we respect the attributes that are already defined in
the source file (i.e. those that have the
[[clang::xray_{always,never}_instrument]] attributes) before applying
the always/never instrument lists.

Reviewers: rsmith, chandlerc

Subscribers: jfb, mgorny, cfe-commits

Differential Revision: https://reviews.llvm.org/D30388

Added:
cfe/trunk/include/clang/Basic/XRayLists.h
cfe/trunk/include/clang/Driver/XRayArgs.h
cfe/trunk/lib/Basic/XRayLists.cpp
cfe/trunk/lib/Driver/XRayArgs.cpp
cfe/trunk/test/CodeGen/xray-always-instrument.cpp
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Basic/CMakeLists.txt
cfe/trunk/lib/Basic/LangOptions.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/Driver/CMakeLists.txt
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=299041=299040=299041=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Mar 29 19:29:36 2017
@@ -39,6 +39,7 @@
 #include "clang/Basic/SanitizerBlacklist.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
+#include "clang/Basic/XRayLists.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
@@ -475,6 +476,10 @@ private:
   /// entities should not be instrumented.
   std::unique_ptr SanitizerBL;
 
+  /// \breif Function filtering mehcanism to determine whether a given function
+  /// should be imbued with the XRay "always" or "never" attributes.
+  std::unique_ptr XRayFilter;
+
   /// \brief The allocator used to create AST objects.
   ///
   /// AST objects are never destructed; rather, all memory associated with the
@@ -657,6 +662,10 @@ public:
 return *SanitizerBL;
   }
 
+  const XRayFunctionFilter () const {
+return *XRayFilter;
+  }
+
   DiagnosticsEngine () const;
 
   FullSourceLoc getFullLoc(SourceLocation Loc) const {

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=299041=299040=299041=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Wed Mar 29 19:29:36 2017
@@ -263,6 +263,8 @@ LANGOPT(SanitizeAddressFieldPadding, 2,
"field padding (0: none, 1:least "
"aggressive, 2: more aggressive)")
 
+LANGOPT(XRayInstrument, 1, 0, "controls whether to do XRay instrumentation")
+
 #undef LANGOPT
 #undef COMPATIBLE_LANGOPT
 #undef BENIGN_LANGOPT

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=299041=299040=299041=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Wed Mar 29 19:29:36 2017
@@ -102,6 +102,16 @@ public:
   /// (files, functions, variables) should not be instrumented.
   std::vector SanitizerBlacklistFiles;
 
+  /// \brief Paths to the XRay "always instrument" files specifying which
+  /// objects (files, functions, variables) should be imbued with the XRay
+  /// "always instrument" attribute.
+  std::vector XRayAlwaysInstrumentFiles;
+
+  /// \brief Paths to the XRay "never instrument" files specifying which
+  /// objects (files, functions, variables) should be imbued with the XRay
+  /// "never instrument" attribute.
+  std::vector XRayNeverInstrumentFiles;
+
   clang::ObjCRuntime ObjCRuntime;
 
   std::string ObjCConstantStringClass;

Added: cfe/trunk/include/clang/Basic/XRayLists.h
URL: 

Re: r298976 - [OpenCL] Added parsing for OpenCL vector types.

2017-03-28 Thread Dean Michael Berris via cfe-commits
Thanks Egor!

On Wed, Mar 29, 2017 at 4:51 PM Egor Churaev  wrote:

> I see it. I'm reverting this patch and I'll investigate why it has happend.
>
> 2017-03-29 8:43 GMT+03:00 Dean Michael Berris :
>
> This seems to have broken multiple builds.
>
> On Wed, Mar 29, 2017 at 4:20 PM Egor Churaev via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: echuraev
> Date: Wed Mar 29 00:08:18 2017
> New Revision: 298976
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298976=rev
> Log:
> [OpenCL] Added parsing for OpenCL vector types.
>
> Reviewers: cfe-commits, Anastasia
>
> Reviewed By: Anastasia
>
> Subscribers: yaxunl, bader
>
> Differential Revision: https://reviews.llvm.org/D31183
>
> Added:
> cfe/trunk/test/Parser/vector-cast-define.cl
> Modified:
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/lib/Parse/ParseExpr.cpp
>
> Modified: cfe/trunk/include/clang/Parse/Parser.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=298976=298975=298976=diff
>
> ==
> --- cfe/trunk/include/clang/Parse/Parser.h (original)
> +++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 29 00:08:18 2017
> @@ -1449,10 +1449,12 @@ private:
>ExprResult ParseCastExpression(bool isUnaryExpression,
>   bool isAddressOfOperand,
>   bool ,
> - TypeCastState isTypeCast);
> + TypeCastState isTypeCast,
> + bool isVectorLiteral = false);
>ExprResult ParseCastExpression(bool isUnaryExpression,
>   bool isAddressOfOperand = false,
> - TypeCastState isTypeCast = NotTypeCast);
> + TypeCastState isTypeCast = NotTypeCast,
> + bool isVectorLiteral = false);
>
>/// Returns true if the next token cannot start an expression.
>bool isNotExpressionStart();
>
> Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=298976=298975=298976=diff
>
> ==
> --- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Mar 29 00:08:18 2017
> @@ -473,12 +473,14 @@ Parser::ParseRHSOfBinaryExpression(ExprR
>  ///
>  ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
> bool isAddressOfOperand,
> -   TypeCastState isTypeCast) {
> +   TypeCastState isTypeCast,
> +   bool isVectorLiteral) {
>bool NotCastExpr;
>ExprResult Res = ParseCastExpression(isUnaryExpression,
> isAddressOfOperand,
> NotCastExpr,
> -   isTypeCast);
> +   isTypeCast,
> +   isVectorLiteral);
>if (NotCastExpr)
>  Diag(Tok, diag::err_expected_expression);
>return Res;
> @@ -694,7 +696,8 @@ class CastExpressionIdValidator : public
>  ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
> bool isAddressOfOperand,
> bool ,
> -   TypeCastState isTypeCast) {
> +   TypeCastState isTypeCast,
> +   bool isVectorLiteral) {
>ExprResult Res;
>tok::TokenKind SavedKind = Tok.getKind();
>NotCastExpr = false;
> @@ -722,6 +725,9 @@ ExprResult Parser::ParseCastExpression(b
>  Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/,
> isTypeCast == IsTypeCast, CastTy,
> RParenLoc);
>
> +if (isVectorLiteral)
> +return Res;
> +
>  switch (ParenExprType) {
>  case SimpleExpr:   break;// Nothing else to do.
>  case CompoundStmt: break;  // Nothing else to do.
> @@ -2350,6 +2356,48 @@ Parser::ParseParenExpression(ParenParseO
>  return ParseCompoundLiteralExpression(Ty.get(), OpenLoc,
> RParenLoc);
>}
>
> +  if (Tok.is(tok::l_paren)) {
> +// This could be OpenCL vector Literals
> +if (getLangOpts().OpenCL)
> +{
> +  TypeResult Ty;
> +  {
> +InMessageExpressionRAIIObject InMessage(*this, false);
> +Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo);
> +  }
> +  if(Ty.isInvalid())
> +  {
> + return ExprError();
> +  }
> +  QualType QT = Ty.get().get().getCanonicalType();
> +  if 

Re: r298976 - [OpenCL] Added parsing for OpenCL vector types.

2017-03-28 Thread Dean Michael Berris via cfe-commits
This seems to have broken multiple builds.

On Wed, Mar 29, 2017 at 4:20 PM Egor Churaev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: echuraev
> Date: Wed Mar 29 00:08:18 2017
> New Revision: 298976
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298976=rev
> Log:
> [OpenCL] Added parsing for OpenCL vector types.
>
> Reviewers: cfe-commits, Anastasia
>
> Reviewed By: Anastasia
>
> Subscribers: yaxunl, bader
>
> Differential Revision: https://reviews.llvm.org/D31183
>
> Added:
> cfe/trunk/test/Parser/vector-cast-define.cl
> Modified:
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/lib/Parse/ParseExpr.cpp
>
> Modified: cfe/trunk/include/clang/Parse/Parser.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=298976=298975=298976=diff
>
> ==
> --- cfe/trunk/include/clang/Parse/Parser.h (original)
> +++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 29 00:08:18 2017
> @@ -1449,10 +1449,12 @@ private:
>ExprResult ParseCastExpression(bool isUnaryExpression,
>   bool isAddressOfOperand,
>   bool ,
> - TypeCastState isTypeCast);
> + TypeCastState isTypeCast,
> + bool isVectorLiteral = false);
>ExprResult ParseCastExpression(bool isUnaryExpression,
>   bool isAddressOfOperand = false,
> - TypeCastState isTypeCast = NotTypeCast);
> + TypeCastState isTypeCast = NotTypeCast,
> + bool isVectorLiteral = false);
>
>/// Returns true if the next token cannot start an expression.
>bool isNotExpressionStart();
>
> Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=298976=298975=298976=diff
>
> ==
> --- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Mar 29 00:08:18 2017
> @@ -473,12 +473,14 @@ Parser::ParseRHSOfBinaryExpression(ExprR
>  ///
>  ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
> bool isAddressOfOperand,
> -   TypeCastState isTypeCast) {
> +   TypeCastState isTypeCast,
> +   bool isVectorLiteral) {
>bool NotCastExpr;
>ExprResult Res = ParseCastExpression(isUnaryExpression,
> isAddressOfOperand,
> NotCastExpr,
> -   isTypeCast);
> +   isTypeCast,
> +   isVectorLiteral);
>if (NotCastExpr)
>  Diag(Tok, diag::err_expected_expression);
>return Res;
> @@ -694,7 +696,8 @@ class CastExpressionIdValidator : public
>  ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
> bool isAddressOfOperand,
> bool ,
> -   TypeCastState isTypeCast) {
> +   TypeCastState isTypeCast,
> +   bool isVectorLiteral) {
>ExprResult Res;
>tok::TokenKind SavedKind = Tok.getKind();
>NotCastExpr = false;
> @@ -722,6 +725,9 @@ ExprResult Parser::ParseCastExpression(b
>  Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/,
> isTypeCast == IsTypeCast, CastTy,
> RParenLoc);
>
> +if (isVectorLiteral)
> +return Res;
> +
>  switch (ParenExprType) {
>  case SimpleExpr:   break;// Nothing else to do.
>  case CompoundStmt: break;  // Nothing else to do.
> @@ -2350,6 +2356,48 @@ Parser::ParseParenExpression(ParenParseO
>  return ParseCompoundLiteralExpression(Ty.get(), OpenLoc,
> RParenLoc);
>}
>
> +  if (Tok.is(tok::l_paren)) {
> +// This could be OpenCL vector Literals
> +if (getLangOpts().OpenCL)
> +{
> +  TypeResult Ty;
> +  {
> +InMessageExpressionRAIIObject InMessage(*this, false);
> +Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo);
> +  }
> +  if(Ty.isInvalid())
> +  {
> + return ExprError();
> +  }
> +  QualType QT = Ty.get().get().getCanonicalType();
> +  if (QT->isVectorType())
> +  {
> +// We parsed '(' vector-type-name ')' followed by '('
> +
> +// Parse the cast-expression that follows it next.
> +// isVectorLiteral = true will make sure we don't parse any
> +

r298835 - [XRay][clang] Remove dependency on libatomic for XRay builds

2017-03-27 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Mar 27 02:14:11 2017
New Revision: 298835

URL: http://llvm.org/viewvc/llvm-project?rev=298835=rev
Log:
[XRay][clang] Remove dependency on libatomic for XRay builds

Summary:
This change depends on D31381 where we change the implementation to use
sanitizer_common provided atomic operations library.

Fixes http://llvm.org/PR32274.

Reviewers: pelikan, dblaikie

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D31382

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=298835=298834=298835=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Mon Mar 27 02:14:11 2017
@@ -346,7 +346,6 @@ static void linkXRayRuntimeDeps(const To
   CmdArgs.push_back("-lpthread");
   CmdArgs.push_back("-lrt");
   CmdArgs.push_back("-lm");
-  CmdArgs.push_back("-latomic");
 
   if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
 CmdArgs.push_back("-ldl");


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r298670 - [XRay] Do not depend on C++ stdlib for XRay builds

2017-03-23 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Mar 23 19:20:05 2017
New Revision: 298670

URL: http://llvm.org/viewvc/llvm-project?rev=298670=rev
Log:
[XRay] Do not depend on C++ stdlib for XRay builds

Summary:
Now that XRay doesn't require a runtime dependency on a C++ standard
library, we remove that dependency from the clang linker flags.

Reviewers: saugustine, pelikan

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D31313

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=298670=298669=298670=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Thu Mar 23 19:20:05 2017
@@ -348,8 +348,6 @@ static void linkXRayRuntimeDeps(const To
   CmdArgs.push_back("-lm");
   CmdArgs.push_back("-latomic");
 
-  TC.AddCXXStdlibLibArgs(Args, CmdArgs);
-
   if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
 CmdArgs.push_back("-ldl");
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296999 - [XRay] [clang] Allow logging the first argument of a function call.

2017-03-05 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Mar  6 01:08:21 2017
New Revision: 296999

URL: http://llvm.org/viewvc/llvm-project?rev=296999=rev
Log:
[XRay] [clang] Allow logging the first argument of a function call.

Summary:
Functions with the "xray_log_args" attribute will tell LLVM to emit a special
XRay sled for compiler-rt to copy any call arguments to your logging handler.

Reviewers: dberris

Reviewed By: dberris

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D29704

Added:
cfe/trunk/test/CodeGen/xray-log-args.cpp
cfe/trunk/test/Sema/xray-log-args-oob.c
cfe/trunk/test/Sema/xray-log-args-oob.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=296999=296998=296999=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Mar  6 01:08:21 2017
@@ -450,6 +450,15 @@ def XRayInstrument : InheritableAttr {
   let Documentation = [XRayDocs];
 }
 
+def XRayLogArgs : InheritableAttr {
+  let Spellings = [GNU<"xray_log_args">, CXX11<"clang", "xray_log_args">];
+  let Subjects = SubjectList<
+  [CXXMethod, ObjCMethod, Function], WarnDiag, "ExpectedFunctionOrMethod"
+  >;
+  let Args = [UnsignedArgument<"ArgumentCount">];
+  let Documentation = [XRayDocs];
+}
+
 def TLSModel : InheritableAttr {
   let Spellings = [GCC<"tls_model">];
   let Subjects = SubjectList<[TLSVar], ErrorDiag, "ExpectedTLSVar">;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=296999=296998=296999=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Mar  6 01:08:21 2017
@@ -2862,13 +2862,15 @@ See the RenderScript_ documentation for
 
 def XRayDocs : Documentation {
   let Category = DocCatFunction;
-  let Heading = "xray_always_instrument (clang::xray_always_instrument), 
xray_never_instrument (clang::xray_never_instrument)";
+  let Heading = "xray_always_instrument (clang::xray_always_instrument), 
xray_never_instrument (clang::xray_never_instrument), xray_log_args 
(clang::xray_log_args)";
   let Content = [{
 ``__attribute__((xray_always_instrument))`` or 
``[[clang::xray_always_instrument]]`` is used to mark member functions (in 
C++), methods (in Objective C), and free functions (in C, C++, and Objective C) 
to be instrumented with XRay. This will cause the function to always have space 
at the beginning and exit points to allow for runtime patching.
 
 Conversely, ``__attribute__((xray_never_instrument))`` or 
``[[clang::xray_never_instrument]]`` will inhibit the insertion of these 
instrumentation points.
 
 If a function has neither of these attributes, they become subject to the XRay 
heuristics used to determine whether a function should be instrumented or 
otherwise.
+
+``__attribute__((xray_log_args(N)))`` or ``[[clang::xray_log_args(N)]]`` is 
used to preserve N function arguments for the logging function.  Currently, 
only N==1 is supported.
   }];
 }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=296999=296998=296999=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Mon Mar  6 01:08:21 2017
@@ -779,6 +779,10 @@ void CodeGenFunction::StartFunction(Glob
 Fn->addFnAttr("function-instrument", "xray-always");
   if (XRayAttr->neverXRayInstrument())
 Fn->addFnAttr("function-instrument", "xray-never");
+  if (const auto *LogArgs = D->getAttr()) {
+Fn->addFnAttr("xray-log-args",
+  llvm::utostr(LogArgs->getArgumentCount()));
+  }
 } else {
   Fn->addFnAttr(
   "xray-instruction-threshold",

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=296999=296998=296999=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Mar  6 01:08:21 2017
@@ -4424,6 +4424,19 @@ static void handleTypeTagForDatatypeAttr
 Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleXRayLogArgsAttr(Sema , Decl *D,
+  const AttributeList ) {
+  uint64_t ArgCount;
+  if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 1, Attr.getArgAsExpr(0),
+  

[PATCH] D26415: [XRay] Support AArch64 in Clang

2016-11-20 Thread Dean Michael Berris via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL287518: [XRay] Support AArch64 in Clang (authored by 
dberris).

Changed prior to commit:
  https://reviews.llvm.org/D26415?vs=78216=78685#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26415

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
  cfe/trunk/test/Driver/XRay/xray-instrument-os.c


Index: cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
===
--- cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
+++ cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: amd64-, x86_64-, x86_64h-, arm
+// XFAIL: amd64-, x86_64-, x86_64h-, arm, aarch64, arm64
 // REQUIRES: linux
 typedef int a;
Index: cfe/trunk/test/Driver/XRay/xray-instrument-os.c
===
--- cfe/trunk/test/Driver/XRay/xray-instrument-os.c
+++ cfe/trunk/test/Driver/XRay/xray-instrument-os.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
 // XFAIL: -linux-
-// REQUIRES-ANY: amd64, x86_64, x86_64h, arm
+// REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64
 typedef int a;
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -4900,14 +4900,20 @@
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 const char *const XRayInstrumentOption = "-fxray-instrument";
-if (Triple.getOS() == llvm::Triple::Linux &&
-(Triple.getArch() == llvm::Triple::arm ||
- Triple.getArch() == llvm::Triple::x86_64)) {
-  // Supported.
-} else {
+if (Triple.getOS() == llvm::Triple::Linux)
+  switch (Triple.getArch()) {
+  case llvm::Triple::x86_64:
+  case llvm::Triple::arm:
+  case llvm::Triple::aarch64:
+// Supported.
+break;
+  default:
+D.Diag(diag::err_drv_clang_unsupported)
+<< (std::string(XRayInstrumentOption) + " on " + Triple.str());
+  }
+else
   D.Diag(diag::err_drv_clang_unsupported)
-  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
-}
+  << (std::string(XRayInstrumentOption) + " on non-Linux target OS");
 CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,


Index: cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
===
--- cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
+++ cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: amd64-, x86_64-, x86_64h-, arm
+// XFAIL: amd64-, x86_64-, x86_64h-, arm, aarch64, arm64
 // REQUIRES: linux
 typedef int a;
Index: cfe/trunk/test/Driver/XRay/xray-instrument-os.c
===
--- cfe/trunk/test/Driver/XRay/xray-instrument-os.c
+++ cfe/trunk/test/Driver/XRay/xray-instrument-os.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
 // XFAIL: -linux-
-// REQUIRES-ANY: amd64, x86_64, x86_64h, arm
+// REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64
 typedef int a;
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -4900,14 +4900,20 @@
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 const char *const XRayInstrumentOption = "-fxray-instrument";
-if (Triple.getOS() == llvm::Triple::Linux &&
-(Triple.getArch() == llvm::Triple::arm ||
- Triple.getArch() == llvm::Triple::x86_64)) {
-  // Supported.
-} else {
+if (Triple.getOS() == llvm::Triple::Linux)
+  switch (Triple.getArch()) {
+  case llvm::Triple::x86_64:
+  case llvm::Triple::arm:
+  case llvm::Triple::aarch64:
+// Supported.
+break;
+  default:
+D.Diag(diag::err_drv_clang_unsupported)
+<< (std::string(XRayInstrumentOption) + " on " + Triple.str());
+  }
+else
   D.Diag(diag::err_drv_clang_unsupported)
-  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
-}
+  << (std::string(XRayInstrumentOption) + " on non-Linux target OS");
 CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26415: [XRay] Support AArch64 in Clang

2016-11-10 Thread Dean Michael Berris via cfe-commits
dberris added inline comments.



Comment at: lib/Driver/Tools.cpp:4903-4906
+if (Triple.getOS() != llvm::Triple::Linux)
+  D.Diag(diag::err_drv_clang_unsupported)
+  << (std::string(XRayInstrumentOption) + " on non-Linux target OS.");
+switch (Triple.getArch()) {

Did you need to put an `else` before the switch? I don't know what happens when 
you're on Windows non-supported platform -- will this cause two diagnostics to 
be printed?


https://reviews.llvm.org/D26415



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26415: [XRay] Support AArch64 in Clang

2016-11-10 Thread Dean Michael Berris via cfe-commits
dberris added inline comments.



Comment at: lib/Driver/Tools.cpp:4903-4906
 if (Triple.getOS() == llvm::Triple::Linux &&
 (Triple.getArch() == llvm::Triple::arm ||
- Triple.getArch() == llvm::Triple::x86_64)) {
+ Triple.getArch() == llvm::Triple::x86_64 ||
+ Triple.getArch() == llvm::Triple::aarch64)) {

rSerge wrote:
> dberris wrote:
> > rSerge wrote:
> > > dberris wrote:
> > > > I'm wondering whether it's worth turning this into a `switch` statement 
> > > > now that we have more than two supported architectures?
> > > I think that would lead to more awkward code: there wouldn't be a single 
> > > decision outcome point (like the current `else` block), so to avoid 
> > > duplicating the code which currently prints the message, a `bool` 
> > > variable would be needed. I think it's more neat to just enumerate all 
> > > the OS combinations in the `if` condition for now.
> > > This place is not performance-critical and the compiler should convert 
> > > appropriate `if`s into `switch`es anyway.
> > This is an issue of making it more readable, something like:
> > 
> > ```
> > if (Triple.getOS() != llvm::Triple::Linux)
> >   D.Diag(...) << ...; // Unsupported OS.
> > switch (Triple.getArch()) {
> >   case llvm::Triple::arm:
> >   case llvm::Triple::x86_64:
> >   case llvm::Tripe::aarch64:
> > // Supported.
> > break;
> >   default:
> > D.Diag(...) << ...;
> > }
> > ```
> > 
> > This way any new architectures become supported, they just get added to the 
> > list of cases that short-circuit.
> We can't say that an OS is supported or unsupported unless all CPU 
> architectures for this OS support or don't support XRay, and this is not 
> going to happen in the near future. So it is more accurate to say about the 
> triple: some triples are supported and some are not. So in coding it is 
> natural to check for the triple with `||` and `&&`.
> We can't say that an OS is supported or unsupported unless all CPU 
> architectures for this OS support or don't support XRay, and this is not 
> going to happen in the near future.

I don't get it. Right now, as written, it doesn't matter what OS it is -- any 
OS other than Linux wouldn't be supported anyway. Maybe I mis-wrote, but:

```
if (Triple.getOS() != llvm::Triple::Linux)
  D.Diag(...) << ...;
else switch(Triple.getArch()) {
  ...
  default:
D.Diag(...) << ...;
}
```

Is a direct translation that's more readable than the current complex if 
statement conditional.

> So it is more accurate to say about the triple: some triples are supported 
> and some are not. So in coding it is natural to check for the triple with || 
> and &&.

Sure, but conditional is already unwieldy with just three supported platforms.


https://reviews.llvm.org/D26415



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26415: [XRay] Support AArch64 in Clang

2016-11-09 Thread Dean Michael Berris via cfe-commits
dberris added inline comments.



Comment at: lib/Driver/Tools.cpp:4903-4906
 if (Triple.getOS() == llvm::Triple::Linux &&
 (Triple.getArch() == llvm::Triple::arm ||
- Triple.getArch() == llvm::Triple::x86_64)) {
+ Triple.getArch() == llvm::Triple::x86_64 ||
+ Triple.getArch() == llvm::Triple::aarch64)) {

rSerge wrote:
> dberris wrote:
> > I'm wondering whether it's worth turning this into a `switch` statement now 
> > that we have more than two supported architectures?
> I think that would lead to more awkward code: there wouldn't be a single 
> decision outcome point (like the current `else` block), so to avoid 
> duplicating the code which currently prints the message, a `bool` variable 
> would be needed. I think it's more neat to just enumerate all the OS 
> combinations in the `if` condition for now.
> This place is not performance-critical and the compiler should convert 
> appropriate `if`s into `switch`es anyway.
This is an issue of making it more readable, something like:

```
if (Triple.getOS() != llvm::Triple::Linux)
  D.Diag(...) << ...; // Unsupported OS.
switch (Triple.getArch()) {
  case llvm::Triple::arm:
  case llvm::Triple::x86_64:
  case llvm::Tripe::aarch64:
// Supported.
break;
  default:
D.Diag(...) << ...;
}
```

This way any new architectures become supported, they just get added to the 
list of cases that short-circuit.


https://reviews.llvm.org/D26415



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-27 Thread Dean Michael Berris via cfe-commits
dberris added a comment.

It was in the .cpp file, and was mostly trailing whitespace. This is what I did:

  curl 
https://reviews.llvm.org/file/data/d72xn56ybspvx3ovex36/PHID-FILE-vzd63mvia62eq7e32iho/D24799.diff
 | git apply - -p0 --whitespace=fix

And I got the following:

  :6: trailing whitespace.
  
  :7: trailing whitespace.
if (Args.hasFlag(options::OPT_fxray_instrument,
  :8: trailing whitespace.
 options::OPT_fnoxray_instrument, false)) {
  :10: trailing whitespace.
  const char *const XRayInstrumentOption = "-fxray-instrument";
  :11: trailing whitespace.
  if (Triple.getOS() == llvm::Triple::Linux &&


Repository:
  rL LLVM

https://reviews.llvm.org/D24799



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26024: [Xray] Don't generate output for xray tests

2016-10-27 Thread Dean Michael Berris via cfe-commits
dberris accepted this revision.
dberris added a comment.

Yes, thanks (and sorry for missing this).


https://reviews.llvm.org/D26024



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-26 Thread Dean Michael Berris via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285266: [XRay] Check in Clang whether XRay supports the 
target when -fxray-instrument… (authored by dberris).

Changed prior to commit:
  https://reviews.llvm.org/D24799?vs=75452=75980#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24799

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/XRay/lit.local.cfg
  cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
  cfe/trunk/test/Driver/XRay/xray-instrument-os.c


Index: cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
===
--- cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
+++ cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
@@ -0,0 +1,4 @@
+// RUN: not %clang -v -fxray-instrument -c %s
+// XFAIL: amd64-, x86_64-, x86_64h-, arm
+// REQUIRES: linux
+typedef int a;
Index: cfe/trunk/test/Driver/XRay/lit.local.cfg
===
--- cfe/trunk/test/Driver/XRay/lit.local.cfg
+++ cfe/trunk/test/Driver/XRay/lit.local.cfg
@@ -0,0 +1,2 @@
+target_triple_components = config.target_triple.split('-')
+config.available_features.update(target_triple_components)
Index: cfe/trunk/test/Driver/XRay/xray-instrument-os.c
===
--- cfe/trunk/test/Driver/XRay/xray-instrument-os.c
+++ cfe/trunk/test/Driver/XRay/xray-instrument-os.c
@@ -0,0 +1,4 @@
+// RUN: not %clang -v -fxray-instrument -c %s
+// XFAIL: -linux-
+// REQUIRES-ANY: amd64, x86_64, x86_64h, arm
+typedef int a;
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -4810,7 +4810,16 @@
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
+const char *const XRayInstrumentOption = "-fxray-instrument";
+if (Triple.getOS() == llvm::Triple::Linux &&
+(Triple.getArch() == llvm::Triple::arm ||
+ Triple.getArch() == llvm::Triple::x86_64)) {
+  // Supported.
+} else {
+  D.Diag(diag::err_drv_clang_unsupported)
+  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
+}
+CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {


Index: cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
===
--- cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
+++ cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
@@ -0,0 +1,4 @@
+// RUN: not %clang -v -fxray-instrument -c %s
+// XFAIL: amd64-, x86_64-, x86_64h-, arm
+// REQUIRES: linux
+typedef int a;
Index: cfe/trunk/test/Driver/XRay/lit.local.cfg
===
--- cfe/trunk/test/Driver/XRay/lit.local.cfg
+++ cfe/trunk/test/Driver/XRay/lit.local.cfg
@@ -0,0 +1,2 @@
+target_triple_components = config.target_triple.split('-')
+config.available_features.update(target_triple_components)
Index: cfe/trunk/test/Driver/XRay/xray-instrument-os.c
===
--- cfe/trunk/test/Driver/XRay/xray-instrument-os.c
+++ cfe/trunk/test/Driver/XRay/xray-instrument-os.c
@@ -0,0 +1,4 @@
+// RUN: not %clang -v -fxray-instrument -c %s
+// XFAIL: -linux-
+// REQUIRES-ANY: amd64, x86_64, x86_64h, arm
+typedef int a;
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -4810,7 +4810,16 @@
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
+const char *const XRayInstrumentOption = "-fxray-instrument";
+if (Triple.getOS() == llvm::Triple::Linux &&
+(Triple.getArch() == llvm::Triple::arm ||
+ Triple.getArch() == llvm::Triple::x86_64)) {
+  // Supported.
+} else {
+  D.Diag(diag::err_drv_clang_unsupported)
+  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
+}
+CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285266 - [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-26 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Wed Oct 26 23:56:14 2016
New Revision: 285266

URL: http://llvm.org/viewvc/llvm-project?rev=285266=rev
Log:
[XRay] Check in Clang whether XRay supports the target when -fxray-instrument 
is passed

Summary:
Added the code which explicitly emits an error in Clang in case
`-fxray-instrument` is passed, but XRay is not supported for the
selected target.

Reviewers: rsmith, aaron.ballman, rnk, dberris

Differential Revision: https://reviews.llvm.org/D24799

Added:
cfe/trunk/test/Driver/XRay/
cfe/trunk/test/Driver/XRay/lit.local.cfg
cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
cfe/trunk/test/Driver/XRay/xray-instrument-os.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=285266=285265=285266=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Oct 26 23:56:14 2016
@@ -4810,7 +4810,16 @@ void Clang::ConstructJob(Compilation ,
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
+const char *const XRayInstrumentOption = "-fxray-instrument";
+if (Triple.getOS() == llvm::Triple::Linux &&
+(Triple.getArch() == llvm::Triple::arm ||
+ Triple.getArch() == llvm::Triple::x86_64)) {
+  // Supported.
+} else {
+  D.Diag(diag::err_drv_clang_unsupported)
+  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
+}
+CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {

Added: cfe/trunk/test/Driver/XRay/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/lit.local.cfg?rev=285266=auto
==
--- cfe/trunk/test/Driver/XRay/lit.local.cfg (added)
+++ cfe/trunk/test/Driver/XRay/lit.local.cfg Wed Oct 26 23:56:14 2016
@@ -0,0 +1,2 @@
+target_triple_components = config.target_triple.split('-')
+config.available_features.update(target_triple_components)

Added: cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c?rev=285266=auto
==
--- cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c (added)
+++ cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c Wed Oct 26 23:56:14 2016
@@ -0,0 +1,4 @@
+// RUN: not %clang -v -fxray-instrument -c %s
+// XFAIL: amd64-, x86_64-, x86_64h-, arm
+// REQUIRES: linux
+typedef int a;

Added: cfe/trunk/test/Driver/XRay/xray-instrument-os.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-instrument-os.c?rev=285266=auto
==
--- cfe/trunk/test/Driver/XRay/xray-instrument-os.c (added)
+++ cfe/trunk/test/Driver/XRay/xray-instrument-os.c Wed Oct 26 23:56:14 2016
@@ -0,0 +1,4 @@
+// RUN: not %clang -v -fxray-instrument -c %s
+// XFAIL: -linux-
+// REQUIRES-ANY: amd64, x86_64, x86_64h, arm
+typedef int a;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-26 Thread Dean Michael Berris via cfe-commits
dberris added a comment.

Actually I tried again, but still the patch doesn't apply cleanly through git 
(and it still complains of whitespace issues). Let me go through this manually 
again, and see whether there are still failures that come up.


https://reviews.llvm.org/D24799



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-26 Thread Dean Michael Berris via cfe-commits
dberris accepted this revision.
dberris added a comment.
This revision is now accepted and ready to land.

Thanks @rSerge -- I'll land this now.


https://reviews.llvm.org/D24799



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-17 Thread Dean Michael Berris via cfe-commits
dberris added a comment.

In https://reviews.llvm.org/D24799#566507, @rSerge wrote:

> I have extended this feature to check for OS support too (currently Linux 
> only). I can't commit it so far because I don't know how to implement a test. 
> XFAIL cannot check for both CPU and OS: it can only check for one of them. I 
> tried to implement 2 tests instead like these:
>  Test 1:
>
>   // RUN: not %clang -v -fxray-instrument -c %s
>// XFAIL: Linux
>// REQUIRES-ANY: amd64-, x86_64, x86_64h, arm
>typedef int a;
>   
>
> Test 2:
>
>   // RUN: not %clang -v -fxray-instrument -c %s
>// XFAIL: amd64-, x86_64, x86_64h, arm
>// REQUIRES: Linux
>typedef int a;
>   
>
> However the problem with REQUIRES / REQUIRES-ANY is that they only check in 
> LIT features, but not in the target triple. So everything becomes unsupported.
>
> Does anyone have any ideas on how to implement the tests for Clang checking 
> for both OS and CPU? I have 2 options in mind:
>
> 1. extend LIT, putting OS and CPU into the feature list


This should be configurable in the various `lit.site.cfg` files for Clang. I 
suspect though that just relying on the `REQUIRES` exclusively should work -- 
i.e. define a list of features that you actually require.

http://llvm.org/docs/TestingGuide.html#requires-and-requires-any-directive

> 2. implement the test via GTest, rather than LIT

Probably won't work since this is a test of the compiler, unless you had 
something more specific?


https://reviews.llvm.org/D24799



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-17 Thread Dean Michael Berris via cfe-commits
dberris added a comment.

Sorry for the delay, I had thought I pointed to some potentially helpful 
documentation. :/

BTW, did the test get removed from the latest change? I don't see it being 
added anymore.


https://reviews.llvm.org/D24799



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-10 Thread Dean Michael Berris via cfe-commits
dberris requested changes to this revision.
dberris added a comment.
This revision now requires changes to proceed.

Sorry, I forgot to update the status. I made a few more comments to make this 
part a little more readable.


https://reviews.llvm.org/D24799



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-06 Thread Dean Michael Berris via cfe-commits
dberris added inline comments.


> rSerge wrote in Tools.cpp:4787
> Is there any advantage over `const char* const` here?

This same value is turned into a string later on anyway. You can make it a 
std::string and std::move(...) it at the call to CmdArgs.push_back(...).

> rSerge wrote in Tools.cpp:4796
> It returns `StringRef`. `.str()` would construct a `std::string`, which seems 
> unnecessary.  Of course this piece is not performance-critical, but why not 
> to just use `operator+=` taking as the argument `const char* const`?

.data() doesn't necessarily have a null terminator.

Constructing a string out of successive +'s invoke move constructors on 
std::string, which makes it as efficient if not more efficient than growing a 
single string this way. At any rate it's much more readable if you did it in a 
single line.

https://reviews.llvm.org/D24799



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-06 Thread Dean Michael Berris via cfe-commits
dberris requested changes to this revision.
dberris added a comment.
This revision now requires changes to proceed.

Are we sure this will not fail on Windows? i.e. have you built/run the tests on 
Windws ARM or X86_64?



> Tools.cpp:4787
> options::OPT_fnoxray_instrument, false)) {
> -CmdArgs.push_back("-fxray-instrument");
> +const char* const XRayInstrumentOption = "-fxray-instrument";
> +switch(getToolChain().getArch()) {

Why can't this just be a `const string`, or a `const StringRef`?

> Tools.cpp:4796
> +  Feature += " on ";
> +  Feature += Triple.getArchName().data();
> +  D.Diag(diag::err_drv_clang_unsupported) << Feature;

I'm not a fan of calling `.data()` here -- if this returns a `StringRef` I'd 
much rather turn it into a string directly. Either that or you can even string 
these together. Say something like:

  default:
D.Diag(...) << (XRayInstrumentOption + " on " + Triple.getArchName().str());
break;

> Tools.cpp:4799
> +  break;
> +} }
> +CmdArgs.push_back(XRayInstrumentOption);

As part of my submitting this change upstream, I had to format it accordingly 
with `clang-format` -- you might want to do the same so that the formatting is 
in-line with the LLVM developers style guidelines.

https://reviews.llvm.org/D24799



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-04 Thread Dean Michael Berris via cfe-commits
dberris added a comment.

In https://reviews.llvm.org/D24799#561106, @rSerge wrote:

> My mistake was that initially I only enumerated the unsupported targets from 
> llvm\include\llvm\ADT\Triple.h . Now I've added also the cases from 
> llvm\lib\Support\Triple.cpp .
>  `XFAIL` requires a list of all unsupported cases, which is currently much 
> larger than the list of supported cases. However, AFAIK there is nothing like 
> `XPASS` in LIT.


I just thought about reversing this. How about if you do something like:

  // RUN: not %clang -v -fxray-instrument -c %s
  // XFAIL: x86_64-, arm7-

I suspect that would be sufficient to work as an `XPASS` of sorts?


https://reviews.llvm.org/D24799



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-04 Thread Dean Michael Berris via cfe-commits
dberris requested changes to this revision.
dberris added a subscriber: rengolin.
dberris added a comment.
This revision now requires changes to proceed.

I'm not sure whether the exhaustive list scales though... is there a better way 
of doing this? Maybe @rengolin has better ideas here?


Repository:
  rL LLVM

https://reviews.llvm.org/D24799



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-04 Thread Dean Michael Berris via cfe-commits
dberris reopened this revision.
dberris added a comment.
This revision is now accepted and ready to land.

This broke the build on i686.

   TEST 'Clang :: Driver/xray-instrument.c' FAILED 

  Script:
  --
  C:/bb-win/ninja-clang-i686-msc19-R/build/./bin/clang.EXE  -v 
-fxray-instrument -c 
C:\bb-win\ninja-clang-i686-msc19-R\llvm-project\clang\test\Driver\xray-instrument.c
  --
  Exit Code: 1
  
  Command Output (stdout):
  --
  $ "C:/bb-win/ninja-clang-i686-msc19-R/build/./bin/clang.EXE" "-v" 
"-fxray-instrument" "-c" 
"C:\bb-win\ninja-clang-i686-msc19-R\llvm-project\clang\test\Driver\xray-instrument.c"
  # command stderr:
  clang version 4.0.0 
  
  Target: i686-pc-windows-msvc
  
  Thread model: posix
  
  InstalledDir: C:\bb-win\ninja-clang-i686-msc19-R\build\bin
  
  clang.EXE: error: the clang compiler does not support '-fxray-instrument on 
i686-pc-windows-msvc19.0.23506'
  
  
  error: command failed with exit status: 1

Reverted in https://reviews.llvm.org/rL283199.


Repository:
  rL LLVM

https://reviews.llvm.org/D24799



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-04 Thread Dean Michael Berris via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283193: [XRay] Check in Clang whether XRay supports the 
target when -fxray-instrument… (authored by dberris).

Changed prior to commit:
  https://reviews.llvm.org/D24799?vs=72554=73424#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24799

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/xray-instrument.c


Index: cfe/trunk/test/Driver/xray-instrument.c
===
--- cfe/trunk/test/Driver/xray-instrument.c
+++ cfe/trunk/test/Driver/xray-instrument.c
@@ -0,0 +1,3 @@
+// RUN: %clang -v -fxray-instrument -c %s
+// XFAIL: armeb, aarch64, aarch64_be, avr, bpfel, bpfeb, hexagon, mips, 
mipsel, mips64, mips64el, msp430, ppc, ppc64, ppc64le, r600, amdgcn, sparc, 
sparcv9, sparcel, systemz, tce, thumb, thumbeb, x86-, xcore, nvptx, nvptx64, 
le32, le64, amdil, amdil64, hsail, hsail64, spir, spir64, kalimba, shave, 
lanai, wasm32, wasm64, renderscript32, renderscript64
+typedef int a;
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -4777,7 +4777,20 @@
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
+const char *const XRayInstrumentOption = "-fxray-instrument";
+switch (getToolChain().getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::x86_64:
+  break;
+default: {
+  std::string Feature(XRayInstrumentOption);
+  Feature += " on ";
+  Feature += Triple.getArchName().data();
+  D.Diag(diag::err_drv_clang_unsupported) << Feature;
+  break;
+}
+}
+CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {


Index: cfe/trunk/test/Driver/xray-instrument.c
===
--- cfe/trunk/test/Driver/xray-instrument.c
+++ cfe/trunk/test/Driver/xray-instrument.c
@@ -0,0 +1,3 @@
+// RUN: %clang -v -fxray-instrument -c %s
+// XFAIL: armeb, aarch64, aarch64_be, avr, bpfel, bpfeb, hexagon, mips, mipsel, mips64, mips64el, msp430, ppc, ppc64, ppc64le, r600, amdgcn, sparc, sparcv9, sparcel, systemz, tce, thumb, thumbeb, x86-, xcore, nvptx, nvptx64, le32, le64, amdil, amdil64, hsail, hsail64, spir, spir64, kalimba, shave, lanai, wasm32, wasm64, renderscript32, renderscript64
+typedef int a;
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -4777,7 +4777,20 @@
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
+const char *const XRayInstrumentOption = "-fxray-instrument";
+switch (getToolChain().getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::x86_64:
+  break;
+default: {
+  std::string Feature(XRayInstrumentOption);
+  Feature += " on ";
+  Feature += Triple.getArchName().data();
+  D.Diag(diag::err_drv_clang_unsupported) << Feature;
+  break;
+}
+}
+CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r283193 - [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-04 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Tue Oct  4 03:22:47 2016
New Revision: 283193

URL: http://llvm.org/viewvc/llvm-project?rev=283193=rev
Log:
[XRay] Check in Clang whether XRay supports the target when -fxray-instrument 
is passed

Added the code which explicitly emits an error in Clang in case
`-fxray-instrument` is passed, but XRay is not supported for the
selected target.

Author: rSerge

Reviewers: dberris, rsmith, aaron.ballman, rnk

Subscribers: cfe-commits, iid_iunknown

Differential Revision: https://reviews.llvm.org/D24799

Added:
cfe/trunk/test/Driver/xray-instrument.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=283193=283192=283193=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Oct  4 03:22:47 2016
@@ -4777,7 +4777,20 @@ void Clang::ConstructJob(Compilation ,
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
+const char *const XRayInstrumentOption = "-fxray-instrument";
+switch (getToolChain().getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::x86_64:
+  break;
+default: {
+  std::string Feature(XRayInstrumentOption);
+  Feature += " on ";
+  Feature += Triple.getArchName().data();
+  D.Diag(diag::err_drv_clang_unsupported) << Feature;
+  break;
+}
+}
+CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {

Added: cfe/trunk/test/Driver/xray-instrument.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/xray-instrument.c?rev=283193=auto
==
--- cfe/trunk/test/Driver/xray-instrument.c (added)
+++ cfe/trunk/test/Driver/xray-instrument.c Tue Oct  4 03:22:47 2016
@@ -0,0 +1,3 @@
+// RUN: %clang -v -fxray-instrument -c %s
+// XFAIL: armeb, aarch64, aarch64_be, avr, bpfel, bpfeb, hexagon, mips, 
mipsel, mips64, mips64el, msp430, ppc, ppc64, ppc64le, r600, amdgcn, sparc, 
sparcv9, sparcel, systemz, tce, thumb, thumbeb, x86-, xcore, nvptx, nvptx64, 
le32, le64, amdil, amdil64, hsail, hsail64, spir, spir64, kalimba, shave, 
lanai, wasm32, wasm64, renderscript32, renderscript64
+typedef int a;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-03 Thread Dean Michael Berris via cfe-commits
dberris added a comment.

In https://reviews.llvm.org/D24799#55, @rSerge wrote:

> @dberris ,  could you deliver this patch to mainline? Or do we need approval 
> from more reviewers?


Yes, I can do this -- sorry it was the long weekend for me down under. I'll get 
to this today. :)


https://reviews.llvm.org/D24799



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-09-26 Thread Dean Michael Berris via cfe-commits
dberris added inline comments.


Comment at: lib/Driver/Tools.cpp:4777-4780
@@ +4776,6 @@
+{
+  std::string Feature(XRayInstrumentOption);
+  Feature += " on ";
+  Feature += Triple.getArchName().data();
+  D.Diag(diag::err_drv_clang_unsupported) << Feature;
+  break;

Wouldn't something like this work better:

  D.Diag(...) << XRayInstrumentOption << " on " << Triple.getArchName();


https://reviews.llvm.org/D24799



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-09-22 Thread Dean Michael Berris via cfe-commits
dberris added a comment.

In https://reviews.llvm.org/D24799#549634, @rSerge wrote:

> In https://reviews.llvm.org/D24799#549442, @dberris wrote:
>
> > What does the error actually look like? Can you add a test for it? It's 
> > unclear to me how this would read... for example does it say "XRay for arm 
> > is unsupported"?
>
>
> In the attached picture you can see how the error looks when cross-compiling 
> with Clang from x86_64-Windows host to Thumb-Linux target. 
>  F2439489: Unsupported XRay target error.jpg 
> 
>  It says
>
> > clang++.exe: error: the clang compiler does not support 'XRay for 
> > armv6kz--linux-gnueabihf'
>


Thanks -- I that's really helpful.

A clearer message I think might read something like:

> the clang compiler does not support '-fxray-instrument' on 
> '-mtriple=armv6kz-linux-gnueabihf'


Even if you drop the '-mtriple=' prefix, I think that might work better than 
"XRay for".

> I'll try to add tests.


Thanks -- an XFAIL for a platform you know it should fail for should be 
sufficient, without spelling out the actual error message in the test.


https://reviews.llvm.org/D24799



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r281879 - [XRay] ARM 32-bit no-Thumb support in Clang

2016-09-18 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Sun Sep 18 19:59:19 2016
New Revision: 281879

URL: http://llvm.org/viewvc/llvm-project?rev=281879=rev
Log:
[XRay] ARM 32-bit no-Thumb support in Clang

Just a test for now, adapted from x86_64 tests of XRay.
This is one of 3 commits to different repositories of XRay ARM port. The other 
2 are:

https://reviews.llvm.org/D23931 (LLVM)
https://reviews.llvm.org/D23933 (compiler-rt)

Differential Revision: https://reviews.llvm.org/D23932

Added:
cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp

Added: cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp?rev=281879=auto
==
--- cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp (added)
+++ cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp Sun Sep 18 
19:59:19 2016
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple arm-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23932: [XRay] ARM 32-bit no-Thumb support in Clang

2016-09-18 Thread Dean Michael Berris via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281879: [XRay] ARM 32-bit no-Thumb support in Clang 
(authored by dberris).

Changed prior to commit:
  https://reviews.llvm.org/D23932?vs=71635=71765#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23932

Files:
  cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp

Index: cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
===
--- cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
+++ cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple arm-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"


Index: cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
===
--- cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
+++ cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple arm-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23932: [XRay] ARM 32-bit no-Thumb support in Clang

2016-09-08 Thread Dean Michael Berris via cfe-commits
dberris requested changes to this revision.
dberris added a comment.
This revision now requires changes to proceed.

See comments in https://reviews.llvm.org/D23931 for more details.


https://reviews.llvm.org/D23932



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23932: [XRay] ARM 32-bit no-Thumb support in Clang

2016-09-08 Thread Dean Michael Berris via cfe-commits
dberris reopened this revision.
dberris added a comment.
This revision is now accepted and ready to land.

Reverted in https://reviews.llvm.org/rL280968 -- we should resolve 
https://reviews.llvm.org/D23931 before attempting to land again.


https://reviews.llvm.org/D23932



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23932: [XRay] ARM 32-bit no-Thumb support in Clang

2016-09-07 Thread Dean Michael Berris via cfe-commits
dberris closed this revision.
dberris added a comment.

This has been landed as https://reviews.llvm.org/rL280889.


https://reviews.llvm.org/D23932



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r280889 - [XRay] ARM 32-bit no-Thumb support in Clang

2016-09-07 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Wed Sep  7 19:23:28 2016
New Revision: 280889

URL: http://llvm.org/viewvc/llvm-project?rev=280889=rev
Log:
[XRay] ARM 32-bit no-Thumb support in Clang

Just a test for now, adapted from x86_64 tests of XRay.
This is one of 3 commits to different repositories of XRay ARM port. The
other 2 are:

1. https://reviews.llvm.org/D23931 (LLVM)
2. https://reviews.llvm.org/D23933 (compiler-rt)

Differential Review: https://reviews.llvm.org/D23932

Added:
cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp

Added: cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp?rev=280889=auto
==
--- cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp (added)
+++ cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp Wed Sep  7 
19:23:28 2016
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple arm-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23932: [XRay] ARM 32-bit no-Thumb support in Clang

2016-09-07 Thread Dean Michael Berris via cfe-commits
dberris added a comment.

Landing this one now.


https://reviews.llvm.org/D23932



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23932: [XRay] ARM 32-bit no-Thumb support in Clang

2016-08-28 Thread Dean Michael Berris via cfe-commits
dberris accepted this revision.
dberris added a comment.

Concur 100% with @rengolin here -- please land after the LLVM changes land. :)


https://reviews.llvm.org/D23932



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22463: [RFC] Moving to GitHub Proposal: NOT DECISION!

2016-07-18 Thread Dean Michael Berris via cfe-commits
dberris added a subscriber: dberris.
dberris added a comment.

Mostly wording comments, thank you for writing this up!



Comment at: docs/Proposals/GitHub.rst:78
@@ +77,3 @@
+
+GitHub, like GitLab and BitBucket, provide FREE code hosting for open source
+projects. Essentially, they will completely replace *all* the infrastructure 
that

nit: I see you use FREE in caps but this instance isn't *FREE* (as opposed to 
the first mention above) -- consider making it consistent? Either remove the 
emphasis (just "free") or emphasise consistently?


Comment at: docs/Proposals/GitHub.rst:86
@@ +85,3 @@
+for example development meetings, sponsoring disadvantaged people to work on
+compilers and foster diversity and quality in our community.
+

Did you mean "diversity and equality" instead of "diversity and quality" here?


Comment at: docs/Proposals/GitHub.rst:110-112
@@ +109,5 @@
+
+As with the current SVN and Git repositories, each project will be separate,
+on its own, and people will also be able to check them out in the same way
+they're already doing today.
+

Consider rewording this sentence -- it's a little too long and is trying to say 
too many things.

Perhaps something like:

"Each LLVM project will continue to be hosted as separate GitHub repositories 
under a single GitHub organisation. Users can continue to choose to use either 
SVN or Git to access the repositories to suit their current workflow."


Comment at: docs/Proposals/GitHub.rst:185
@@ +184,3 @@
+
+Are there any other upstream systems that could be affected?
+

Probably worth mentioning how Phabricator will need to be updated to integrate 
with the GitHub repository once the canonical repo is changed.


https://reviews.llvm.org/D22463



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r275570 - XRay: Remove duplicate checks for xray instrumentation flags

2016-07-15 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Fri Jul 15 10:46:39 2016
New Revision: 275570

URL: http://llvm.org/viewvc/llvm-project?rev=275570=rev
Log:
XRay: Remove duplicate checks for xray instrumentation flags

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=275570=275569=275570=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jul 15 10:46:39 2016
@@ -4612,16 +4612,6 @@ void Clang::ConstructJob(Compilation ,
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-fxray-instrument");
-if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
- options::OPT_fxray_instruction_threshold_EQ)) 
{
-  CmdArgs.push_back("-fxray-instruction-threshold");
-  CmdArgs.push_back(A->getValue());
-}
-  }
-
-  if (Args.hasFlag(options::OPT_fxray_instrument,
-   options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r275368 - Add C++ dependencies to xray runtime

2016-07-14 Thread Dean Michael Berris via cfe-commits
Thanks Mikael -- this has been fixed in r275377 (
http://reviews.llvm.org/rL275377).

On Thu, Jul 14, 2016 at 7:30 PM Mikael Holmén 
wrote:

> Hi,
>
> Your commit
>
>  Add C++ dependencies to xray runtime
>
> Doesn't compile with gcc. At least 5.3 and 4.8.4 complains about this
> change:
>
> +  if (Args.hasArg(options::OPT_fxray_instrument,
> +  options::OPT_fnoxray_instrument, false)) {
> +CmdArgs.push_back("-fxray-instrument");
> +if (Arg *A =
> Args.getLastArg(options::OPT_fxray_instruction_threshold_,
> +
> options::OPT_fxray_instruction_threshold_EQ)) {
> +  CmdArgs.push_back("-fxray-instruction-threshold");
> +  CmdArgs.push_back(A->getValue());
> +}
> +  }
> +
>
> ../tools/clang/lib/Driver/Tools.cpp:4613:57: error: converting to
> 'llvm::opt::OptSpecifier' from initializer list would use explicit
> constructor 'llvm::opt::OptSpecifier::OptSpecifier(bool)'
> options::OPT_fnoxray_instrument, false)) {
>   ^
> In file included from ../include/llvm/Option/OptTable.h:15:0,
>   from ../include/llvm/Option/Option.h:15,
>   from ../tools/clang/lib/Driver/Tools.h:19,
>   from ../tools/clang/lib/Driver/Tools.cpp:10:
> ../include/llvm/Option/OptSpecifier.h:24:14: error:
> 'llvm::opt::OptSpecifier::OptSpecifier(bool)' is private
>   explicit OptSpecifier(bool) = delete;
>^
> ../tools/clang/lib/Driver/Tools.cpp:4613:57: error: within this context
> options::OPT_fnoxray_instrument, false)) {
>   ^
> ../tools/clang/lib/Driver/Tools.cpp:4613:57: error: use of deleted
> function 'llvm::opt::OptSpecifier::OptSpecifier(bool)'
> In file included from ../include/llvm/Option/OptTable.h:15:0,
>   from ../include/llvm/Option/Option.h:15,
>   from ../tools/clang/lib/Driver/Tools.h:19,
>   from ../tools/clang/lib/Driver/Tools.cpp:10:
> ../include/llvm/Option/OptSpecifier.h:24:14: error: declared here
>   explicit OptSpecifier(bool) = delete;
>^
> In file included from
> ../tools/clang/include/clang/Driver/SanitizerArgs.h:15:0,
>   from ../tools/clang/lib/Driver/Tools.cpp:24:
> ../include/llvm/Option/ArgList.h:191:8: error:   initializing argument 3
> of 'bool llvm::opt::ArgList::hasArg(llvm::opt::OptSpecifier,
> llvm::opt::OptSpecifier, llvm::opt::OptSpecifier) const'
> bool hasArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2)
> const {
>  ^
> ninja: build stopped: subcommand failed.
> system(/proj/flexasic/app/ninja/1.4/SLED11-64/bin/ninja -j1 -C
> build-all-gcc53 llc llvm-stress opt clang all) failed: child exited with
> value 1
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22338: Use hasFlag instead of hasArg

2016-07-14 Thread Dean Michael Berris via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275377: Use hasFlag instead of hasArg (authored by dberris).

Changed prior to commit:
  http://reviews.llvm.org/D22338?vs=63922=63923#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D22338

Files:
  cfe/trunk/lib/Driver/Tools.cpp

Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -4609,8 +4609,8 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
-  if (Args.hasArg(options::OPT_fxray_instrument,
-  options::OPT_fnoxray_instrument, false)) {
+  if (Args.hasFlag(options::OPT_fxray_instrument,
+   options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-fxray-instrument");
 if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
  options::OPT_fxray_instruction_threshold_EQ)) 
{


Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -4609,8 +4609,8 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
-  if (Args.hasArg(options::OPT_fxray_instrument,
-  options::OPT_fnoxray_instrument, false)) {
+  if (Args.hasFlag(options::OPT_fxray_instrument,
+   options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-fxray-instrument");
 if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
  options::OPT_fxray_instruction_threshold_EQ)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r275377 - Use hasFlag instead of hasArg

2016-07-14 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Jul 14 01:37:46 2016
New Revision: 275377

URL: http://llvm.org/viewvc/llvm-project?rev=275377=rev
Log:
Use hasFlag instead of hasArg

Summary: Fix the build to use hasFlag instead of hasArg for checking some flags.

Reviewers: echristo

Subscribers: mehdi_amini, cfe-commits

Differential Revision: http://reviews.llvm.org/D22338

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=275377=275376=275377=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Jul 14 01:37:46 2016
@@ -4609,8 +4609,8 @@ void Clang::ConstructJob(Compilation ,
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
-  if (Args.hasArg(options::OPT_fxray_instrument,
-  options::OPT_fnoxray_instrument, false)) {
+  if (Args.hasFlag(options::OPT_fxray_instrument,
+   options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-fxray-instrument");
 if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
  options::OPT_fxray_instruction_threshold_EQ)) 
{


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22338: Use hasFlag instead of hasArg

2016-07-14 Thread Dean Michael Berris via cfe-commits
dberris created this revision.
dberris added a reviewer: echristo.
dberris added a subscriber: cfe-commits.
Herald added a subscriber: mehdi_amini.

Fix the build to use hasFlag instead of hasArg for checking some flags.

http://reviews.llvm.org/D22338

Files:
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4609,8 +4609,8 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
-  if (Args.hasArg(options::OPT_fxray_instrument,
-  options::OPT_fnoxray_instrument, false)) {
+  if (Args.hasFlag(options::OPT_fxray_instrument,
+   options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-fxray-instrument");
 if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
  options::OPT_fxray_instruction_threshold_EQ)) 
{


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4609,8 +4609,8 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
-  if (Args.hasArg(options::OPT_fxray_instrument,
-  options::OPT_fnoxray_instrument, false)) {
+  if (Args.hasFlag(options::OPT_fxray_instrument,
+   options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-fxray-instrument");
 if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
  options::OPT_fxray_instruction_threshold_EQ)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21983: Add C++ dependencies to xray runtime

2016-07-13 Thread Dean Michael Berris via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275368: Add C++ dependencies to xray runtime (authored by 
dberris).

Changed prior to commit:
  http://reviews.llvm.org/D21983?vs=63917=63919#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21983

Files:
  cfe/trunk/lib/Driver/Tools.cpp

Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -3193,12 +3193,17 @@
   return false;
 }
 
-static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
   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");
 }
@@ -4604,6 +4609,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-fxray-instrument");
+if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
+ options::OPT_fxray_instruction_threshold_EQ)) 
{
+  CmdArgs.push_back("-fxray-instruction-threshold");
+  CmdArgs.push_back(A->getValue());
+}
+  }
+
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-fxray-instrument");
@@ -9451,7 +9466,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: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -3193,12 +3193,17 @@
   return false;
 }
 
-static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
   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");
 }
@@ -4604,6 +4609,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-fxray-instrument");
+if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
+ options::OPT_fxray_instruction_threshold_EQ)) {
+  CmdArgs.push_back("-fxray-instruction-threshold");
+  CmdArgs.push_back(A->getValue());
+}
+  }
+
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-fxray-instrument");
@@ -9451,7 +9466,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);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r275368 - Add C++ dependencies to xray runtime

2016-07-13 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Wed Jul 13 23:58:44 2016
New Revision: 275368

URL: http://llvm.org/viewvc/llvm-project?rev=275368=rev
Log:
Add C++ dependencies to xray runtime

Summary:
Depends on D21982 which implements the in-memory logging implementation of the
XRay runtime. These additional changes also depends on D20352 which adds the
bulk of XRay flags/dependencies when using the `-fxray-instrument` flag from
Clang.

Reviewers: echristo, rnk, aaron.ballman

Subscribers: mehdi_amini, cfe-commits

Differential Revision: http://reviews.llvm.org/D21983

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=275368=275367=275368=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul 13 23:58:44 2016
@@ -3193,12 +3193,17 @@ static bool addXRayRuntime(const ToolCha
   return false;
 }
 
-static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
   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");
 }
@@ -4604,6 +4609,16 @@ void Clang::ConstructJob(Compilation ,
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-fxray-instrument");
+if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
+ options::OPT_fxray_instruction_threshold_EQ)) 
{
+  CmdArgs.push_back("-fxray-instruction-threshold");
+  CmdArgs.push_back(A->getValue());
+}
+  }
+
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-fxray-instrument");
@@ -9451,7 +9466,7 @@ void gnutools::Linker::ConstructJob(Comp
 linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
 
   if (NeedsXRayDeps)
-linkXRayRuntimeDeps(ToolChain, CmdArgs);
+linkXRayRuntimeDeps(ToolChain, Args, CmdArgs);
 
   bool WantPthread = Args.hasArg(options::OPT_pthread) ||
  Args.hasArg(options::OPT_pthreads);


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21983: Add C++ dependencies to xray runtime

2016-07-13 Thread Dean Michael Berris via cfe-commits
dberris updated this revision to Diff 63917.
dberris added a comment.

- Undo unnecessary formatting change


http://reviews.llvm.org/D21983

Files:
  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 , ArgStringList ) {
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
   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");
 }
@@ -4604,6 +4609,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-fxray-instrument");
+if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
+ options::OPT_fxray_instruction_threshold_EQ)) 
{
+  CmdArgs.push_back("-fxray-instruction-threshold");
+  CmdArgs.push_back(A->getValue());
+}
+  }
+
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-fxray-instrument");
@@ -9451,7 +9466,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/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3193,12 +3193,17 @@
   return false;
 }
 
-static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
   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");
 }
@@ -4604,6 +4609,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-fxray-instrument");
+if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
+ options::OPT_fxray_instruction_threshold_EQ)) {
+  CmdArgs.push_back("-fxray-instruction-threshold");
+  CmdArgs.push_back(A->getValue());
+}
+  }
+
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-fxray-instrument");
@@ -9451,7 +9466,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);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21983: Add C++ dependencies to xray runtime

2016-07-13 Thread Dean Michael Berris via cfe-commits
dberris updated this revision to Diff 63916.
dberris added a comment.

Rebase


http://reviews.llvm.org/D21983

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 , ArgStringList ) {
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
   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");
 }
@@ -4604,6 +4609,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-fxray-instrument");
+if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
+ options::OPT_fxray_instruction_threshold_EQ)) 
{
+  CmdArgs.push_back("-fxray-instruction-threshold");
+  CmdArgs.push_back(A->getValue());
+}
+  }
+
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-fxray-instrument");
@@ -9451,7 +9466,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
@@ -536,9 +536,9 @@
 
   std::string baseTypeName;
   if (isPipe)
-baseTypeName = ty.getCanonicalType()->getAs()
-  ->getElementType().getCanonicalType()
-  .getAsString(Policy);
+baseTypeName =
+
cast(ty)->getElementType().getCanonicalType().getAsString(
+Policy);
   else
 baseTypeName =
   ty.getUnqualifiedType().getCanonicalType().getAsString(Policy);


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3193,12 +3193,17 @@
   return false;
 }
 
-static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
   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");
 }
@@ -4604,6 +4609,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-fxray-instrument");
+if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
+ options::OPT_fxray_instruction_threshold_EQ)) {
+  CmdArgs.push_back("-fxray-instruction-threshold");
+  CmdArgs.push_back(A->getValue());
+}
+  }
+
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-fxray-instrument");
@@ -9451,7 +9466,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
@@ -536,9 +536,9 @@
 
   std::string baseTypeName;
   if (isPipe)
-baseTypeName = ty.getCanonicalType()->getAs()
-  ->getElementType().getCanonicalType()
-  .getAsString(Policy);
+baseTypeName =
+cast(ty)->getElementType().getCanonicalType().getAsString(
+Policy);
   else
 baseTypeName 

Re: [PATCH] D20352: Add XRay flags to Clang

2016-07-12 Thread Dean Michael Berris via cfe-commits
dberris added a comment.

It looks like I was using `hasArg` instead of `hasFlag`. The dangerous part 
here is that OptSpecifier has an unsigned non-explicit argument, and I suspect 
`bool` is being promoted to `unsigned` silently with clang/gcc.


http://reviews.llvm.org/D20352



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20352: Add XRay flags to Clang

2016-07-12 Thread Dean Michael Berris via cfe-commits
dberris updated this revision to Diff 63775.
dberris added a comment.

- Use hasFlag instead of hasArg


http://reviews.llvm.org/D20352

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/xray-attributes-supported.cpp
  test/Sema/xray-always-instrument-attr.c
  test/Sema/xray-always-instrument-attr.cpp

Index: test/Sema/xray-always-instrument-attr.cpp
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+void foo [[clang::xray_always_instrument]] ();
+
+struct [[clang::xray_always_instrument]] a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+class b {
+ void c [[clang::xray_always_instrument]] ();
+};
+
+void baz [[clang::xray_always_instrument("not-supported")]] (); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/Sema/xray-always-instrument-attr.c
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11
+void foo() __attribute__((xray_always_instrument));
+
+struct __attribute__((xray_always_instrument)) a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+void bar() __attribute__((xray_always_instrument("not-supported"))); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- /dev/null
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5909,10 +5909,13 @@
   case AttributeList::AT_TypeTagForDatatype:
 handleTypeTagForDatatypeAttr(S, D, Attr);
 break;
-
   case AttributeList::AT_RenderScriptKernel:
 handleSimpleAttribute(S, D, Attr);
 break;
+  // XRay attributes.
+  case AttributeList::AT_XRayInstrument:
+handleSimpleAttribute(S, D, Attr);
+break;
   }
 }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -687,6 +687,9 @@
   }
 
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
+  Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
+  Opts.XRayInstructionThreshold =
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
   Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3181,6 +3181,28 @@
   return !StaticRuntimes.empty();
 }
 
+static bool addXRayRuntime(const ToolChain , const ArgList ,
+   ArgStringList ) {
+  if (Args.hasFlag(options::OPT_fxray_instrument,
+   options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+  CmdArgs.push_back("-latomic");
+  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
+CmdArgs.push_back("-ldl");
+}
+
 static bool areOptimizationsEnabled(const ArgList ) {
   // Find the last -O arg and see if it is non-zero.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group))
@@ -4582,6 +4604,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+  if (Args.hasArg(options::OPT_fxray_instrument,
+ 

Re: [PATCH] D20352: Add XRay flags to Clang

2016-07-12 Thread Dean Michael Berris via cfe-commits
dberris updated this revision to Diff 63771.
dberris added a comment.

Rebase


http://reviews.llvm.org/D20352

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/xray-attributes-supported.cpp
  test/Sema/xray-always-instrument-attr.c
  test/Sema/xray-always-instrument-attr.cpp

Index: test/Sema/xray-always-instrument-attr.cpp
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+void foo [[clang::xray_always_instrument]] ();
+
+struct [[clang::xray_always_instrument]] a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+class b {
+ void c [[clang::xray_always_instrument]] ();
+};
+
+void baz [[clang::xray_always_instrument("not-supported")]] (); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/Sema/xray-always-instrument-attr.c
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11
+void foo() __attribute__((xray_always_instrument));
+
+struct __attribute__((xray_always_instrument)) a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+void bar() __attribute__((xray_always_instrument("not-supported"))); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- /dev/null
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5909,10 +5909,13 @@
   case AttributeList::AT_TypeTagForDatatype:
 handleTypeTagForDatatypeAttr(S, D, Attr);
 break;
-
   case AttributeList::AT_RenderScriptKernel:
 handleSimpleAttribute(S, D, Attr);
 break;
+  // XRay attributes.
+  case AttributeList::AT_XRayInstrument:
+handleSimpleAttribute(S, D, Attr);
+break;
   }
 }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -687,6 +687,9 @@
   }
 
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
+  Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
+  Opts.XRayInstructionThreshold =
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
   Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3181,6 +3181,28 @@
   return !StaticRuntimes.empty();
 }
 
+static bool addXRayRuntime(const ToolChain , const ArgList ,
+   ArgStringList ) {
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+  CmdArgs.push_back("-latomic");
+  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
+CmdArgs.push_back("-ldl");
+}
+
 static bool areOptimizationsEnabled(const ArgList ) {
   // Find the last -O arg and see if it is non-zero.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group))
@@ -4582,6 +4604,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  

Re: [PATCH] D20352: Add XRay flags to Clang

2016-07-07 Thread Dean Michael Berris via cfe-commits
dberris added a comment.

Thanks -- I don't have commit powers yet, do either of you mind landing this 
for me?

Cheers


http://reviews.llvm.org/D20352



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20352: Add XRay flags to Clang

2016-07-07 Thread Dean Michael Berris via cfe-commits
dberris updated this revision to Diff 63041.
dberris added a comment.

- Check D is valid before using it


http://reviews.llvm.org/D20352

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/xray-attributes-supported.cpp
  test/Sema/xray-always-instrument-attr.c
  test/Sema/xray-always-instrument-attr.cpp

Index: test/Sema/xray-always-instrument-attr.cpp
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+void foo [[clang::xray_always_instrument]] ();
+
+struct [[clang::xray_always_instrument]] a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+class b {
+ void c [[clang::xray_always_instrument]] ();
+};
+
+void baz [[clang::xray_always_instrument("not-supported")]] (); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/Sema/xray-always-instrument-attr.c
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11
+void foo() __attribute__((xray_always_instrument));
+
+struct __attribute__((xray_always_instrument)) a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+void bar() __attribute__((xray_always_instrument("not-supported"))); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- /dev/null
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5909,10 +5909,13 @@
   case AttributeList::AT_TypeTagForDatatype:
 handleTypeTagForDatatypeAttr(S, D, Attr);
 break;
-
   case AttributeList::AT_RenderScriptKernel:
 handleSimpleAttribute(S, D, Attr);
 break;
+  // XRay attributes.
+  case AttributeList::AT_XRayInstrument:
+handleSimpleAttribute(S, D, Attr);
+break;
   }
 }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -686,6 +686,9 @@
   }
 
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
+  Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
+  Opts.XRayInstructionThreshold =
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
   Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3181,6 +3181,28 @@
   return !StaticRuntimes.empty();
 }
 
+static bool addXRayRuntime(const ToolChain , const ArgList ,
+   ArgStringList ) {
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+  CmdArgs.push_back("-latomic");
+  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
+CmdArgs.push_back("-ldl");
+}
+
 static bool areOptimizationsEnabled(const ArgList ) {
   // Find the last -O arg and see if it is non-zero.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group))
@@ -4582,6 +4604,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+  if (Args.hasArg(options::OPT_fxray_instrument,

Re: [PATCH] D21983: Add C++ dependencies to xray runtime

2016-07-07 Thread Dean Michael Berris via cfe-commits
dberris updated this revision to Diff 63042.
dberris added a comment.

Rebase


http://reviews.llvm.org/D21983

Files:
  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 , ArgStringList ) {
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
   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/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3193,12 +3193,17 @@
   return false;
 }
 
-static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
   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);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21983: Add C++ dependencies to xray runtime

2016-07-07 Thread Dean Michael Berris via cfe-commits
dberris updated this revision to Diff 63040.
dberris added a comment.

- Check first whether `D` is actually not nullptr


http://reviews.llvm.org/D21983

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 , ArgStringList ) {
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
   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()) {
   if (XRayAttr->alwaysXRayInstrument())
 Fn->addFnAttr("function-instrument", "xray-always");


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3193,12 +3193,17 @@
   return false;
 }
 
-static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
   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()) {
   if (XRayAttr->alwaysXRayInstrument())
 Fn->addFnAttr("function-instrument", "xray-always");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20352: Add XRay flags to Clang

2016-07-07 Thread Dean Michael Berris via cfe-commits
dberris updated this revision to Diff 63039.
dberris added a comment.

Undo previous change -- updated the wrong patch. :(


http://reviews.llvm.org/D20352

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/xray-attributes-supported.cpp
  test/Sema/xray-always-instrument-attr.c
  test/Sema/xray-always-instrument-attr.cpp

Index: test/Sema/xray-always-instrument-attr.cpp
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+void foo [[clang::xray_always_instrument]] ();
+
+struct [[clang::xray_always_instrument]] a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+class b {
+ void c [[clang::xray_always_instrument]] ();
+};
+
+void baz [[clang::xray_always_instrument("not-supported")]] (); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/Sema/xray-always-instrument-attr.c
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11
+void foo() __attribute__((xray_always_instrument));
+
+struct __attribute__((xray_always_instrument)) a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+void bar() __attribute__((xray_always_instrument("not-supported"))); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- /dev/null
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5909,10 +5909,13 @@
   case AttributeList::AT_TypeTagForDatatype:
 handleTypeTagForDatatypeAttr(S, D, Attr);
 break;
-
   case AttributeList::AT_RenderScriptKernel:
 handleSimpleAttribute(S, D, Attr);
 break;
+  // XRay attributes.
+  case AttributeList::AT_XRayInstrument:
+handleSimpleAttribute(S, D, Attr);
+break;
   }
 }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -686,6 +686,9 @@
   }
 
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
+  Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
+  Opts.XRayInstructionThreshold =
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
   Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3181,6 +3181,28 @@
   return !StaticRuntimes.empty();
 }
 
+static bool addXRayRuntime(const ToolChain , const ArgList ,
+   ArgStringList ) {
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+  CmdArgs.push_back("-latomic");
+  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
+CmdArgs.push_back("-ldl");
+}
+
 static bool areOptimizationsEnabled(const ArgList ) {
   // Find the last -O arg and see if it is non-zero.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group))
@@ -4582,6 +4604,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+  if 

Re: [PATCH] D20352: Add XRay flags to Clang

2016-07-07 Thread Dean Michael Berris via cfe-commits
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 , ArgStringList ) {
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
   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()) {
   if (XRayAttr->alwaysXRayInstrument())
 Fn->addFnAttr("function-instrument", "xray-always");


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3193,12 +3193,17 @@
   return false;
 }
 
-static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
   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()) {
   if (XRayAttr->alwaysXRayInstrument())
 Fn->addFnAttr("function-instrument", "xray-always");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20352: Add XRay flags to Clang

2016-07-05 Thread Dean Michael Berris via cfe-commits
dberris updated this revision to Diff 62824.
dberris marked an inline comment as done.
dberris added a comment.

- Formatting changes


http://reviews.llvm.org/D20352

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/xray-attributes-supported.cpp
  test/Sema/xray-always-instrument-attr.c
  test/Sema/xray-always-instrument-attr.cpp

Index: test/Sema/xray-always-instrument-attr.cpp
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+void foo [[clang::xray_always_instrument]] ();
+
+struct [[clang::xray_always_instrument]] a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+class b {
+ void c [[clang::xray_always_instrument]] ();
+};
+
+void baz [[clang::xray_always_instrument("not-supported")]] (); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/Sema/xray-always-instrument-attr.c
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11
+void foo() __attribute__((xray_always_instrument));
+
+struct __attribute__((xray_always_instrument)) a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+void bar() __attribute__((xray_always_instrument("not-supported"))); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- /dev/null
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5909,10 +5909,13 @@
   case AttributeList::AT_TypeTagForDatatype:
 handleTypeTagForDatatypeAttr(S, D, Attr);
 break;
-
   case AttributeList::AT_RenderScriptKernel:
 handleSimpleAttribute(S, D, Attr);
 break;
+  // XRay attributes.
+  case AttributeList::AT_XRayInstrument:
+handleSimpleAttribute(S, D, Attr);
+break;
   }
 }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -686,6 +686,9 @@
   }
 
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
+  Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
+  Opts.XRayInstructionThreshold =
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
   Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3181,6 +3181,28 @@
   return !StaticRuntimes.empty();
 }
 
+static bool addXRayRuntime(const ToolChain , const ArgList ,
+   ArgStringList ) {
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+  CmdArgs.push_back("-latomic");
+  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
+CmdArgs.push_back("-ldl");
+}
+
 static bool areOptimizationsEnabled(const ArgList ) {
   // Find the last -O arg and see if it is non-zero.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group))
@@ -4582,6 +4604,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+  if 

Re: [PATCH] D20352: Add XRay flags to Clang

2016-07-05 Thread Dean Michael Berris via cfe-commits
dberris marked 2 inline comments as done.


Comment at: include/clang/Basic/Attr.td:436
@@ +435,3 @@
+   CXX11<"clang", "xray_never_instrument">];
+  let Subjects = SubjectList<[CXXMethod, ObjCMethod, Function], WarnDiag,
+  "ExpectedFunctionOrMethod">;

aaron.ballman wrote:
> Then ClangAttrEmitter.cpp needs to be updated as well (this is a reasonable 
> case to automatically support, I think).
That makes sense, I can do it in another change that's more focused on just 
that if you don't mind?


Comment at: include/clang/Basic/AttrDocs.td:2457
@@ +2456,3 @@
+  let Content = [{
+``__attribute__((xray_always_instrument))`` or 
``[[clang:xray_always_instrument]]`` is used to mark member functions (in C++), 
methods (in Objective C), and free functions (in C, C++, and Objective C) to be 
instrumented with XRay. This will cause the function to always have space at 
the beginning and exit points to allow for runtime patching.
+

aaron.ballman wrote:
> I get the impression they do conflict because they have overlapping 
> functionality (both provide prologue space for runtime patching, for 
> instance). It would be best to have only one attribute if we can do it.
I've explored that option (using `patchable-function` instead) and while I 
haven't excluded that outright, there needs to be a discussion about how we're 
going to implement complimentary instrumentation functionality that do nop-sled 
inserting. I suspect that has to happen in D19904 where we can still make those 
changes to instead use `patchable-function`.

The response to my comment in D19908 seems to be that there should be no 
conflicts in the platforms XRay currently cares about -- but that if we do ever 
want to get XRay implemented/supported in x86 32-bit, then we're going to have 
issues. This suggests that a harder look at `patchable-function` and exclusive 
modes (or special-casing the supported configurations) might need to happen 
sooner than later.


http://reviews.llvm.org/D20352



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21983: Add C++ dependencies to xray runtime

2016-07-05 Thread Dean Michael Berris via cfe-commits
dberris created this revision.
dberris added reviewers: echristo, rnk, aaron.ballman.
dberris added a subscriber: cfe-commits.
dberris added dependencies: D20352: Add XRay flags to Clang, D21982: WIP: 
Implement a per-thread inmemory log.
Herald added a subscriber: mehdi_amini.

Depends on D21982 which implements the in-memory logging implementation of the
XRay runtime. These additional changes also depends on D20352 which adds the
bulk of XRay flags/dependencies when using the `-fxray-instrument` flag from
Clang.

http://reviews.llvm.org/D21983

Files:
  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 , ArgStringList ) {
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
   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/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3193,12 +3193,17 @@
   return false;
 }
 
-static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+static void linkXRayRuntimeDeps(const ToolChain , const ArgList ,
+ArgStringList ) {
   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);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20352: Add XRay flags to Clang

2016-07-05 Thread Dean Michael Berris via cfe-commits
dberris updated this revision to Diff 62720.
dberris added a comment.

Rebase harder.


http://reviews.llvm.org/D20352

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/xray-attributes-supported.cpp
  test/Sema/xray-always-instrument-attr.c
  test/Sema/xray-always-instrument-attr.cpp

Index: test/Sema/xray-always-instrument-attr.cpp
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+void foo [[clang::xray_always_instrument]] ();
+
+struct [[clang::xray_always_instrument]] a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+class b {
+ void c [[clang::xray_always_instrument]] ();
+};
+
+void baz [[clang::xray_always_instrument("not-supported")]] (); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/Sema/xray-always-instrument-attr.c
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11
+void foo() __attribute__((xray_always_instrument));
+
+struct __attribute__((xray_always_instrument)) a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+void bar() __attribute__((xray_always_instrument("not-supported"))); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- /dev/null
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5909,10 +5909,13 @@
   case AttributeList::AT_TypeTagForDatatype:
 handleTypeTagForDatatypeAttr(S, D, Attr);
 break;
-
   case AttributeList::AT_RenderScriptKernel:
 handleSimpleAttribute(S, D, Attr);
 break;
+  // XRay attributes.
+  case AttributeList::AT_XRayInstrument:
+handleSimpleAttribute(S, D, Attr);
+break;
   }
 }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -686,6 +686,9 @@
   }
 
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
+  Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
+  Opts.XRayInstructionThreshold =
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
   Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3181,6 +3181,28 @@
   return !StaticRuntimes.empty();
 }
 
+static bool addXRayRuntime(const ToolChain , const ArgList ,
+   ArgStringList ) {
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+  CmdArgs.push_back("-latomic");
+  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
+CmdArgs.push_back("-ldl");
+}
+
 static bool areOptimizationsEnabled(const ArgList ) {
   // Find the last -O arg and see if it is non-zero.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group))
@@ -4582,6 +4604,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  

Re: [PATCH] D21830: Remove -mrelax-all from Clang -O0

2016-06-29 Thread Dean Michael Berris via cfe-commits
dberris added a comment.

Changed the description to provide a justification.


http://reviews.llvm.org/D21830



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21830: Remove -mrelax-all from Clang -O0

2016-06-29 Thread Dean Michael Berris via cfe-commits
dberris created this revision.
dberris added reviewers: echristo, rafael, grosbach.
dberris added a subscriber: cfe-commits.
Herald added a subscriber: mehdi_amini.

Remove the -mrelax-all options passed onto the integrated assembler in
-O0.

http://reviews.llvm.org/D21830

Files:
  lib/Driver/Tools.cpp
  test/Driver/integrated-as.c

Index: test/Driver/integrated-as.c
===
--- test/Driver/integrated-as.c
+++ test/Driver/integrated-as.c
@@ -1,7 +1,6 @@
 // RUN: %clang -### -c -save-temps -integrated-as %s 2>&1 | FileCheck %s
 
 // CHECK: cc1as
-// CHECK: -mrelax-all
 
 // RUN: %clang -### -fintegrated-as -c -save-temps %s 2>&1 | FileCheck %s 
-check-prefix FIAS
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2721,38 +2721,10 @@
   return !UseDwarfDirectory;
 }
 
-/// \brief Check whether the given input tree contains any compilation actions.
-static bool ContainsCompileAction(const Action *A) {
-  if (isa(A) || isa(A))
-return true;
-
-  for (const auto  : A->inputs())
-if (ContainsCompileAction(AI))
-  return true;
-
-  return false;
-}
-
 /// \brief Check if -relax-all should be passed to the internal assembler.
-/// This is done by default when compiling non-assembler source with -O0.
 static bool UseRelaxAll(Compilation , const ArgList ) {
-  bool RelaxDefault = true;
-
-  if (Arg *A = Args.getLastArg(options::OPT_O_Group))
-RelaxDefault = A->getOption().matches(options::OPT_O0);
-
-  if (RelaxDefault) {
-RelaxDefault = false;
-for (const auto  : C.getActions()) {
-  if (ContainsCompileAction(Act)) {
-RelaxDefault = true;
-break;
-  }
-}
-  }
-
   return Args.hasFlag(options::OPT_mrelax_all, options::OPT_mno_relax_all,
-  RelaxDefault);
+  false);
 }
 
 // Convert an arg of the form "-gN" or "-ggdbN" or one of their aliases


Index: test/Driver/integrated-as.c
===
--- test/Driver/integrated-as.c
+++ test/Driver/integrated-as.c
@@ -1,7 +1,6 @@
 // RUN: %clang -### -c -save-temps -integrated-as %s 2>&1 | FileCheck %s
 
 // CHECK: cc1as
-// CHECK: -mrelax-all
 
 // RUN: %clang -### -fintegrated-as -c -save-temps %s 2>&1 | FileCheck %s -check-prefix FIAS
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2721,38 +2721,10 @@
   return !UseDwarfDirectory;
 }
 
-/// \brief Check whether the given input tree contains any compilation actions.
-static bool ContainsCompileAction(const Action *A) {
-  if (isa(A) || isa(A))
-return true;
-
-  for (const auto  : A->inputs())
-if (ContainsCompileAction(AI))
-  return true;
-
-  return false;
-}
-
 /// \brief Check if -relax-all should be passed to the internal assembler.
-/// This is done by default when compiling non-assembler source with -O0.
 static bool UseRelaxAll(Compilation , const ArgList ) {
-  bool RelaxDefault = true;
-
-  if (Arg *A = Args.getLastArg(options::OPT_O_Group))
-RelaxDefault = A->getOption().matches(options::OPT_O0);
-
-  if (RelaxDefault) {
-RelaxDefault = false;
-for (const auto  : C.getActions()) {
-  if (ContainsCompileAction(Act)) {
-RelaxDefault = true;
-break;
-  }
-}
-  }
-
   return Args.hasFlag(options::OPT_mrelax_all, options::OPT_mno_relax_all,
-  RelaxDefault);
+  false);
 }
 
 // Convert an arg of the form "-gN" or "-ggdbN" or one of their aliases
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20352: Add XRay flags to Clang

2016-06-27 Thread Dean Michael Berris via cfe-commits
dberris added inline comments.


Comment at: include/clang/Basic/Attr.td:436
@@ +435,3 @@
+   CXX11<"clang", "xray_never_instrument">];
+  let Subjects = SubjectList<[CXXMethod, ObjCMethod, Function], WarnDiag,
+  "ExpectedFunctionOrMethod">;

aaron.ballman wrote:
> You can drop the WarnDiag and string literal; the defaults already do the 
> right thing.
I tried, but I'm getting this error:

.../Basic/Attr.td:436:18: error: Could not deduce diagnostic argument for Attr 
subjects
  let Subjects = SubjectList<[CXXMethod, ObjCMethod, Function]>;



Comment at: include/clang/Basic/AttrDocs.td:2455
@@ +2454,3 @@
+  let Content = [{
+``__attribute__((xray_always_instrument))`` or 
``[[clang:xray_always_instrument]]`` is used to mark member functions (in C++), 
methods (in Objective C), and free functions (in C, C++, and Objective C) to be 
instrumented with XRay. This will cause the function to always have space at 
the beginning and exit points to allow for runtime patching.
+

aaron.ballman wrote:
> Let's make sure that this patch and D19908 do not conflict, because they seem 
> to be implementing competing semantics.
Good catch. Let me comment on D19908 to see if it competes with how we define 
XRay instrumentation. As far as I can tell from the LLVM side, those should not 
interfere with each other.


Comment at: lib/CodeGen/CodeGenFunction.cpp:381
@@ -380,3 +380,3 @@
 
-  for (SmallVectorImpl::iterator
+  for (SmallVectorImpl::iterator
I = DeferredReplacements.begin(),

aaron.ballman wrote:
> Can't you rangify this loop?
Probably in a different change. :) For now I've reverted the formatting changes.


Comment at: lib/CodeGen/CodeGenFunction.cpp:402
@@ +401,3 @@
+/// instrumented with XRay nop sleds.
+bool CodeGenFunction::ShouldXRayInstrumentFunction() {
+  return CGM.getCodeGenOpts().XRayInstrumentFunctions;

aaron.ballman wrote:
> Any particular reason this isn't a `const` function?
No good reason. :) Good catch, fixed.


Comment at: lib/CodeGen/CodeGenFunction.cpp:691
@@ +690,3 @@
+if (D->hasAttr()) {
+  switch (D->getAttr()->getSpellingListIndex()) {
+case 0:

aaron.ballman wrote:
> This is not the right way to do this. ;-)
> 
> You should check the *semantic* spelling instead. e.g.,
> ```
> if (const auto *A = D->getAttr()) {
>   switch (A->getSemanticSpelling()) {
>   case XRayInstrumentAttr::GNU_blahblah:
>   case XRayInstrumentAttr::CXX11_clang_blahblah:
>   }
> }
> ```
> Alternatively (and I think this may be cleaner), you could add an additional 
> member in Attr.td that exposes this as two Boolean getters `bool 
> alwaysInstrument() const` and `bool neverInstrument() const` that do the 
> semantic spelling switch.
I thought this was a little weird, thanks for pointing this out!

I've used accessors instead, maybe it looks better now?


http://reviews.llvm.org/D20352



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20352: Add XRay flags to Clang

2016-06-27 Thread Dean Michael Berris via cfe-commits
dberris updated this revision to Diff 62056.
dberris marked 2 inline comments as done.
dberris added a comment.

- Undo formatting changes
- Re-apply changes post-review
- Address more comments


http://reviews.llvm.org/D20352

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/xray-attributes-supported.cpp
  test/Sema/xray-always-instrument-attr.c
  test/Sema/xray-always-instrument-attr.cpp

Index: test/Sema/xray-always-instrument-attr.cpp
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+void foo [[clang::xray_always_instrument]] ();
+
+struct [[clang::xray_always_instrument]] a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+class b {
+ void c [[clang::xray_always_instrument]] ();
+};
+
+void baz [[clang::xray_always_instrument("not-supported")]] (); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/Sema/xray-always-instrument-attr.c
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11
+void foo() __attribute__((xray_always_instrument));
+
+struct __attribute__((xray_always_instrument)) a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+void bar() __attribute__((xray_always_instrument("not-supported"))); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- /dev/null
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5913,10 +5913,13 @@
   case AttributeList::AT_TypeTagForDatatype:
 handleTypeTagForDatatypeAttr(S, D, Attr);
 break;
-
   case AttributeList::AT_RenderScriptKernel:
 handleSimpleAttribute(S, D, Attr);
 break;
+  // XRay attributes.
+  case AttributeList::AT_XRayInstrument:
+handleSimpleAttribute(S, D, Attr);
+break;
   }
 }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -685,6 +685,9 @@
   }
 
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
+  Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
+  Opts.XRayInstructionThreshold =
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
   Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3178,6 +3178,28 @@
   return !StaticRuntimes.empty();
 }
 
+static bool addXRayRuntime(const ToolChain , const ArgList ,
+   ArgStringList ) {
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+  CmdArgs.push_back("-latomic");
+  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
+CmdArgs.push_back("-ldl");
+}
+
 static bool areOptimizationsEnabled(const ArgList ) {
   // Find the last -O arg and see if it is non-zero.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group))
@@ -4579,6 +4601,16 @@
 
   Args.AddAllArgs(CmdArgs, 

Re: [PATCH] D20352: Add XRay flags to Clang

2016-06-27 Thread Dean Michael Berris via cfe-commits
dberris marked an inline comment as done.


Comment at: include/clang/Basic/Attr.td:432
@@ +431,3 @@
+   CXX11<"clang", "xray_always_instrument">];
+  let Subjects = SubjectList<[CXXMethod, Function], WarnDiag,
+  "ExpectedFunctionOrMethod">;

Yes it does, done.


Comment at: include/clang/Basic/Attr.td:433
@@ +432,3 @@
+  let Subjects = SubjectList<[CXXMethod, Function], WarnDiag,
+  "ExpectedFunctionOrMethod">;
+  let Documentation = [Undocumented];  // TODO(dberris): Document this!

Done the latter to include ObjC methods.


Comment at: include/clang/Basic/Attr.td:437
@@ +436,3 @@
+
+def XRayNeverInstrument : InheritableAttr {
+  let Spellings = [GNU<"xray_never_instrument">,

This actually makes a lot of sense. I've done some of the consolidation to make 
it a lot easier to check in the code and to expand later on too. I suppose 
other attributes that are XRay-specific with additional values/arguments would 
make a better candidate for additional attributes. Will cross that bridge when 
we get to that part of the implementation. :)


Comment at: include/clang/Frontend/CodeGenOptions.def:75
@@ -74,3 +74,3 @@
 CODEGENOPT(FunctionSections  , 1, 0) ///< Set when -ffunction-sections is 
enabled.
 CODEGENOPT(InstrumentFunctions , 1, 0) ///< Set when -finstrument-functions is
///< enabled.

I'm open to this idea, except this might break compatibility with GCC (as this 
seems to be a gcc-inspired flag).

I'm happy to explore consolidating the different instrumentation flags under 
`-finstrument=` which then has namespace values internally (profile-..., 
xray-...) for different modes, etc. For now the simplest thing to do might be 
to have XRay do this independently first, then have a cleanup later to 
consolidate flags on the driver and deprecate the flags.


http://reviews.llvm.org/D20352



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20352: Add XRay flags to Clang

2016-06-27 Thread Dean Michael Berris via cfe-commits
dberris updated this revision to Diff 61932.
dberris marked 2 inline comments as done.
dberris added a comment.

- Address review comments; see details.


http://reviews.llvm.org/D20352

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/xray-attributes-supported.cpp
  test/Sema/xray-always-instrument-attr.c
  test/Sema/xray-always-instrument-attr.cpp

Index: test/Sema/xray-always-instrument-attr.cpp
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+void foo [[clang::xray_always_instrument]] ();
+
+struct [[clang::xray_always_instrument]] a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+class b {
+ void c [[clang::xray_always_instrument]] ();
+};
+
+void baz [[clang::xray_always_instrument("not-supported")]] (); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/Sema/xray-always-instrument-attr.c
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11
+void foo() __attribute__((xray_always_instrument));
+
+struct __attribute__((xray_always_instrument)) a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+void bar() __attribute__((xray_always_instrument("not-supported"))); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- /dev/null
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5913,10 +5913,13 @@
   case AttributeList::AT_TypeTagForDatatype:
 handleTypeTagForDatatypeAttr(S, D, Attr);
 break;
-
   case AttributeList::AT_RenderScriptKernel:
 handleSimpleAttribute(S, D, Attr);
 break;
+  // XRay attributes.
+  case AttributeList::AT_XRayInstrument:
+handleSimpleAttribute(S, D, Attr);
+break;
   }
 }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -685,6 +685,9 @@
   }
 
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
+  Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
+  Opts.XRayInstructionThreshold =
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
   Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3178,6 +3178,28 @@
   return !StaticRuntimes.empty();
 }
 
+static bool addXRayRuntime(const ToolChain , const ArgList ,
+   ArgStringList ) {
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+  CmdArgs.push_back("-latomic");
+  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
+CmdArgs.push_back("-ldl");
+}
+
 static bool areOptimizationsEnabled(const ArgList ) {
   // Find the last -O arg and see if it is non-zero.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group))
@@ -4579,6 +4601,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+  

Re: [PATCH] D20352: Add XRay flags to Clang

2016-06-22 Thread Dean Michael Berris via cfe-commits
dberris updated this revision to Diff 61567.
dberris added a comment.

- Merge branch 'master' of http://llvm.org/git/clang into xray
- Merge branch 'master' of http://llvm.org/git/clang into xray
- Add runtime support for XRay


http://reviews.llvm.org/D20352

Files:
  include/clang/Basic/Attr.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/xray-always-instrument-attr.c
  test/Sema/xray-always-instrument-attr.cpp

Index: test/Sema/xray-always-instrument-attr.cpp
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+void foo [[clang::xray_always_instrument]] ();
+
+struct [[clang::xray_always_instrument]] a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+class b {
+ void c [[clang::xray_always_instrument]] ();
+};
Index: test/Sema/xray-always-instrument-attr.c
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11
+void foo() __attribute__((xray_always_instrument));
+
+struct __attribute__((xray_always_instrument)) a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5913,10 +5913,16 @@
   case AttributeList::AT_TypeTagForDatatype:
 handleTypeTagForDatatypeAttr(S, D, Attr);
 break;
-
   case AttributeList::AT_RenderScriptKernel:
 handleSimpleAttribute(S, D, Attr);
 break;
+  // XRay attributes.
+  case AttributeList::AT_XRayAlwaysInstrument:
+handleSimpleAttribute(S, D, Attr);
+break;
+  case AttributeList::AT_XRayNeverInstrument:
+handleSimpleAttribute(S, D, Attr);
+break;
   }
 }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -680,6 +680,9 @@
   }
 
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
+  Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
+  Opts.XRayInstructionThreshold =
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
   Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3159,6 +3159,28 @@
   return !StaticRuntimes.empty();
 }
 
+static bool addXRayRuntime(const ToolChain , const ArgList ,
+   ArgStringList ) {
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+  CmdArgs.push_back("-latomic");
+  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
+CmdArgs.push_back("-ldl");
+}
+
 static bool areOptimizationsEnabled(const ArgList ) {
   // Find the last -O arg and see if it is non-zero.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group))
@@ -4557,6 +4579,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-fxray-instrument");
+if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
+ options::OPT_fxray_instruction_threshold_EQ)) {
+  CmdArgs.push_back("-fxray-instruction-threshold");
+  CmdArgs.push_back(A->getValue());
+}
+  }
+
   addPGOAndCoverageFlags(C, D, Output, Args, CmdArgs);
 
   // Add runtime flag for PS4 when PGO or Coverage are enabled.
@@ -9290,6 +9322,7 @@
 CmdArgs.push_back("--no-demangle");
 
   bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
+  bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);
   // The profile runtime also needs access to system libraries.