summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-03-19 18:21:43 +0000
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-03-19 18:21:43 +0000
commit064774f753a093f484b524eb5b3847da48dcad8d (patch)
tree6465a9303f05be43b19400c589a63b98c0e2045f /llvm/include
parent9ef60a2539b268f40052f61149aab6c2442732aa (diff)
downloadbcm5719-llvm-064774f753a093f484b524eb5b3847da48dcad8d.tar.gz
bcm5719-llvm-064774f753a093f484b524eb5b3847da48dcad8d.zip
Revert "[Remarks] Add a new Remark / RemarkParser abstraction"
This reverts commit 51dc6a8c84cd6a58562e320e1828a0158dbbf750. Breaks http://lab.llvm.org:8011/builders/clang-cmake-x86_64-sde-avx512-linux/builds/20034/steps/build%20stage%201/logs/stdio. llvm-svn: 356492
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm-c/Remarks.h223
-rw-r--r--llvm/include/llvm/Remarks/Remark.h98
-rw-r--r--llvm/include/llvm/Remarks/RemarkParser.h46
3 files changed, 55 insertions, 312 deletions
diff --git a/llvm/include/llvm-c/Remarks.h b/llvm/include/llvm-c/Remarks.h
index e57ca3cd8f5..901acac76d9 100644
--- a/llvm/include/llvm-c/Remarks.h
+++ b/llvm/include/llvm-c/Remarks.h
@@ -34,201 +34,86 @@ extern "C" {
#define REMARKS_API_VERSION 0
/**
- * The type of the emitted remark.
- */
-enum LLVMRemarkType {
- LLVMRemarkTypeUnknown,
- LLVMRemarkTypePassed,
- LLVMRemarkTypeMissed,
- LLVMRemarkTypeAnalysis,
- LLVMRemarkTypeAnalysisFPCommute,
- LLVMRemarkTypeAnalysisAliasing,
- LLVMRemarkTypeFailure
-};
-
-/**
* String containing a buffer and a length. The buffer is not guaranteed to be
* zero-terminated.
*
* \since REMARKS_API_VERSION=0
*/
-typedef struct LLVMRemarkOpaqueString *LLVMRemarkStringRef;
-
-/**
- * Returns the buffer holding the string.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern const char *LLVMRemarkStringGetData(LLVMRemarkStringRef String);
-
-/**
- * Returns the size of the string.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern uint32_t LLVMRemarkStringGetLen(LLVMRemarkStringRef String);
+typedef struct {
+ const char *Str;
+ uint32_t Len;
+} LLVMRemarkStringRef;
/**
* DebugLoc containing File, Line and Column.
*
* \since REMARKS_API_VERSION=0
*/
-typedef struct LLVMRemarkOpaqueDebugLoc *LLVMRemarkDebugLocRef;
-
-/**
- * Return the path to the source file for a debug location.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern LLVMRemarkStringRef
-LLVMRemarkDebugLocGetSourceFilePath(LLVMRemarkDebugLocRef DL);
-
-/**
- * Return the line in the source file for a debug location.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern uint32_t LLVMRemarkDebugLocGetSourceLine(LLVMRemarkDebugLocRef DL);
-
-/**
- * Return the column in the source file for a debug location.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern uint32_t LLVMRemarkDebugLocGetSourceColumn(LLVMRemarkDebugLocRef DL);
+typedef struct {
+ // File:
+ LLVMRemarkStringRef SourceFile;
+ // Line:
+ uint32_t SourceLineNumber;
+ // Column:
+ uint32_t SourceColumnNumber;
+} LLVMRemarkDebugLoc;
/**
* Element of the "Args" list. The key might give more information about what
- * the semantics of the value are, e.g. "Callee" will tell you that the value
+ * are the semantics of the value, e.g. "Callee" will tell you that the value
* is a symbol that names a function.
*
* \since REMARKS_API_VERSION=0
*/
-typedef struct LLVMRemarkOpaqueArg *LLVMRemarkArgRef;
+typedef struct {
+ // e.g. "Callee"
+ LLVMRemarkStringRef Key;
+ // e.g. "malloc"
+ LLVMRemarkStringRef Value;
-/**
- * Returns the key of an argument. The key defines what the value is, and the
- * same key can appear multiple times in the list of arguments.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern LLVMRemarkStringRef LLVMRemarkArgGetKey(LLVMRemarkArgRef Arg);
+ // "DebugLoc": Optional
+ LLVMRemarkDebugLoc DebugLoc;
+} LLVMRemarkArg;
/**
- * Returns the value of an argument. This is a string that can contain newlines.
+ * One remark entry.
*
* \since REMARKS_API_VERSION=0
*/
-extern LLVMRemarkStringRef LLVMRemarkArgGetValue(LLVMRemarkArgRef Arg);
+typedef struct {
+ // e.g. !Missed, !Passed
+ LLVMRemarkStringRef RemarkType;
+ // "Pass": Required
+ LLVMRemarkStringRef PassName;
+ // "Name": Required
+ LLVMRemarkStringRef RemarkName;
+ // "Function": Required
+ LLVMRemarkStringRef FunctionName;
-/**
- * Returns the debug location that is attached to the value of this argument.
- *
- * If there is no debug location, the return value will be `NULL`.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern LLVMRemarkDebugLocRef LLVMRemarkArgGetDebugLoc(LLVMRemarkArgRef Arg);
-
-/**
- * A remark emitted by the compiler.
- *
- * \since REMARKS_API_VERSION=0
- */
-typedef struct LLVMRemarkOpaqueEntry *LLVMRemarkEntryRef;
-
-/**
- * The type of the remark. For example, it can allow users to only keep the
- * missed optimizations from the compiler.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern enum LLVMRemarkType LLVMRemarkEntryGetType(LLVMRemarkEntryRef Remark);
-
-/**
- * Get the name of the pass that emitted this remark.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern LLVMRemarkStringRef
-LLVMRemarkEntryGetPassName(LLVMRemarkEntryRef Remark);
-
-/**
- * Get an identifier of the remark.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern LLVMRemarkStringRef
-LLVMRemarkEntryGetRemarkName(LLVMRemarkEntryRef Remark);
-
-/**
- * Get the name of the function being processsed when the remark was emitted.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern LLVMRemarkStringRef
-LLVMRemarkEntryGetFunctionName(LLVMRemarkEntryRef Remark);
-
-/**
- * Returns the debug location that is attached to this remark.
- *
- * If there is no debug location, the return value will be `NULL`.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern LLVMRemarkDebugLocRef
-LLVMRemarkEntryGetDebugLoc(LLVMRemarkEntryRef Remark);
-
-/**
- * Return the hotness of the remark.
- *
- * A hotness of `0` means this value is not set.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern uint64_t LLVMRemarkEntryGetHotness(LLVMRemarkEntryRef Remark);
-
-/**
- * The number of arguments the remark holds.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern uint32_t LLVMRemarkEntryGetNumArgs(LLVMRemarkEntryRef Remark);
-
-/**
- * Get a new iterator to iterate over a remark's argument.
- *
- * If there are no arguments in \p Remark, the return value will be `NULL`.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern LLVMRemarkArgRef LLVMRemarkEntryGetFirstArg(LLVMRemarkEntryRef Remark);
-
-/**
- * Get the next argument in \p Remark from the position of \p It.
- *
- * Returns `NULL` if there are no more arguments available.
- *
- * \since REMARKS_API_VERSION=0
- */
-extern LLVMRemarkArgRef LLVMRemarkEntryGetNextArg(LLVMRemarkArgRef It,
- LLVMRemarkEntryRef Remark);
+ // "DebugLoc": Optional
+ LLVMRemarkDebugLoc DebugLoc;
+ // "Hotness": Optional
+ uint32_t Hotness;
+ // "Args": Optional. It is an array of `num_args` elements.
+ uint32_t NumArgs;
+ LLVMRemarkArg *Args;
+} LLVMRemarkEntry;
typedef struct LLVMRemarkOpaqueParser *LLVMRemarkParserRef;
/**
- * Creates a remark parser that can be used to parse the buffer located in \p
- * Buf of size \p Size bytes.
+ * Creates a remark parser that can be used to read and parse the buffer located
+ * in \p Buf of size \p Size.
*
- * \p Buf cannot be `NULL`.
+ * \p Buf cannot be NULL.
*
* This function should be paired with LLVMRemarkParserDispose() to avoid
* leaking resources.
*
* \since REMARKS_API_VERSION=0
*/
-extern LLVMRemarkParserRef LLVMRemarkParserCreateYAML(const void *Buf,
- uint64_t Size);
+extern LLVMRemarkParserRef LLVMRemarkParserCreate(const void *Buf,
+ uint64_t Size);
/**
* Returns the next remark in the file.
@@ -236,9 +121,9 @@ extern LLVMRemarkParserRef LLVMRemarkParserCreateYAML(const void *Buf,
* The value pointed to by the return value is invalidated by the next call to
* LLVMRemarkParserGetNext().
*
- * If the parser reaches the end of the buffer, the return value will be `NULL`.
+ * If the parser reaches the end of the buffer, the return value will be NULL.
*
- * In the case of an error, the return value will be `NULL`, and:
+ * In the case of an error, the return value will be NULL, and:
*
* 1) LLVMRemarkParserHasError() will return `1`.
*
@@ -249,16 +134,18 @@ extern LLVMRemarkParserRef LLVMRemarkParserCreateYAML(const void *Buf,
*
* 1) An argument is invalid.
*
- * 2) There is a parsing error. This can occur on things like malformed YAML.
+ * 2) There is a YAML parsing error. This type of error aborts parsing
+ * immediately and returns `1`. It can occur on malformed YAML.
*
- * 3) There is a Remark semantic error. This can occur on well-formed files with
- * missing or extra fields.
+ * 3) Remark parsing error. If this type of error occurs, the parser won't call
+ * the handler and will continue to the next one. It can occur on malformed
+ * remarks, like missing or extra fields in the file.
*
* Here is a quick example of the usage:
*
* ```
- * LLVMRemarkParserRef Parser = LLVMRemarkParserCreateYAML(Buf, Size);
- * LLVMRemarkEntryRef Remark = NULL;
+ * LLVMRemarkParserRef Parser = LLVMRemarkParserCreate(Buf, Size);
+ * LLVMRemarkEntry *Remark = NULL;
* while ((Remark == LLVMRemarkParserGetNext(Parser))) {
* // use Remark
* }
@@ -268,7 +155,7 @@ extern LLVMRemarkParserRef LLVMRemarkParserCreateYAML(const void *Buf,
*
* \since REMARKS_API_VERSION=0
*/
-extern LLVMRemarkEntryRef LLVMRemarkParserGetNext(LLVMRemarkParserRef Parser);
+extern LLVMRemarkEntry *LLVMRemarkParserGetNext(LLVMRemarkParserRef Parser);
/**
* Returns `1` if the parser encountered an error while parsing the buffer.
@@ -298,7 +185,7 @@ extern const char *LLVMRemarkParserGetErrorMessage(LLVMRemarkParserRef Parser);
extern void LLVMRemarkParserDispose(LLVMRemarkParserRef Parser);
/**
- * Returns the version of the remarks library.
+ * Returns the version of the remarks dylib.
*
* \since REMARKS_API_VERSION=0
*/
diff --git a/llvm/include/llvm/Remarks/Remark.h b/llvm/include/llvm/Remarks/Remark.h
deleted file mode 100644
index 67fa1718808..00000000000
--- a/llvm/include/llvm/Remarks/Remark.h
+++ /dev/null
@@ -1,98 +0,0 @@
-//===-- llvm/Remarks/Remark.h - The remark type -----------------*- C++/-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines an abstraction for handling remarks.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_REMARKS_REMARK_H
-#define LLVM_REMARKS_REMARK_H
-
-#include "llvm-c/Remarks.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Optional.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/CBindingWrapping.h"
-#include <string>
-
-namespace llvm {
-namespace remarks {
-
-/// The debug location used to track a remark back to the source file.
-struct RemarkLocation {
- /// Absolute path of the source file corresponding to this remark.
- StringRef SourceFilePath;
- unsigned SourceLine;
- unsigned SourceColumn;
-};
-
-// Create wrappers for C Binding types (see CBindingWrapping.h).
-DEFINE_SIMPLE_CONVERSION_FUNCTIONS(RemarkLocation, LLVMRemarkDebugLocRef)
-
-/// A key-value pair with a debug location that is used to display the remarks
-/// at the right place in the source.
-struct Argument {
- StringRef Key;
- // FIXME: We might want to be able to store other types than strings here.
- StringRef Val;
- // If set, the debug location corresponding to the value.
- Optional<RemarkLocation> Loc;
-};
-
-// Create wrappers for C Binding types (see CBindingWrapping.h).
-DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Argument, LLVMRemarkArgRef)
-
-/// The type of the remark.
-enum class Type {
- Unknown,
- Passed,
- Missed,
- Analysis,
- AnalysisFPCommute,
- AnalysisAliasing,
- Failure,
- LastTypeValue = Failure
-};
-
-/// A remark type used for both emission and parsing.
-struct Remark {
- /// The type of the remark.
- enum Type RemarkType = Type::Unknown;
-
- /// Name of the pass that triggers the emission of this remark.
- StringRef PassName;
-
- /// Textual identifier for the remark (single-word, camel-case). Can be used
- /// by external tools reading the output file for remarks to identify the
- /// remark.
- StringRef RemarkName;
-
- /// Mangled name of the function that triggers the emssion of this remark.
- StringRef FunctionName;
-
- /// The location in the source file of the remark.
- Optional<RemarkLocation> Loc;
-
- /// If profile information is available, this is the number of times the
- /// corresponding code was executed in a profile instrumentation run.
- Optional<uint64_t> Hotness;
-
- /// Arguments collected via the streaming interface.
- ArrayRef<Argument> Args;
-
- /// Return a message composed from the arguments as a string.
- std::string getArgsAsMsg() const;
-};
-
-// Create wrappers for C Binding types (see CBindingWrapping.h).
-DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Remark, LLVMRemarkEntryRef)
-
-} // end namespace remarks
-} // end namespace llvm
-
-#endif /* LLVM_REMARKS_REMARK_H */
diff --git a/llvm/include/llvm/Remarks/RemarkParser.h b/llvm/include/llvm/Remarks/RemarkParser.h
deleted file mode 100644
index fb8d4c6021a..00000000000
--- a/llvm/include/llvm/Remarks/RemarkParser.h
+++ /dev/null
@@ -1,46 +0,0 @@
-//===-- llvm/Remarks/Remark.h - The remark type -----------------*- C++/-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides an interface for parsing remarks in LLVM.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_REMARKS_REMARK_PARSER_H
-#define LLVM_REMARKS_REMARK_PARSER_H
-
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Remarks/Remark.h"
-#include "llvm/Support/Error.h"
-#include <memory>
-
-namespace llvm {
-namespace remarks {
-
-struct ParserImpl;
-
-/// Parser used to parse a raw buffer to remarks::Remark objects.
-struct Parser {
- /// The hidden implementation of the parser.
- std::unique_ptr<ParserImpl> Impl;
-
- /// Create a parser parsing \p Buffer to Remark objects.
- /// This constructor should be only used for parsing YAML remarks.
- Parser(StringRef Buffer);
-
- // Needed because ParserImpl is an incomplete type.
- ~Parser();
-
- /// Returns an empty Optional if it reached the end.
- /// Returns a valid remark otherwise.
- Expected<const Remark *> getNext() const;
-};
-
-} // end namespace remarks
-} // end namespace llvm
-
-#endif /* LLVM_REMARKS_REMARK_PARSER_H */
OpenPOWER on IntegriCloud