[clang] [CIR] Add side effect attribute to call operations (PR #144201)
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 17 11:39:57 PDT 2025
================
@@ -1858,6 +1858,40 @@ def FuncOp : CIR_Op<"func", [
// CallOp
//===----------------------------------------------------------------------===//
+def SE_All : I32EnumAttrCase<"All", 1, "all">;
+def SE_Pure : I32EnumAttrCase<"Pure", 2, "pure">;
+def SE_Const : I32EnumAttrCase<"Const", 3, "const">;
+
+def SideEffect
+ : I32EnumAttr<
+ "SideEffect",
+ "allowed side effects of a function", [SE_All, SE_Pure, SE_Const]> {
+ let description = [{
+ The side effect attribute specifies the possible side effects of the callee
+ of a call operation. This is an enumeration attribute and all possible
+ enumerators are:
+
+ - all: The callee can have any side effects. This is the default if no side
+ effects are explicitly listed.
+ - pure: The callee may read data from memory, but it cannot write data to
----------------
bcardosolopes wrote:
Oh I see, clarity is indeed key, didn't think from that perspective.
> Do we represent side-effects on LLVM intrinsic calls?
If you mean whether `LLVMIntrinsicCallOp` does it, the answer is no but we should (likewise for the whole family of CIR operations that mostly cover intrinsics). We'll definitely need them for things like `llvm/test/Verifier/fp-intrinsics-pass.ll`, etc.
This is a good reminder so we pay close attention for when PRs for all those arrive, so we can make sure those operations will include a way to handle such attributes.
https://github.com/llvm/llvm-project/pull/144201
More information about the cfe-commits
mailing list