[PATCH] D22825: Add a counter-function insertion pass

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 27 19:41:12 PDT 2016


hfinkel added inline comments.

================
Comment at: test/Transforms/CountingFunctionInserter/mcount.ll:26
@@ +25,3 @@
+attributes #0 = { "counting-function"="mcount" }
+attributes #1 = { "counting-function"=".mcount" }
+
----------------
honggyu.kim wrote:
> Is there a reason that we have to explicitly provide name of "counting-function" attribute? Would it be better to get the name from TargetInfo? I need to find a way to get TargetInfo in FunctionPass first thought.  I think we better not to increase target-dependency in IR level even if it's just attributes because mcount name is kind of target-dependent.
> Is there a reason that we have to explicitly provide name of "counting-function" attribute? Would it be better to get the name from TargetInfo?

Because the functionality might be useful for cases outside of -pg (and might even be useful for a tracing JIT), and there's no need to make a trivially-generalizable functionality artificially specific, I think it makes sense to make the function name something the IR-generator can specify.

> I think we better not to increase target-dependency in IR level even if it's just attributes because mcount name is kind of target-dependent.

I'm fine with having a target-specific default. We'd move the current logic for setting the mcount name into initialize in lib/Analysis/TargetLibraryInfo.cpp - see, for example, the calls to TLI.setAvailableWithName in that function.


https://reviews.llvm.org/D22825





More information about the llvm-commits mailing list