[PATCH] D30022: [XRay][compiler-rt] Allow for defining defaults at compile-time
Dean Michael Berris via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 17 18:21:25 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295534: [XRay][compiler-rt] Allow for defining defaults at compile-time (authored by dberris).
Changed prior to commit:
https://reviews.llvm.org/D30022?vs=88919&id=89002#toc
Repository:
rL LLVM
https://reviews.llvm.org/D30022
Files:
compiler-rt/trunk/lib/xray/xray_flags.cc
Index: compiler-rt/trunk/lib/xray/xray_flags.cc
===================================================================
--- compiler-rt/trunk/lib/xray/xray_flags.cc
+++ compiler-rt/trunk/lib/xray/xray_flags.cc
@@ -37,6 +37,25 @@
#undef XRAY_FLAG
}
+// This function, as defined with the help of a macro meant to be introduced at
+// build time of the XRay runtime, passes in a statically defined list of
+// options that control XRay. This means users/deployments can tweak the
+// defaults that override the hard-coded defaults in the xray_flags.inc at
+// compile-time using the XRAY_DEFAULT_OPTIONS macro.
+static const char *useCompilerDefinedFlags() XRAY_NEVER_INSTRUMENT {
+#ifdef XRAY_DEFAULT_OPTIONS
+// Do the double-layered string conversion to prevent badly crafted strings
+// provided through the XRAY_DEFAULT_OPTIONS from causing compilation issues (or
+// changing the semantics of the implementation through the macro). This ensures
+// that we convert whatever XRAY_DEFAULT_OPTIONS is defined as a string literal.
+#define XRAY_STRINGIZE(x) #x
+#define XRAY_STRINGIZE_OPTIONS(options) XRAY_STRINGIZE(options)
+ return XRAY_STRINGIZE_OPTIONS(XRAY_DEFAULT_OPTIONS);
+#else
+ return "";
+#endif
+}
+
void initializeFlags() XRAY_NEVER_INSTRUMENT {
SetCommonFlagsDefaults();
auto *F = flags();
@@ -46,9 +65,14 @@
registerXRayFlags(&XRayParser, F);
RegisterCommonFlags(&XRayParser);
- // Override from command line.
+ // Use options defaulted at compile-time for the runtime.
+ const char *XRayCompileFlags = useCompilerDefinedFlags();
+ XRayParser.ParseString(XRayCompileFlags);
+
+ // Override from environment variables.
XRayParser.ParseString(GetEnv("XRAY_OPTIONS"));
+ // Override from command line.
InitializeCommonFlags();
if (Verbosity())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30022.89002.patch
Type: text/x-patch
Size: 1794 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170218/9684cffb/attachment.bin>
More information about the llvm-commits
mailing list