Wenqing Zhuang via llvm-dev
2016-Apr-20 02:25 UTC
[llvm-dev] Questions on writing a machine pass in LLVM
Dear all, Hi, my name is Wenqing(Wendell) Zhuang who is a Ph.D student in the college of EECS of Syracuse University in US, I am currently writing a machine pass of LLVM which checks if a pointer points to an address that is out of a certain range. So in that pass, I need to determine if a pointer points to a stack slot or to a non-stack area(e.g heap), I call the function: X86InstrInfo::isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) in my pass which is added in X86PassConfig::addPreEmitPass(), however, that function always return 0 for every Machine Instruction, and returned FrameIndex is always 0, my pass is executed before code emit and after register allocation, but isLoadFromStackSlot and isStoreToStackSlot do not work as I expected in my pass,I can hardly figure out why. I really appreciate if anyone can help me with this. Thanks. The best! Wenqing(Wendell) Zhuang wzhuang at syr.edu Department of Electrical Engineering and Computer Science Syracuse University, US -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160420/e77fbca8/attachment.html>
Krzysztof Parzyszek via llvm-dev
2016-Apr-20 14:35 UTC
[llvm-dev] Questions on writing a machine pass in LLVM
On 4/19/2016 9:25 PM, Wenqing Zhuang via llvm-dev wrote:> > Hi, my name is Wenqing(Wendell) Zhuang who is a Ph.D student in the > college of EECS of Syracuse University in US, I am currently writing a > machine pass of LLVM which checks if a pointer points to an address that > is out of a certain range. So in that pass, I need to determine if a > pointer points to a stack slot or to a non-stack area(e.g heap), I call > the function: X86InstrInfo::isLoadFromStackSlot(const MachineInstr *MI, > int &FrameIndex) in my pass which is added in > X86PassConfig::addPreEmitPass(), however, that function always return 0 > for every Machine Instruction, and returned FrameIndex is always 0, my > pass is executed before code emit and after register allocation, but > isLoadFromStackSlot and isStoreToStackSlot do not work as I expected in > my pass,I can hardly figure out why. > > > I really appreciate if anyone can help me with this. Thanks. The best!Hi Wenqing, The functions isLoadFromStackSlot and isStoreToStackSlot only work while the frame indices are still present as instruction operands. After prolog/epilog insertion, they will be replaced with actual register/offset values and determining whether any load or store accesses a stack slot is likely beyond the intended scope of these functions. If your pass runs before prolog/epilog insertion, it should work fine, but I suspect it runs too late. -Krzysztof -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation