Index: test/NaCl/PNaClABI/abi-arithmetic-attributes.ll |
diff --git a/test/NaCl/PNaClABI/abi-arithmetic-attributes.ll b/test/NaCl/PNaClABI/abi-arithmetic-attributes.ll |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6be379b104a140ce206a139a1c80fd319688adbf |
--- /dev/null |
+++ b/test/NaCl/PNaClABI/abi-arithmetic-attributes.ll |
@@ -0,0 +1,41 @@ |
+; RUN: not pnacl-abicheck < %s | FileCheck %s |
+ |
+; This tests that the arithmetic attributes "nuw" and "nsw" ("no |
+; unsigned wrap" and "no signed wrap") and "exact" are disallowed by |
+; the PNaCl ABI verifier. |
+ |
+define internal void @allowed_cases() { |
+ %add = add i32 1, 2 |
+ %shl = shl i32 3, 4 |
+ %udiv = udiv i32 4, 2 |
+ %lshr = lshr i32 2, 1 |
+ %ashr = ashr i32 2, 1 |
+ ret void |
+} |
+; CHECK-NOT: disallowed |
+ |
+ |
+define internal void @rejected_cases() { |
+ %add = add nsw i32 1, 2 |
+; CHECK: disallowed: has "nsw" attribute: %add |
+ %shl1 = shl nuw i32 3, 4 |
+; CHECK-NEXT: disallowed: has "nuw" attribute: %shl1 |
+ %sub = sub nsw nuw i32 5, 6 |
+; CHECK-NEXT: disallowed: has "nuw" attribute: %sub |
+ |
+ %lshr = lshr exact i32 2, 1 |
+; CHECK-NEXT: disallowed: has "exact" attribute: %lshr |
+ %ashr = ashr exact i32 2, 1 |
+; CHECK-NEXT: disallowed: has "exact" attribute: %ashr |
+ %udiv = udiv exact i32 4, 2 |
+; CHECK-NEXT: disallowed: has "exact" attribute: %udiv |
+ |
+ ret void |
+} |
+; CHECK-NOT: disallowed |
+ |
+ |
+; This stops the verifier from complaining about the lack of an entry point. |
+define void @_start(i32 %arg) { |
+ ret void |
+} |