Diagnostic source location accuracy with and without remarks enabled

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Diagnostic source location accuracy with and without remarks enabled

Kristóf Umann via cfe-dev
I'm trying to get some insight into why source locations in a warning resolve differently when remarks are enabled in a cc1 invocation. 

In a diagnostic handler I have two diagnostics being emitted(one warning and one remark), but the accuracy of the source location changes dramatically if I request remarks to be emitted through '-R<remark>'. Note that I don't mean the specific remark I'm emitting, I mean *any* remark.

More concretely, when I enable the warning and request no remarks, I get a source location that is the beginning of the function. However, if I enable any remarks(such as for the inliner pass), the source location becomes fully accurate for the warning(i.e. pointing to a branch location in the function body).

The invocations only differ in a small way:

clang -cc1 source.ll -Wmisexpect <... rest of invocation>

vs.

clang -cc1 source.ll -Wmisexpect -R<anything> <... rest of invocation> 

I ran into this when working on some tests in https://reviews.llvm.org/D66324, and I'm having trouble understanding why this is happening. The same source location is passed to both diagnostics. This behavior also doesn't seem to appear if I don't use cc1 directly, but I would still like to understand this behavior.

Can someone explain why enabling remarks here has an effect on the accuracy of the source locations? Do they cause a delay in the source location resolution, or is there an important piece of infrastructure that the remarks framework enables that I've missed?

For reference my backend diagnostic handler looks something like the following snippet where the source location is passed to both the warning and remark:

```
void BackendConsumer::MisExpectDiagHandler(
    const llvm::DiagnosticInfoMisExpect &D) {
  StringRef Filename;
  unsigned Line, Column;
  bool BadDebugInfo = false;
  FullSourceLoc Loc =
      getBestLocationFromDebugLoc(D, BadDebugInfo, Filename, Line, Column);

  Diags.Report(Loc, diag::warn_misexpect) << D.getMsg().str();
  Diags.Report(Loc, diag::remark_misexpect) << D.getMsg().str();
 
  // ...
}
```


--
Paul Kirth

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Diagnostic source location accuracy with and without remarks enabled

Kristóf Umann via cfe-dev


On Aug 16, 2019, at 8:17 PM, Paul Kirth <[hidden email]> wrote:

I'm trying to get some insight into why source locations in a warning resolve differently when remarks are enabled in a cc1 invocation. 

In a diagnostic handler I have two diagnostics being emitted(one warning and one remark), but the accuracy of the source location changes dramatically if I request remarks to be emitted through '-R<remark>'. Note that I don't mean the specific remark I'm emitting, I mean *any* remark.

More concretely, when I enable the warning and request no remarks, I get a source location that is the beginning of the function. However, if I enable any remarks(such as for the inliner pass), the source location becomes fully accurate for the warning(i.e. pointing to a branch location in the function body).

Requesting remarks implies -gline-tables-only.

Adam


The invocations only differ in a small way:

clang -cc1 source.ll -Wmisexpect <... rest of invocation>

vs.

clang -cc1 source.ll -Wmisexpect -R<anything> <... rest of invocation> 

I ran into this when working on some tests in https://reviews.llvm.org/D66324, and I'm having trouble understanding why this is happening. The same source location is passed to both diagnostics. This behavior also doesn't seem to appear if I don't use cc1 directly, but I would still like to understand this behavior.

Can someone explain why enabling remarks here has an effect on the accuracy of the source locations? Do they cause a delay in the source location resolution, or is there an important piece of infrastructure that the remarks framework enables that I've missed?

For reference my backend diagnostic handler looks something like the following snippet where the source location is passed to both the warning and remark:

```
void BackendConsumer::MisExpectDiagHandler(
    const llvm::DiagnosticInfoMisExpect &D) {
  StringRef Filename;
  unsigned Line, Column;
  bool BadDebugInfo = false;
  FullSourceLoc Loc =
      getBestLocationFromDebugLoc(D, BadDebugInfo, Filename, Line, Column);

  Diags.Report(Loc, diag::warn_misexpect) << D.getMsg().str();
  Diags.Report(Loc, diag::remark_misexpect) << D.getMsg().str();
 
  // ...
}
```


--
Paul Kirth


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Diagnostic source location accuracy with and without remarks enabled

Kristóf Umann via cfe-dev


On Fri, Aug 16, 2019 at 9:56 PM Adam Nemet <[hidden email]> wrote:


On Aug 16, 2019, at 8:17 PM, Paul Kirth <[hidden email]> wrote:

I'm trying to get some insight into why source locations in a warning resolve differently when remarks are enabled in a cc1 invocation. 

In a diagnostic handler I have two diagnostics being emitted(one warning and one remark), but the accuracy of the source location changes dramatically if I request remarks to be emitted through '-R<remark>'. Note that I don't mean the specific remark I'm emitting, I mean *any* remark.

More concretely, when I enable the warning and request no remarks, I get a source location that is the beginning of the function. However, if I enable any remarks(such as for the inliner pass), the source location becomes fully accurate for the warning(i.e. pointing to a branch location in the function body).

Requesting remarks implies -gline-tables-only.


Thanks for the clarification, that makes more sense. 
 
Adam


The invocations only differ in a small way:

clang -cc1 source.ll -Wmisexpect <... rest of invocation>

vs.

clang -cc1 source.ll -Wmisexpect -R<anything> <... rest of invocation> 

I ran into this when working on some tests in https://reviews.llvm.org/D66324, and I'm having trouble understanding why this is happening. The same source location is passed to both diagnostics. This behavior also doesn't seem to appear if I don't use cc1 directly, but I would still like to understand this behavior.

Can someone explain why enabling remarks here has an effect on the accuracy of the source locations? Do they cause a delay in the source location resolution, or is there an important piece of infrastructure that the remarks framework enables that I've missed?

For reference my backend diagnostic handler looks something like the following snippet where the source location is passed to both the warning and remark:

```
void BackendConsumer::MisExpectDiagHandler(
    const llvm::DiagnosticInfoMisExpect &D) {
  StringRef Filename;
  unsigned Line, Column;
  bool BadDebugInfo = false;
  FullSourceLoc Loc =
      getBestLocationFromDebugLoc(D, BadDebugInfo, Filename, Line, Column);

  Diags.Report(Loc, diag::warn_misexpect) << D.getMsg().str();
  Diags.Report(Loc, diag::remark_misexpect) << D.getMsg().str();
 
  // ...
}
```


--
Paul Kirth



--
Paul Kirth

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev