[PATCH] Add DIBuilder functions to build RAUWable DIVariables and DIFunctions.

David Blaikie dblaikie at gmail.com
Mon Sep 15 13:52:27 PDT 2014


================
Comment at: lib/IR/DIBuilder.cpp:1173
@@ -1141,9 +1172,3 @@
 
-/// createFunction - Create a new descriptor for the specified function.
-DISubprogram DIBuilder::createFunction(DIDescriptor Context, StringRef Name,
-                                       StringRef LinkageName, DIFile File,
-                                       unsigned LineNo, DICompositeType Ty,
-                                       bool isLocalToUnit, bool isDefinition,
-                                       unsigned ScopeLine, unsigned Flags,
-                                       bool isOptimized, Function *Fn,
-                                       MDNode *TParams, MDNode *Decl) {
+static DISubprogram
+createFunctionHelper(LLVMContext &VMContext, DIDescriptor Context, StringRef Name,
----------------
friss wrote:
> dblaikie wrote:
> > Since this is a static function, you can make it a template and avoid the std::function dynamic overhead - but I suppose that's a binary size V execution time tradeoff... I don't feel too strongly about it either way, though I'd probably have gone with a template rather than std::function, personally.
> Can do. I find the std::function more self documenting, but it has a sometimes noticeable overhead. I didn't think it would show up on profiles here, but if you prefer I'll happily change that to a template parameter.
Nah, that's fine.

================
Comment at: lib/IR/DIBuilder.cpp:1248
@@ +1247,3 @@
+                              Flags, isOptimized, Fn, TParams, Decl,
+                              [this] (ArrayRef<Value *> Elts) {
+                                return MDNode::getTemporary(VMContext, Elts);
----------------
friss wrote:
> dblaikie wrote:
> > Not sure what the style guide says, but I usually just capture by "[&]" rather than listing the me explicitly (goes for here and above)
> I haven't tried it, but I think [&] wouldn't capture 'this', as it can't be captured by reference. And wouldn't capturing everything by value create a lot of useless copies (in other words, does the compiler only copy what is needed?).
I believe [&] does the right thing for 'this'

& yes, even when using a default capture, only things that are ODR-used within the lambda are captured. Things you don't reference won't be unnecessarily captured.

http://reviews.llvm.org/D5328






More information about the llvm-commits mailing list