diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-09-04 12:50:46 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-09-04 12:50:46 -0700 |
commit | f8ea6b0a1ed535c10089d53c93f32cfe0117c812 (patch) | |
tree | d4547468cda1900dd2e8fbb553bb3e0842bdc68b /test/NaCl/Bitcode | |
parent | eb10318143cc0045a053a1973e4aeaf246e53984 (diff) |
PNaCl bitcode reader: Disallow pointer-typed arguments in indirect calls
Make the bitcode reader stricter, so that it disallows pointer
arguments in indirect function calls, which are disallowed by the
PNaCl ABI checker. Pointer arguments in function calls are only
allowed in intrinsic calls, and calls to intrinsics must always be
direct calls, not indirect calls.
This involves removing two tests that specifically test for pointer
args.
This is in preparation for tweaking how indirect calls are
represented, so that they store the call's return type rather than the
function type.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3544
TEST=*.ll tests
Review URL: https://codereview.chromium.org/23660005
Diffstat (limited to 'test/NaCl/Bitcode')
-rw-r--r-- | test/NaCl/Bitcode/call-elide.ll | 99 |
1 files changed, 10 insertions, 89 deletions
diff --git a/test/NaCl/Bitcode/call-elide.ll b/test/NaCl/Bitcode/call-elide.ll index c0b9cfc31b..adcd32a904 100644 --- a/test/NaCl/Bitcode/call-elide.ll +++ b/test/NaCl/Bitcode/call-elide.ll @@ -37,7 +37,7 @@ define void @DirectCall() { ; PF1: <FUNCTION_BLOCK> ; PF1: </CONSTANTS_BLOCK> -; PF1-NEXT: <INST_CALL op0=0 op1=16 op2=1/> +; PF1-NEXT: <INST_CALL op0=0 op1=14 op2=1/> ; PF1-NEXT: <INST_RET/> ; PF1-NEXT: </FUNCTION_BLOCK> @@ -48,7 +48,7 @@ define void @DirectCall() { ; PF2: <FUNCTION_BLOCK> ; PF2: </CONSTANTS_BLOCK> -; PF2-NEXT: <INST_CALL op0=0 op1=16 op2=1/> +; PF2-NEXT: <INST_CALL op0=0 op1=14 op2=1/> ; PF2-NEXT: <INST_RET/> ; PF2-NEXT: </FUNCTION_BLOCK> @@ -73,7 +73,7 @@ define void @DirectCallIntToPtrArg(i32 %i) { ; PF1: <FUNCTION_BLOCK> ; PF1-NEXT: <DECLAREBLOCKS op0=1/> ; PF1-NEXT: <INST_CAST op0=1 op1=4 op2=10/> -; PF1-NEXT: <INST_CALL op0=0 op1=16 op2=1/> +; PF1-NEXT: <INST_CALL op0=0 op1=14 op2=1/> ; PF1-NEXT: <INST_RET/> ; PF1: </FUNCTION_BLOCK> @@ -85,7 +85,7 @@ define void @DirectCallIntToPtrArg(i32 %i) { ; PF2: <FUNCTION_BLOCK> ; PF2-NEXT: <DECLAREBLOCKS op0=1/> -; PF2-NEXT: <INST_CALL op0=0 op1=15 op2=1/> +; PF2-NEXT: <INST_CALL op0=0 op1=13 op2=1/> ; PF2-NEXT: <INST_RET/> ; PF2: </FUNCTION_BLOCK> @@ -110,7 +110,7 @@ define void @DirectCallPtrToIntArg() { ; PF1: </CONSTANTS_BLOCK> ; PF1-NEXT: <INST_ALLOCA op0=1 op1=4/> ; PF1-NEXT: <INST_CAST op0=1 op1=0 op2=9/> -; PF1-NEXT: <INST_CALL op0=0 op1=18 op2=1/> +; PF1-NEXT: <INST_CALL op0=0 op1=16 op2=1/> ; PF1-NEXT: <INST_RET/> ; PF1-NEXT: </FUNCTION_BLOCK> @@ -124,7 +124,7 @@ define void @DirectCallPtrToIntArg() { ; PF2: <FUNCTION_BLOCK> ; PF2: </CONSTANTS_BLOCK> ; PF2-NEXT: <INST_ALLOCA op0=1 op1=4/> -; PF2-NEXT: <INST_CALL op0=0 op1=17 op2=1/> +; PF2-NEXT: <INST_CALL op0=0 op1=15 op2=1/> ; PF2-NEXT: <INST_RET/> ; PF2-NEXT: </FUNCTION_BLOCK> @@ -146,7 +146,7 @@ define void @DirectCallBitcastArg(i32 %i) { ; PF1: <FUNCTION_BLOCK> ; PF1-NEXT: <DECLAREBLOCKS op0=1/> ; PF1-NEXT: <INST_CAST op0=2 op1=4 op2=11/> -; PF1-NEXT: <INST_CALL op0=0 op1=16 op2=1/> +; PF1-NEXT: <INST_CALL op0=0 op1=14 op2=1/> ; PF1-NEXT: <INST_RET/> ; PF1: </FUNCTION_BLOCK> @@ -158,7 +158,7 @@ define void @DirectCallBitcastArg(i32 %i) { ; PF2: <FUNCTION_BLOCK> ; PF2-NEXT: <DECLAREBLOCKS op0=1/> -; PF2-NEXT: <INST_CALL op0=0 op1=15 op2=2/> +; PF2-NEXT: <INST_CALL op0=0 op1=13 op2=2/> ; PF2-NEXT: <INST_RET/> ; PF2: </FUNCTION_BLOCK> @@ -180,7 +180,7 @@ define void @DirectCallScalarArg(i32* %ptr) { ; PF1: <FUNCTION_BLOCK> ; PF1-NEXT: <DECLAREBLOCKS op0=1/> ; PF1-NEXT: <INST_CAST op0=2 op1=0 op2=9/> -; PF1-NEXT: <INST_CALL op0=0 op1=17 op2=1/> +; PF1-NEXT: <INST_CALL op0=0 op1=15 op2=1/> ; PF1-NEXT: <INST_RET/> ; PF1: </FUNCTION_BLOCK> @@ -192,7 +192,7 @@ define void @DirectCallScalarArg(i32* %ptr) { ; PF2: <FUNCTION_BLOCK> ; PF2-NEXT: <DECLAREBLOCKS op0=1/> -; PF2-NEXT: <INST_CALL op0=0 op1=16 op2=2/> +; PF2-NEXT: <INST_CALL op0=0 op1=14 op2=2/> ; PF2-NEXT: <INST_RET/> ; PF2: </FUNCTION_BLOCK> @@ -274,85 +274,6 @@ define void @IndirectCallPtrToIntArg(i32 %i) { ; PF2: </FUNCTION_BLOCK> ; ------------------------------------------------------ -; Test how we handle a direct call with a normalized inttoptr argument. -; Note: This code doesn't follow the PNaCl ABI in that function -; calls can't get pointer arguments. However, intrinsic calls can, and -; this code is a placeholder for such a test. - -define void @IndirectCallIntToPtrArg(i32 %i) { - %1 = inttoptr i32 %i to i32 (i32*)* - %2 = inttoptr i32 %i to i32* - %3 = call i32 %1(i32* %2) - ret void -} - -; TD1: define void @IndirectCallIntToPtrArg(i32 %i) { -; TD1-NEXT: %1 = inttoptr i32 %i to i32 (i32*)* -; TD1-NEXT: %2 = inttoptr i32 %i to i32* -; TD1-NEXT: %3 = call i32 %1(i32* %2) -; TD1-NEXT: ret void -; TD1-NEXT: } - -; PF1: <FUNCTION_BLOCK> -; PF1-NEXT: <DECLAREBLOCKS op0=1/> -; PF1-NEXT: <INST_CAST op0=1 op1=6 op2=10/> -; PF1-NEXT: <INST_CAST op0=2 op1=4 op2=10/> -; PF1-NEXT: <INST_CALL op0=0 op1=2 op2=1/> -; PF1-NEXT: <INST_RET/> -; PF1: </FUNCTION_BLOCK> - -; TD2: define void @IndirectCallIntToPtrArg(i32 %i) { -; TD2-NEXT: %1 = inttoptr i32 %i to i32 (i32*)* -; TD2-NEXT: %2 = inttoptr i32 %i to i32* -; TD2-NEXT: %3 = call i32 %1(i32* %2) -; TD2-NEXT: ret void -; TD2-NEXT: } - -; PF2: <FUNCTION_BLOCK> -; PF2-NEXT: <DECLAREBLOCKS op0=1/> -; PF2-NEXT: <INST_CALL_INDIRECT op0=0 op1=1 op2=5 op3=1/> -; PF2-NEXT: <INST_RET/> -; PF2: </FUNCTION_BLOCK> - -; ------------------------------------------------------ -; Test how we handle an indirect call with a normalized bitcast argument. - -define void @IndirectCallBitcastArg(i32 %i) { - %1 = inttoptr i32 %i to i32 (i32*)* - %2 = bitcast [4 x i8]* @bytes to i32* - %3 = call i32 %1(i32* %2) - ret void -} - -; TD1: define void @IndirectCallBitcastArg(i32 %i) { -; TD1-NEXT: %1 = inttoptr i32 %i to i32 (i32*)* -; TD1-NEXT: %2 = bitcast [4 x i8]* @bytes to i32* -; TD1-NEXT: %3 = call i32 %1(i32* %2) -; TD1-NEXT: ret void -; TD1-NEXT: } - -; PF1: <FUNCTION_BLOCK> -; PF1-NEXT: <DECLAREBLOCKS op0=1/> -; PF1-NEXT: <INST_CAST op0=1 op1=6 op2=10/> -; PF1-NEXT: <INST_CAST op0=3 op1=4 op2=11/> -; PF1-NEXT: <INST_CALL op0=0 op1=2 op2=1/> -; PF1-NEXT: <INST_RET/> -; PF1: </FUNCTION_BLOCK> - -; TD2: define void @IndirectCallBitcastArg(i32 %i) { -; TD2-NEXT: %1 = inttoptr i32 %i to i32 (i32*)* -; TD2-NEXT: %2 = bitcast [4 x i8]* @bytes to i32* -; TD2-NEXT: %3 = call i32 %1(i32* %2) -; TD2-NEXT: ret void -; TD2-NEXT: } - -; PF2: <FUNCTION_BLOCK> -; PF2-NEXT: <DECLAREBLOCKS op0=1/> -; PF2-NEXT: <INST_CALL_INDIRECT op0=0 op1=1 op2=5 op3=2/> -; PF2-NEXT: <INST_RET/> -; PF2: </FUNCTION_BLOCK> - -; ------------------------------------------------------ ; Test how we handle an indirect call with a pointer to scalar conversion. define void @IndirectCallScalarArg(i32 %i, i32* %ptr) { |