-
Since LLVM IR does not have a built in not operator it performs not operations with the xor (See CreateNot() https://llvm.org/doxygen/classllvm_1_1BinaryOperator.html). Here a xor operation is done with the operand and a constant with all 1 bits. LLVM uses i1 for boolean constants (https://llvm.org/docs/LangRef.html#simple-constants), and declaring boolean as i1 will generate the below IR. As we are currently using i8 for boolean, this will carry out the xor with 111111112 or -1 This introduces a bug where the value of the boolean variable becomes -1 or -2 for 0 and 1 respectively. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Sounds good to me |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
+1
Ref : https://stackoverflow.com/a/36166536