diff options
-rw-r--r-- | lib/Analysis/NaCl/PNaClABIVerifyModule.cpp | 18 | ||||
-rw-r--r-- | test/NaCl/PNaClABI/global-attributes.ll | 38 |
2 files changed, 56 insertions, 0 deletions
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp index 23699860b0..d98868f53c 100644 --- a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp +++ b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp @@ -112,6 +112,15 @@ bool PNaClABIVerifyModule::runOnModule(Module &M) { " has disallowed linkage type: " << linkageName(MI->getLinkage()) << "\n"; } + + if (MI->hasSection()) { + Reporter->addError() << "Variable " << MI->getName() << + " has disallowed \"section\" attribute\n"; + } + if (MI->isThreadLocal()) { + Reporter->addError() << "Variable " << MI->getName() << + " has disallowed \"thread_local\" attribute\n"; + } } // No aliases allowed for now. for (Module::alias_iterator MI = M.alias_begin(), @@ -136,6 +145,15 @@ bool PNaClABIVerifyModule::runOnModule(Module &M) { PNaClABITypeChecker::getTypeName(PT) << "\n"; } } + + if (MI->hasSection()) { + Reporter->addError() << "Function " << MI->getName() << + " has disallowed \"section\" attribute\n"; + } + if (MI->hasGC()) { + Reporter->addError() << "Function " << MI->getName() << + " has disallowed \"gc\" attribute\n"; + } } // Check named metadata nodes diff --git a/test/NaCl/PNaClABI/global-attributes.ll b/test/NaCl/PNaClABI/global-attributes.ll new file mode 100644 index 0000000000..255e1f8a02 --- /dev/null +++ b/test/NaCl/PNaClABI/global-attributes.ll @@ -0,0 +1,38 @@ +; RUN: pnacl-abicheck < %s | FileCheck %s + +; Global variable attributes + +; CHECK: Variable var_with_section has disallowed "section" attribute +@var_with_section = global i32 99, section ".some_section" + +; PNaCl programs can depend on data alignments in general, so we allow +; "align" on global variables. +; CHECK-NOT: var_with_alignment +@var_with_alignment = global i32 99, align 8 + +; TLS variables must be expanded out by ExpandTls. +; CHECK-NEXT: Variable tls_var has disallowed "thread_local" attribute +@tls_var = thread_local global i32 99 + + +; Function attributes + +; CHECK-NEXT: Function func_with_section has disallowed "section" attribute +define void @func_with_section() section ".some_section" { + ret void +} + +; TODO(mseaborn): PNaCl programs don't know what alignment is +; reasonable for a function, so we should disallow this. +; CHECK-NOT: func_with_alignment +define void @func_with_alignment() align 1 { + ret void +} + +; CHECK-NEXT: Function func_with_gc has disallowed "gc" attribute +define void @func_with_gc() gc "my_gc_func" { + ret void +} + +; CHECK-NOT: disallowed +; If another check is added, there should be a check-not in between each check |