Writing static program analyses using LLVM

Assignment Help Programming Languages
Reference no: EM131668726

Dataflow Analysis

Objective - This assignment will familiarize you with writing static program analyses using LLVM. LLVM is a collection of compiler and analysis tool chain utilities widely used in the software analysis community. You will use LLVM to implement two intra-procedural dataflow analyses, one forward (reaching definitions analysis) and one backward (liveness analysis).

Setup

1. Download and extract the assignment code in the file dataflow.zip.

2. Navigate to dataflow/build and run the following commands:

cmake ..

make clean

make

(You should now see libDataflowPass.so under dataflow/build/Dataflow.)

3. Go to the dataflow/example directory and compile the programs we will analyze with the following commands:

clang -emit-llvmArrayDemo.c -c -o ArrayDemo.bc

clang -emit-llvmGreatest.c -c -o Greatest.bc

4. Run the Dataflow pass using the commands below to ensure everything works as expected for the test program ArrayDemo.c. These commands print the results of reaching definition analysis and liveness analysis (they are empty sets because the analyses are only stubs) as the dataflow facts for each instruction.

opt -load ../build/Dataflow/libDataflowPass.so -ReachDef<ArrayDemo.bc> /dev/null

opt -load ../build/Dataflow/libDataflowPass.so -Liveness<ArrayDemo.bc> /dev/null

Assignment Instructions -

Complete the do Analysis method in ReachDefAnalysis.cpp and LivenessAnalysis.cpp (located in dataflow/Dataflow/ ) to implement the two analyses. Do not write your analysis code outside of these files, as these files are the only ones you will submit.

You may use the C++ Standard Template Library (STL) with LLVM.

Your code will need to iterate over the program points in the input function and store the computed dataflow facts in DataflowAnalysis::inMapand DataflowAnalysis::outMap. Both analyses inherit from the base class DataflowAnalysis, which you can find in the header file DataflowAnalysis.hlocated in the directory dataflow/Dataflow/. Besides including useful classes such as SetVectorand ValueMap, DataflowAnalysis.halso defines usefl utility functions such as getPredecessors, getSuccessors, and isDef.

The file Printer.cpp (also in the same directory) demonstrates the API by printing the definitions, uses, predecessors, and successors of each instruction. You can execute it using the command:

opt -load ../build/Dataflow/libDataflowPass.so -Printer <ArrayDemo.bc> /dev/null

After completing the two doAnalysismethods, re-build the analyses using the commands from setup Step 2, and then rerun the analyses using the commands from setup Step 4 to obtain the output of your analyses on the ArrayDemo.cprogram. If your implementation is correct, your output will match the example output in ArrayDemo_ReachDefand ArrayDemo_Liveness (both found in dataflow/example/ ). The order of elements in the in and out sets does not matter, but the number of elements and the values should match exactly.

We have also included another program, Greatest.c, and it's expected outputs for testing your implementation. You can use commands similar to those the final set-up instruction step to analyze this program.

Attachment:- Assignment Files.rar

Reference no: EM131668726

Questions Cloud

Why do departments refuse to change : Explain why police patrols methods have remained basically reactive in nature for decades. Why do departments refuse to change ?
What is the vertical intercept of function : Assume that Y is on the vertical axis and X is on the horizontal axis. What is the vertical intercept of this function?
Discuss about the grey code corporation : Grey Code Corporation(GCC) is a media and marketing company involved in magazine and book publishing and television broadcasting.
Find the price elasticity of demand : At this price, find the price elasticity of demand. USE THE POINT SLOPE METHOD to find this elasticity. Hint: You'll have to find the quantity at this price.
Writing static program analyses using LLVM : Dataflow Analysis. Objective - This assignment will familiarize you with writing static program analyses using LLVM
Illustrates how to calculate profit by influence diagram : These data are given in the file CoxElectric. Note that fixed cost is incurred regardless of the amount produced. Per-unit material and labor cost together.
Write an equation in slope-intercept form of linear function : Write an equation in slope-intercept form of a linear function f whose graph satisfies given conditions. Find average rate of change of function from x1 to x2.
What norm have you decided to break : What norm have you decided to break? Is it a formal norm or an informal norm? Why do you think this norm exists in society?
Solving problem of the-eastman publishing company : Eastman Publishing Company is considering publishing an electronic textbook on spreadsheet applications for business. The fixed cost of manuscript preparation.

Reviews

inf1668726

11/19/2018 12:20:15 AM

The assignment is of Programming Languages and it is really tough.. What the great assurance is your business, what service I choose is perfect and mind blowing. I am really very much thankful for this assignment as it is my final paper consists of overall ratings but you guys did i well.. Keep it up guys !!!!

len1668726

10/5/2017 3:30:51 AM

Instead of source code, LLVM uses its own intermediate representation (bitcode files) compiled from source files. These intermediate representations are in the static single assignment (SSA) form. Since each variable is only defined once, LLVM represents each variable directly using the instruction defining it. In fact, the Instruction class is a subtype of the Value class.

len1668726

10/5/2017 3:30:45 AM

Grading Criteria - If the correct output set for Analysis X contains n entries and your output set contains a of those correct entries and bspurious entries, then you will receive max(0, ( a - b )/ n ) of the points for Analysis X (this is floating-point division, not integer division, of course). You will also receive a deduction if your code doesn’t terminate within two minutes. (If your code for an analysis doesn’t terminate at all, you will receive no credit for that analysis.) While efficiency is important, it is entirely secondary to correctness. Though you may lose some points for an inefficient yet correct algorithm, you will not gain points for an efficient yet incorrect algorithm.

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd