[clang] [CIR] Add side effect attribute to call operations (PR #144201)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 17 11:21:42 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
----------------
andykaylor wrote:
I didn't necessarily mean to say I wanted to change this in order to be consistent with the LLVM IR representation. I just think that's a better, more general representation. To me `pure` and `const` are unclear, particularly given that both terms have conflicting meanings in C++.
Do we represent side-effects on LLVM intrinsic calls? Those would require a richer representation. It would also be nice to mark things like whether a function modifies `errno` or whether it depends on or modifies the floating-point environment.
https://github.com/llvm/llvm-project/pull/144201
More information about the cfe-commits
mailing list