diff options
-rw-r--r-- | lib/Analysis/NaCl/PNaClABIVerifyModule.cpp | 36 | ||||
-rw-r--r-- | test/NaCl/PNaClABI/instructions.ll | 10 | ||||
-rw-r--r-- | test/NaCl/PNaClABI/linkagetypes.ll | 5 | ||||
-rw-r--r-- | test/NaCl/PNaClABI/types.ll | 12 |
4 files changed, 39 insertions, 24 deletions
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp index 364614f9a2..7daeabd0e8 100644 --- a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp +++ b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp @@ -346,22 +346,26 @@ bool PNaClABIVerifyModule::runOnModule(Module &M) { } for (Module::const_iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) { - // Check intrinsics. - if (MI->isIntrinsic() - && !isWhitelistedIntrinsic(MI, MI->getIntrinsicID())) { - Reporter->addError() << "Function " << MI->getName() - << " is a disallowed LLVM intrinsic\n"; - } - - // Check types of functions and their arguments. Not necessary - // for intrinsics, whose types are fixed anyway, and which have - // argument types that we disallow such as i8. - if (!MI->isIntrinsic() && - !PNaClABITypeChecker::isValidFunctionType(MI->getFunctionType())) { - Reporter->addError() << "Function " << MI->getName() - << " has disallowed type: " - << PNaClABITypeChecker::getTypeName(MI->getFunctionType()) - << "\n"; + if (MI->isIntrinsic()) { + // Check intrinsics. + if (!isWhitelistedIntrinsic(MI, MI->getIntrinsicID())) { + Reporter->addError() << "Function " << MI->getName() + << " is a disallowed LLVM intrinsic\n"; + } + } else { + // Check types of functions and their arguments. Not necessary + // for intrinsics, whose types are fixed anyway, and which have + // argument types that we disallow such as i8. + if (!PNaClABITypeChecker::isValidFunctionType(MI->getFunctionType())) { + Reporter->addError() << "Function " << MI->getName() + << " has disallowed type: " + << PNaClABITypeChecker::getTypeName(MI->getFunctionType()) + << "\n"; + } + if (MI->isDeclaration()) { + Reporter->addError() << "Function " << MI->getName() + << " is declared but not defined (disallowed)\n"; + } } checkGlobalValueCommon(MI); diff --git a/test/NaCl/PNaClABI/instructions.ll b/test/NaCl/PNaClABI/instructions.ll index 57d1ec856b..b65829d865 100644 --- a/test/NaCl/PNaClABI/instructions.ll +++ b/test/NaCl/PNaClABI/instructions.ll @@ -113,11 +113,15 @@ bar: ret void } -declare void @external_func() -declare void @personality_func() +define void @throwing_func() { + ret void +} +define void @personality_func() { + ret void +} define void @invoke_func() { - invoke void @external_func() to label %ok unwind label %onerror + invoke void @throwing_func() to label %ok unwind label %onerror ; CHECK-NOT: disallowed ; CHECK: disallowed: bad instruction opcode: invoke ok: diff --git a/test/NaCl/PNaClABI/linkagetypes.ll b/test/NaCl/PNaClABI/linkagetypes.ll index bcd0ee179d..f19ed48796 100644 --- a/test/NaCl/PNaClABI/linkagetypes.ll +++ b/test/NaCl/PNaClABI/linkagetypes.ll @@ -44,8 +44,7 @@ define private void @private_func() { define internal void @internal_func() { ret void } -; TODO(dschuff): Disallow external linkage -; CHECK-NOT: external_func +; CHECK: Function external_func is declared but not defined (disallowed) declare external void @external_func() ; CHECK: linkonce_func has disallowed linkage type: linkonce define linkonce void @linkonce_func() { @@ -63,11 +62,13 @@ define weak void @weak_func() { define weak_odr void @weak_odr_func() { ret void } +; CHECK-NEXT: dllimport_func is declared but not defined (disallowed) ; CHECK-NEXT: dllimport_func has disallowed linkage type: dllimport declare dllimport void @dllimport_func() ; CHECK-NEXT: dllexport_func has disallowed linkage type: dllexport define dllexport void @dllexport_func() { ret void } +; CHECK-NEXT: Function extern_weak_func is declared but not defined (disallowed) ; CHECK-NEXT: Function extern_weak_func has disallowed linkage type: extern_weak declare extern_weak void @extern_weak_func()
\ No newline at end of file diff --git a/test/NaCl/PNaClABI/types.ll b/test/NaCl/PNaClABI/types.ll index b1527ec111..2a331324dc 100644 --- a/test/NaCl/PNaClABI/types.ll +++ b/test/NaCl/PNaClABI/types.ll @@ -3,12 +3,18 @@ ; CHECK: Function badReturn has disallowed type: half* () -declare half* @badReturn() +define half* @badReturn() { + unreachable +} ; CHECK: Function badArgType1 has disallowed type: void (half, i32) -declare void @badArgType1(half %a, i32 %b) +define void @badArgType1(half %a, i32 %b) { + ret void +} ; CHECK: Function badArgType2 has disallowed type: void (i32, half) -declare void @badArgType2(i32 %a, half %b) +define void @badArgType2(i32 %a, half %b) { + ret void +} define void @func() { |