For more info for what reason it was invented, goto: http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html
Details
Diff Detail
Event Timeline
include/llvm/IR/IRBuilder.h | ||
---|---|---|
1638–1639 | Suggested wording: Create a call to invariant.group.barrier which stops the optimizer from propagating equality with invariant.group metadata. | |
lib/CodeGen/CodeGenPrepare.cpp | ||
1414–1417 | Do we also discard the !invariant.group metadata on instructions? The backend has pointers to the Value*'s, it would be bad if they used the !invariant.group markers but all the invariant.group.barrier calls had been removed. | |
lib/Transforms/IPO/GlobalOpt.cpp | ||
2507–2508 ↗ | (On Diff #33043) | Why is this safe? We have %p2 = call @invariant.group.barrier(%p1) and we set that %p2 just plain *is* %p1. Then nothing happens until evaluation completes and we commit the changes, which means replacing %p2 with %p1. At the time, why won't that operation miscompile? I can think of two possible reasons, one is that %p1 may be constrained (like, it may be a ConstantExpr) and the other is that we may know that there are no remaining loads of either %p1 or %p2 with !invariant.group on them. In any event, please answer in the form of a comment in this code. :) |
lib/CodeGen/CodeGenPrepare.cpp | ||
---|---|---|
1414–1417 | The question is, does it make any difference? What I understand, is that CodeGenPrepare is done just before machine code generation, which means that additional metadata in load/stores doesn't make any difference. | |
lib/Transforms/IPO/GlobalOpt.cpp | ||
2507–2508 ↗ | (On Diff #33043) | What do you mean about miscompile? |
deleted globalOpt handling because it was invalid, and I want to push this one first.
lib/CodeGen/CodeGenPrepare.cpp | ||
---|---|---|
1414–1417 |
Is there a LangRef change that introduces the barrier? If that's simply in a different review, then LGTM. Usually I'd ask for the feature and the LangRef change to land together, but it also makes sense to put the LangRef update for !invariant.group and @llvm.invariant.group.barrier together.
The LangRef updates are in http://reviews.llvm.org/D11399; approving based on Nick's conditional LGTM.
Suggested wording: Create a call to invariant.group.barrier which stops the optimizer from propagating equality with invariant.group metadata.