Remove immarg from llvm.expect
The LangRef claimed this was required to be a constant, but this
appears to be wrong.
Fixes bug 41079.
llvm-svn: 356353
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 009f855..fcea8a4 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -15819,8 +15819,7 @@
""""""""""
The ``llvm.expect`` intrinsic takes two arguments. The first argument is
-a value. The second argument is an expected value, this needs to be a
-constant value, variables are not allowed.
+a value. The second argument is an expected value.
Semantics:
""""""""""
diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td
index 680fd14..b26a26f 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -689,13 +689,13 @@
llvm_metadata_ty ]>;
}
// FIXME: Add intrinsics for fcmp, fptrunc, fpext, fptoui and fptosi.
-// FIXME: Add intrinsics for fabs and copysign?
+// FIXME: Add intrinsics for fabs and copysign?
//===------------------------- Expect Intrinsics --------------------------===//
//
def int_expect : Intrinsic<[llvm_anyint_ty],
- [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem, ImmArg<1>]>;
+ [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>;
//===-------------------- Bit Manipulation Intrinsics ---------------------===//
//
diff --git a/llvm/test/Transforms/LowerExpectIntrinsic/PR33346.ll b/llvm/test/Transforms/LowerExpectIntrinsic/PR33346.ll
index 5bcf934..ca962fb 100644
--- a/llvm/test/Transforms/LowerExpectIntrinsic/PR33346.ll
+++ b/llvm/test/Transforms/LowerExpectIntrinsic/PR33346.ll
@@ -7,12 +7,12 @@
store i64 %arg, i64* %tmp, align 8
%tmp1 = load i64, i64* %tmp, align 8
%tmp2 = load i64, i64* %tmp, align 8
- %tmp3 = call i64 @llvm.expect.i64(i64 %tmp1, i64 123)
+ %tmp3 = call i64 @llvm.expect.i64(i64 %tmp1, i64 %tmp2)
ret i64 %tmp3
}
; Function Attrs: nounwind readnone
-declare i64 @llvm.expect.i64(i64, i64 immarg)
+declare i64 @llvm.expect.i64(i64, i64)
!llvm.module.flags = !{!0}
diff --git a/llvm/test/Verifier/intrinsic-immarg.ll b/llvm/test/Verifier/intrinsic-immarg.ll
index 4a701dd..0be3999 100644
--- a/llvm/test/Verifier/intrinsic-immarg.ll
+++ b/llvm/test/Verifier/intrinsic-immarg.ll
@@ -65,15 +65,6 @@
ret void
}
-declare i8 @llvm.expect.i8(i8, i8)
-define i8 @expect(i8 %arg0, i8 %arg1) {
- ; CHECK: immarg operand has non-immediate parameter
- ; CHECK-NEXT: i8 %arg1
- ; CHECK-NEXT: %ret = call i8 @llvm.expect.i8(i8 %arg0, i8 %arg1)
- %ret = call i8 @llvm.expect.i8(i8 %arg0, i8 %arg1)
- ret i8 %ret
-}
-
declare i64 @llvm.smul.fix.i64(i64, i64, i32)
define i64 @smul_fix(i64 %arg0, i64 %arg1, i32 %arg2) {
; CHECK: immarg operand has non-immediate parameter