[cfe-users] Getting variable names in LLVM IR

2017-02-14 Thread Subhendu Malakar via cfe-users

Hi,
I'm a newbie in LLVM environment.

I'm trying to generate the LLVM IR of a c file using clang. The command 
line argument I'm passing is as :

"clang -O0 -S -emit-llvm test.c -c -o test.ll"

It is generating the LLVM IR properly but I'm not getting the variable 
names. e.g,


for the c file :
#include 

int main()
{
int x;
int y;
x = 2;
y =4;
int z = x*y;

if(x==y)
{
z = x*y;
return z;
} else
{
z = x+y;
}
printf("z = %d", z);
return 0;
}


the corresponding llvm IR is :

; Function Attrs: nounwind uwtable
define i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 0, i32* %1, align 4
  store i32 2, i32* %2, align 4
  store i32 4, i32* %3, align 4
  %5 = load i32, i32* %2, align 4
  %6 = load i32, i32* %3, align 4
  %7 = mul nsw i32 %5, %6
  store i32 %7, i32* %4, align 4
  %8 = load i32, i32* %2, align 4
  %9 = load i32, i32* %3, align 4
  %10 = icmp eq i32 %8, %9
  br i1 %10, label %11, label %16

; :11: ; preds = %0
  %12 = load i32, i32* %2, align 4
  %13 = load i32, i32* %3, align 4
  %14 = mul nsw i32 %12, %13
  store i32 %14, i32* %4, align 4
  %15 = load i32, i32* %4, align 4
  store i32 %15, i32* %1, align 4
  br label %21

; :16: ; preds = %0
  %17 = load i32, i32* %2, align 4
  %18 = load i32, i32* %3, align 4
  %19 = add nsw i32 %17, %18
  store i32 %19, i32* %4, align 4
  br label %20

; :20: ; preds = %16
  store i32 0, i32* %1, align 4
  br label %21

; :21: ; preds = %20, %11
  %22 = load i32, i32* %1, align 4
  ret i32 %22
}


I wanted to get the variables in their original name i.e, x,y,z instead 
of %1,%2,%3, etc.

Is it possible to do so?

Thanks.
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] Whole program analysis using LTO

2017-10-09 Thread Subhendu Malakar via cfe-users
Hi,
I want to do an inter-module analysis of a C project which contains multiple C 
files.
I've written the pass as an extension of the ModulePass but I cannot get the 
information about other modules. I was looking into it and there seems to be a 
way to do it via Link Time Optimization (LTO). But I was not able to find an 
example on how to write an analysis pass for such optimization. All the 
examples just mention how to compile the code using LTO i.e, passing "-flto" 
and "-fuse-ld=gold" to clang. Can anybody point me to some example on how to 
write pass for LTO?
The requirement can be seen as generating the CallGraph along with the CFG for 
the whole project. The project uses Makefile to generate executable.
Thanks,
Subhendu.

___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] DFSan User Manual

2018-06-04 Thread Subhendu Malakar via cfe-users
Hi all,

I'm trying to build a taint analysis application based on DFSan. But 
there is no documentation or user manual for the same (except for 
https://clang.llvm.org/docs/DataFlowSanitizer.html and 
https://clang.llvm.org/docs/DataFlowSanitizerDesign.html).

So, I wanted to know if there is another documentation available with 
more examples, etc.

Thanks,
Subhendu.

___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users