Code Monkey home page Code Monkey logo

microsoft / checkedc-llvm-test-suite Goto Github PK

View Code? Open in Web Editor NEW
11.0 14.0 21.0 503.8 MB

This repo contains a version of the LLVM test suite that is being modified to use Checked C. The modified programs will be used to benchmark the implementation of Checked C in clang/LLVM. Checked C is an extension to C that adds checking to detect or prevent common programming errors such as out-of-bounds memory accesses.

Home Page: https://www.microsoft.com/en-us/research/project/checked-c/

License: Other

CMake 0.39% Python 0.51% Shell 0.70% Makefile 0.75% Roff 0.01% C 53.09% Perl 0.75% LLVM 0.01% C++ 33.23% Lua 0.02% QMake 0.05% Fortran 0.47% Awk 5.16% Yacc 0.11% PostScript 2.32% JavaScript 0.09% OpenEdge ABL 2.04% Emacs Lisp 0.28% Brainfuck 0.01% Limbo 0.02%

checkedc-llvm-test-suite's Introduction

The Checked C LLVM test-suite repo

This repo contains a version of the LLVM test-suite repo that is being modified to use Checked C. The modified programs will be used to benchmark the Checked C version of LLVM/clang.

We have deleted test-only code from the master branch of the repo and left only benchmarks in the master branch. That makes the repo easier to work with. It decreases disk usage from about 2.3 GBytes to under 500 MBytes when using the master branch.

Checked C is an extension to C that adds checking to detect or prevent common programming errors such as out-of-bounds memory accesses. For more information on Checked C, see the Checked C specification in the Checked C repo. The Checked C version of LLVM/clang lives in two repos: the Checked C clang repo and the Checked C LLVM repo.

Branch organization

There are 3 branches in the repo:

  • master: this branch contains benchmarks, some of which may have been modified to use Checked C.
  • baseline: this branch contains benchmarks that have not been modified.
  • original: this contains all the tests, including application tests.

This master branch should be used for modifying benchmarks. This branch can be diffed against the baseline branch to see the changes in benchmarks. The original branch can be used to test that the Checked C implementation has not broken existing tests.

Running tests

On Linux

  1. Setup LNT Note: These steps have been adopted from the LNT Quickstart Guide. These instructions are for Ubuntu 20.
sudo apt install bison flex tclsh
sudo apt install virtualenv
sudo virtualenv ~/mysandbox
git clone https://github.com/llvm/llvm-lnt.git  ~/lnt
sudo ~/mysandbox/bin/python ~/lnt/setup.py install
  1. Invoke LNT tests

Prerequisite: Make sure you have checked out and built the Checked C compiler.

git clone https://github.com/microsoft/checkedc-automation.git <AUTOMATION_DIR>
export SRC_DIR=</path/to/llvm/src>
export BUILD_DIR=</path/to/llvm/build>
<AUTOMATION_DIR>/UNIX/run-lnt-local.sh

Optional flags:

TEST_TARGET="X86_64;ARM"
LNT_BIN=</path/to/lnt> // By default, lnt is picked up from ~/mysandbox/bin/lnt.

The test results are generated at:

<BUILD_DIR>/LNT-Results-Release-Linux/<TEST_TARGET>/test-<TIME_STAMP>/test.log

On Windows

The LNT tests can also be run on Windows 10 using the Windows Subsystem for Linux. See the directions here.

Contributing

We would be happy for people to convert existing benchmarks to use Checked C. For code contributions, we follow the standard Github workflow. See Contributing to Checked C for more detail. You will need to sign a contributor license agreement before contributing a converted benchmark.

For more information on contributing on the Checked C project, see Contributing to Checked C.

Code of conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

checkedc-llvm-test-suite's People

Contributors

alinas avatar anemet avatar artem-b avatar asl avatar bob-wilson avatar cunningbaldrick avatar ddunbar avatar df2218380513f49d8a3d896fc45740e9 avatar dtarditi avatar echristo avatar edwintorok avatar ggreif avatar gottesmm avatar homerdin avatar isanbard avatar kbeyls avatar lattner avatar laurovenancio avatar lenary avatar matzeb avatar mbrukman avatar nadavrot avatar nlewycky avatar proton0001 avatar rengolin avatar resistor avatar sampo3k avatar stoklund avatar vadve avatar wschmidt-ibm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

checkedc-llvm-test-suite's Issues

Compilation errors exposed by the implicit inclusion of checked header files.

For the following benchmarks, -DNO_IMPLICIT_INCLUDE_CHECKED_HDRS had to be added in their Makefiles to avoid compilation errors at present.

Cause of compilation error: A function with a bounds-safe interface has another function call as an argument at one of its call-sites.
MultiSource/Benchmarks/BitBench/drop3
MultiSource/Benchmarks/FreeBench/pifft
MultiSource/Benchmarks/McCat/18-imp
MultiSource/Benchmarks/Prolangs-C/TimberWolfMC
MultiSource/Benchmarks/Prolangs-C/agrep
MultiSource/Benchmarks/Prolangs-C/assembler
MultiSource/Benchmarks/Prolangs-C/loader
MultiSource/Benchmarks/Prolangs-C/unix-smail
MultiSource/Benchmarks/Ptrdist/bc
MultiSource/Benchmarks/VersaBench/dbms

Cause of compilation error: Some of the variables/strings (like ON and n) used by Checked-C-specific declarations have been redefined as macros earlier + plus other issues.
MultiSource/Benchmarks/MallocBench/espresso
MultiSource/Benchmarks/McCat/05-eks
MultiSource/Benchmarks/MiBench/consumer-lame
MultiSource/Benchmarks/MiBench/consumer-typeset
MultiSource/Benchmarks/MiBench/network-patricia
MultiSource/Benchmarks/MiBench/office-ispell
MultiSource/Benchmarks/Prolangs-C/archie-client
MultiSource/Benchmarks/Prolangs-C/cdecl
MultiSource/Benchmarks/Trimaran/netbench-url

CheckedC convert Olden/power benchmark

power benchmark checkedc conversion issue

  • checked array type array subscript requires dynamic_check
    • Almost reasoning facts of program can remove away redundant dynamic_check
    • Also static analysis such as constant folding can remove away dynamic_check
  • checked pointer dereference
    • a->b == (*a).b, it means pointer dereference and requires non-null runtime check

reduce amount of unchecked code in converted benchmarks

As part of a paper submission, we counted the lines of code that were unchecked scopes. There are some converted benchmarks where we could reduce the amount of code in unchecked scopes:

  • Olden/TreeAdd: node.c
  • Olden/Power: main.c
    In addition, memset had a bounds-safe annotation that included an unchecked pointer type, which forced all memset calls to be unchecked code. This should be correct as well.
    There may be other converted benchmarks where the amount of unchecked code could be reduced.

One question is what is the criteria for putting code in a checked scope or unchecked scope. Here is what I propose initially:

  • It is fine to put print calls that use varargs in unchecked scopes by themselves.
  • Function bodies or blocks that are > 80% checked code (excluding print calls) should be checked.

document benchmarks

  • We should create a Wiki for this repo and track the PtrDist/Olden benchmarks that have been converted.
  • We should make sure that the Checked C repo and the Checked C clang repo point to this repo.

Update anagram to no longer undefine macros for character testing

On Linux, functions such as isalpha are turned into macros. The macros make function calls that return pointers to pointers to integers. We don't have enough functionality for Checked C implemented yet to annotate the functions called by those macros so that they can be used in checked code. As a work around, we undefined the macros in anagram so that the original library functions are called. When we do have enough functionality implemented, we should update the headers for Linux to annotate the functions called by the macros and undo the workaround in anagram.

Ptrdist/ft Execution Bug

There's a bug and ptrdist/ft is failing at execution time.

It's not in our list of our original 10 benchmarks for the preliminary evaluation, but we should get it checked and working. Not going to investigate it tonight, probably tomorrow afternoon.

Remove uses of global variables in parameter bounds

Many functions in the Ptrdist benchmark (e.g. in vcg.c) use global variables in the declared parameter bounds. The functions should instead accept parameters that are used in the declared bounds. For example:

int globalCount;
array_ptr<int> globalArr : count(globalCount);
void f(array_ptr<int> arr : count(globalCount));
f(globalArr);

should be

int globalCount;
array_ptr<int> globalArr : count(globalCount);
void f(array_ptr<int> arr : count(globalCount), int paramCount);
f(globalArr, globalCount);

The test scimark2 seems to run for a long time thereby being flagged as a FAIL.

The test scimark2 seems to run for a long time thereby being flagged as a FAIL.

Results

FAIL : 1
PASS : 1539
Results available at: db_None/v4/nts/1
++ grep FAIL /build/LNT-Results-Release-Linux/arm32/result.log
FAIL: MultiSource/Benchmarks/SciMark2-C/scimark2.execution_time (309 of 1540)
FAIL : 1
++ echo 'LNT testing failed.'
LNT testing failed.
++ exit 1

Originally posted by @mgrang in microsoft/checkedc-clang#610 (comment)

CheckedC convert Ptrdist/ks benchmark

convert Ptrdist/ks benchmark into checked-c code

  • KS (Kernighan-Schweikert graph partitioning) benchmark is converted to checked-c
  • anagram/ft is slightly modified to follow check-clang modification
  • checkedc-llvm-test-suite checked header files are modified to follow changes of checkedc header files

MultiSource/Benchmakr/Ptrdist all benchmarks are passed with lnt runtest

Copy modified headers back to Checked C repo

We find issues while converting existing benchmarks to be Checked C, mostly having to do with supporting specific platform's C standard library headers. We updated the headers in this repo. The changes to need to be propagated to the home repo of the headers, which is the Checked C repo.

Fix failing tests after Clang 11 upgrade

The following tests in MultiSource/Benchmarks fail on LNT test runs after upgrading to Clang 11:

  • ASC_Sequoia/IRSmk
  • DOE-ProxyApps-C/miniAMR
  • Olden/bh
  • Prolangs-C/TimberWolfMC
  • Prolangs-C/compiler
  • Prolangs-C/loader
  • Prolangs-C/simulator

These tests will be temporarily disabled while we debug in order to unblock the ADO runs.

anagram failing to compile on Linux Ubuntu 14.04

Apparently the tolower and isalpha macros involve a function call that returns an unchecked pointer. Here is an example error:

mnt/d/autobahn1/llvm-test-suite/MultiSource/Benchmarks/Ptrdist/anagram/anagram.c:300:17: error: cannot use a return with an unchecked type in a checked scope or function
            if (isalpha(ch)) cLetters++;
                ^
/usr/include/ctype.h:198:21: note: expanded from macro 'isalpha'
# define isalpha(c)     __isctype((c), _ISalpha)
                        ^
/usr/include/ctype.h:89:6: note: expanded from macro '__isctype'
  ((*__ctype_b_loc ())[(int) (c)] & (unsigned short int) type)
     ^

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.