In this patch we replace common code patterns with the use of utility
functions for dealing with profiling metadata. There should be no change
in functionality, as the existing checks should be preserved in all
cases.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/include/llvm/IR/Instruction.h | ||
---|---|---|
337–338 | There's an argument for removing this entirely and updating the users to just use extractBranchWeights directly (possibly with a specialization of that function that makes the True/False case convenient). I'm not sure how strongly I feel about it, but all of the branch weight stuff being in one place seems kind of nice. WDYT? | |
341 | Is this used anywhere? We can probably omit it until it is. |
llvm/include/llvm/IR/Instruction.h | ||
---|---|---|
337–338 | I think putting all the branch weights utilities in one place is a good idea. Replacing these users was something I was also thinking about, so maybe that's the way we should do it here. I'll take a look at the users and see if there's a straightforward way to migrate them or if a specialization makes more sense. | |
341 | Yeah, I was hesitant about adding the interface, but wanted to provide an option for switch statements. Since there's currently no users I'll remove the interface. Like you said once someone wants/needs it, It's really easy to add back. |
llvm/lib/IR/Metadata.cpp | ||
---|---|---|
1499 | This should either be removed, or also check for switch stmts. Well, anything branch weights may be attached to |
llvm/lib/IR/Metadata.cpp | ||
---|---|---|
1496–1497 | missing space. |
Respond to comments
- Update Interfaces in LLVM for to use extracBranchWeight instead of extractProfMetadata
- Fix typo
- remove unused API
I've left the extractProfMetadata interface to Instruction, since I'm unsure if we want to force downstream users to update their code. We could alternatively just leave the interface as is, and back out the places where we've update usage.
I'm waffling on that one, and whether those updates should be a separate change, or just done here. There's value in leaving the public interface to Instruction alone. We've already moved the logic into a central place, so I'm less convinced that the rest of the refactor is the best approach.
Since there are other types of prof meta data other than branch weights, I think we should get rid of the extractProfMetaData interface (in the current form) and replace them with extractBranchWeights (as Justin suggested).
Let's go ahead and remove extractProfMetadata. Even if downstream users are depending on it the update is trivial, and we can always put it back temporarily if it turns out to be a bigger issue somehow.
Looks like this doesn't build: http://45.33.8.238/linux/82503/step_4.txt
Please take a look, and revert for now if it takes a while to fix.
Thanks!
Going forward, please build and run tests locally before committing, or at least wait for the precommit bots to complete.
I had tested locally, but you're right I should have waited for the bots to finish after rebaseing too. I'll be more careful in the future.
There's an argument for removing this entirely and updating the users to just use extractBranchWeights directly (possibly with a specialization of that function that makes the True/False case convenient). I'm not sure how strongly I feel about it, but all of the branch weight stuff being in one place seems kind of nice. WDYT?