[LLVMdev] running a module pass via opt on multiple bitcode files

Jinwook Shin Jinwook.Shin at microsoft.com
Thu Sep 22 14:55:07 PDT 2011


Ah, I just tried with a properly written project and everything worked smoothly. Thanks John.

From: John Criswell <criswell at illinois.edu<mailto:criswell at illinois.edu>>
Organization: University of Illinois
Date: Thu, 22 Sep 2011 16:08:31 -0500
To: Jinwook Shin <Jinwook.Shin at microsoft.com<mailto:Jinwook.Shin at microsoft.com>>
Cc: "llvmdev at cs.uiuc.edu<mailto:llvmdev at cs.uiuc.edu>" <llvmdev at cs.uiuc.edu<mailto:llvmdev at cs.uiuc.edu>>
Subject: Re: [LLVMdev] running a module pass via opt on multiple bitcode files

On 9/22/11 4:04 PM, Jinwook Shin wrote:
Thanks John. I appreciate your help.

De nada.


I have taken the libLTO approach and it worked like a charm :) For those who wanted to achieve the same thing, below are the steps I've taken.

John --  a small question: I thought I wouldn't need to touch Makefiles at all, but that wasn't the case. Could you take a look at Step 4) and tell me what you think? Thanks!

A properly written project will allow the person compiling the software to easily change the compiler and the compiler/linker flags used.

For example, autoconf-based configure scripts usually use the following environment variables:

CC - C compiler
CXX - C++ compiler
CFLAGS - compiler flags
LDFLAGS - linker flags

So, you would do the following in sh/ksh syntax:

CC=llvm-gcc
CXX=llvm-g++
CFLAGS="-emit-llvm"
export CC
export CXX
export CFLAGS
./configure



1) Create your own libLTO and add your pass to it. Do a code diff between /safecode/tools/LTO/LTOCodeGenerator.cpp and /llvm/tools/lto/LTOCodeGenerator.cpp to figure out what changes are needed to do this.
2) Make a backup copy of the original linker  /usr/lib/libLTO.dylib.
3) Copy your libLTO.dylib to /usr/lib.
4) Open Makefiles in your target project and change CC and CFLAGS as follows:
CC=llvm-gcc
CFLAGS=-emit-llvm …
5) Build the project with LLVM.

-- John T.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110922/1d015a6a/attachment.html>


More information about the llvm-dev mailing list