llvm依赖项alloca-load [英] llvm dependencies alloca-load

查看:177
本文介绍了llvm依赖项alloca-load的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找依赖项方面遇到一些问题.我想从每个Load中获取对应的Alloca(从使用的变量的角度来看,这是对应的,这意味着Load使用的是基于或依赖于Alloca或Allocas的变量).

因此,我的链条如下:Alloca -> Load(1) -> ... -> Computation where the variable might be changed -> Store(new_var) -> ... -> Load(n)

更改变量的位置计算"表示:我可能有Alloca(a), c=a+7000*b[32], Load(c).

首先,我尝试使用AliasAnalysis类中的方法. 计划如下:在获得所有必需别名后,我将它们归类为2:

  1. 类别A:带有allocas的别名
  2. 类别B:不带别名的别名

对于A类,我可以直接满足我的需求. 对于类别B,我从类别A别名的指令中检查是否存在使用变量的指令.如果是,则可以.

对于某些方法,我无法使用Alloca,因此我尝试查找Load之间的依赖关系(我在数组loadInstrArray中具有所有Load指令),然后检查某些Load是否使用与Alloca相同的变量.

但是以下内容完全没有结果(它们应该,我的目标测试代码中有依赖项-意味着在我的代码中多次使用Load j,因此指针必须是别名):

  1. if( AA.isMustAlias(Loci,Locj) )-没有结果
  2. if( AA.alias(Loci,Locj) )-错误的结果,例如"LOAD %2 = load i32* %j, align 4 IS DEPENDENT ON %3 = load i32* %c, align 4"

其中j完全独立于c

3.if( AA.getModRefInfo(allocaInstrArray[j],Loci) )-没有结果

其中基因座"是AliasAnalysis ::来自负载的位置,allocaInstrArray是包含所有allocas的数组

第二,我尝试使用DependencyAnalysis类中的方法.

  1. if (DA.depends(loadInstrArray[i],loadInstrArray[j],false))-没有结果

第三,我尝试了MemoryDe​​pendenceAnalysis类中的方法-现有传递 http://llvm. org/docs/doxygen/html/MemDepPrinter_8cpp_source.html .

  1. 我有错误的结果,例如:%1 = load i32* %j, align 4 IS Clobber FROM: store i32 0, i32* %c, align 4
  2. 然后,我尝试仅获取DEF(而不是破坏者),因为我只需要为每个负载查看对应的Alloca.加载没有任何结果.我还使用getDef()方法进行了检查,负载依赖于自身.
  3. 我不得不提到我评论了00131行,因为我遇到了无法解决的段错误,而不是参数是问题所在.

您认为我应该重点关注什么,哪种方法最好考虑,什么要消除?

非常感谢您的光临!

解决方案

此外,您还应该检查ICMP操作数是否始终都在引用Load指令.如果不是,请从两个ICMP操作数(0和1)中递归查找Load指令.在负载和ICMP之间可能还有其他中间操作.

I have some problems of finding dependencies. I want to get the corresponding Alloca from every Load (corresponding from the point of view of the variable used, meaning that the Load is using a variable based/dependent on the Alloca or Allocas).

Hence, I have a chain like : Alloca -> Load(1) -> ... -> Computation where the variable might be changed -> Store(new_var) -> ... -> Load(n)

"Computation where the variable is changed" means that : I might have Alloca(a), c=a+7000*b[32], Load(c).

First, I tried to use methods from AliasAnalysis class. The plan was the following: after I get all the must-aliases, I categorize them into 2 :

  1. category A : aliases with allocas
  2. category B: aliases without allocas

For category A, is straight ahead for what I need. For category B, I check if there is an instruction where the variable is used also from an instruction from the aliases of category A. If it is, it is ok.

For some methods I cannot use Alloca, so I try to find dependencies among Loads (I have all the Load instructions in an array loadInstrArray) and then check if some Load use the same variable as an Alloca.

But the following gave me no result at all (and they should, I have dependencies in my target test code - meaning that Load j is used multiple times in my code, so the pointers should be must-alias) :

  1. if( AA.isMustAlias(Loci,Locj) ) - no results
  2. if( AA.alias(Loci,Locj) ) - wrong results, like "LOAD %2 = load i32* %j, align 4 IS DEPENDENT ON %3 = load i32* %c, align 4"

where j is totally independent from c

3". if( AA.getModRefInfo(allocaInstrArray[j],Loci) ) - no results

where Loci is AliasAnalysis::Location from a Load, allocaInstrArray is an array with all allocas

Second, I tried to use methods from DependencyAnalysis class.

  1. if (DA.depends(loadInstrArray[i],loadInstrArray[j],false)) - no results

Third, I tried methods from MemoryDependenceAnalysis class - the existing pass http://llvm.org/docs/doxygen/html/MemDepPrinter_8cpp_source.html .

  1. I have wrong results, like : %1 = load i32* %j, align 4 IS Clobber FROM: store i32 0, i32* %c, align 4
  2. then I tried to get only DEF (not clobber), since I only need to see the correspondent Alloca for every Load. I don't have any results for Loads. I also checked with getDef() method, Loads being dependent on themselves.
  3. I have to mention that I commented line 00131, since I had an unsolved segfault and not the parameters are the problem.

What do you think I should focus on, what approach is better to take into account and what to eliminate?

Thank you a lot for your time !

解决方案

In addition, you should check if all the time the ICMP operands are referring to a Load instruction. If not, seek recursive for Load instructions from both ICMP operands (0 and 1). There might be other intermediate operations between Loads and ICMP.

这篇关于llvm依赖项alloca-load的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆