As per the LLVM language reference (https://llvm.org/docs/LangRef.html), the llvm.annotation intrinsic as no effect on code generation and optimization and therefore can be safely replaced by its first argument. This patch 'teaches' SCEV the semantics of that builtin function.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
From the language reference:
they are ignored by code generation and optimization.
I agree that this means the annotation can be ignored. But it returning the first argument (as mentioned in the summary) is not sufficient to conclude that, e.g. it could have side effects.
I can add a test sure, let's first come to a conclusion on the side-effects comment.
It is not clear to me what side-effects the llvm.annotation intrinsic would need to have. The current documentation states that the intrinsic function can be ignored by code gen and optimizations. That means I could move instructions past the intrinsic since the intrinsic can be ignored. If the intrinsics had side effects that optimization would be illegal, and it follows the intrinsic could not be ignored. Do I make any sense?
I am referring to the summary:
The llvm.annotation intrinsic returns the first argument passed to it.
As mentioned, this is not a sufficient condition to be just ignored. The summary should also mention that by the LLVM language reference, " are ignored by code generation and optimization."
Suggestion:
As by the LLVM language reference, the llvm.annotation intrinsic and no effect on code generation and optimization (https://llvm.org/docs/LangRef.html) and therefore can be safely replaced by its first argument. This patch 'teaches' SCEV the semantics of that builtin function.
I am referring to the summary:
The llvm.annotation intrinsic returns the first argument passed to it.
As mentioned, this is not a sufficient condition to be just ignored. The summary should also mention that by the LLVM language reference, " are ignored by code generation and optimization."
Suggestion:
As by the LLVM language reference, the llvm.annotation intrinsic and no effect on code generation and optimization (https://llvm.org/docs/LangRef.html) and therefore can be safely replaced by its first argument. This patch 'teaches' SCEV the semantics of that builtin function.
Hey Michael, I understand now what you meant. Sure I have updated the description now.