[PATCH] D47097: [DebugInfo] Preserve scope in auto generated StoreInst

Adrian Prantl via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 23 11:43:17 PDT 2018


aprantl added inline comments.


================
Comment at: lib/CodeGen/CGExpr.cpp:72
+  // Set debug location in order to preserve the scope
+  Alloca->setDebugLoc(Builder.getCurrentDebugLocation());
   if (AllocaAddr)
----------------
vsk wrote:
> I think we need to be a bit more careful here. The current debug location stored in the builder may not be an artificial 0-location. This may cause non-linear single-stepping behavior. Consider this example:
> 
> ```
> void foo() {
>   bar();
>   if (...) {
>     int var = ...; //< Clang emits an alloca for "var".
>   }
> ...
> ```
> 
> The current debug location at the line "int var = ..." would be at line 4. But the alloca is emitted in the entry block of the function. In the debugger, this may result in strange single-stepping behavior when stepping into foo(). You could step to line 4, then line 2, then line 3, then line 4 again.
> 
> I think we can avoid that by setting an artificial location on allocas.
> I think we can avoid that by setting an artificial location on allocas.
An alloca doesn't really generate any code (or rather.. the code it generates is in the function prologue). In what situation would the debug location on an alloca influence stepping? Are you thinking about the alloca() function?


Repository:
  rC Clang

https://reviews.llvm.org/D47097





More information about the cfe-commits mailing list