[PATCH] Debug Info: Handle by-reference arguments correctly during inlining.

David Blaikie dblaikie at gmail.com
Fri Jan 16 09:55:48 PST 2015


Comment at: lib/Transforms/Utils/CloneFunction.cpp:291
@@ +290,3 @@
+      Ops.push_back(Expr.getElement(i));
+    return DIBuilder(M, false).createExpression(Ops);
+  }
Does createExpression need a DIBuilder? Does it just need access to a Module? (perhaps it could just be a standalone non-member function that takes a Module?)

Comment at: lib/Transforms/Utils/CloneFunction.cpp:293
@@ +292,3 @@
+  }
+  return DIExpression();
So if during inlining we take a pointer and remove the indirection (eg: a function has "int *x" and "*x + 3" and its called with "int y = ...; func(&y)", etc) we drop the expression entirely? Because we can't describe the value of the pointer when there's nothing to point to, I take it? (that seems correct, just checking I understand correctly)

Is that case tested?

Comment at: lib/Transforms/Utils/CloneFunction.cpp:296
@@ +295,3 @@
+static void updateDebugExpression(const DbgDeclareInst *Orig, DbgDeclareInst *New,
+                                  Module &M) {
These two functions have a lot in common (everything except "getAddress/getValue") - should they be combined in some way (should DbgValueInst/DbgDeclareInst have a common "get" (address or value) for ease of access/consistency - or does that not make sense?)? If not, then at least the rest of the function could be pulled out into a common function or template if necessary)

Comment at: test/DebugInfo/inline-indirect-arg.ll:4
@@ +3,3 @@
+; clang++ -g -std=c++11  -O0  -fno-exceptions -fno-rtti -S -emit-llvm test.cpp  -o test.ll
+; struct B {
+;   long a, b, c;
This seems like a lot of code to test this scenario. Could this be simplified further? (I'd also expect to see some __attribute__((always_inline)) so you don't have to rely on the inliner to pick the right things to inline (You can compile the example with -mllvm -disable-llvm-optzns to get the bitcode before the AlwaysInliner runs (since it'll run at -O0 and a simple "clang -emit-llvm" will get you post-inlined IR, which isn't what you want)))



More information about the llvm-commits mailing list