Hi, In PromoteMemoryToRegister.cpp, it seems to rely on the fact that the only users of bitcast/GEP instruction are lifetime intrinsics (llvm.lifetime.start/end). I did some searching in llvm/test folder, it seems to be true. However, by reading LLVM IR manual, I don't see any restriction stated on the possible user of bitcast/GEP instruction. So my question is who impose the restriction ? Is it Clang ? Regards -guoqing -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150130/37689eca/attachment.html>
If a stack pointer is passed to another function it can't be promoted to a register, as that function will need to load or store through the pointer. But while these intrinsics look like functions, they aren't really. On Fri, Jan 30, 2015 at 8:59 PM, guoqing zhang <gqzhang81 at gmail.com> wrote:> Hi, > > In PromoteMemoryToRegister.cpp, it seems to rely on the fact that the only > users of bitcast/GEP instruction are lifetime intrinsics > (llvm.lifetime.start/end). I did some searching in llvm/test folder, it > seems to be true. > > However, by reading LLVM IR manual, I don't see any restriction stated on > the possible user of bitcast/GEP instruction. So my question is who impose > the restriction ? Is it Clang ? > > Regards > -guoqing > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150130/a4fe840c/attachment.html>
----- Original Message -----> From: "guoqing zhang" <gqzhang81 at gmail.com> > To: llvmdev at cs.uiuc.edu > Sent: Friday, January 30, 2015 4:29:16 AM > Subject: [LLVMdev] About user of bitcast/GEP instruction > > Hi, > > > In PromoteMemoryToRegister.cpp, it seems to rely on the fact that the > only users of bitcast/GEP instruction are lifetime intrinsics > (llvm.lifetime.start/end).You're misreading that code. There is special handling is that pass for looking through those instructions to find lifetime intrinsics, but that's all.> I did some searching in llvm/test folder, > it seems to be true. >bitcasts and GEPs are general-purpose instructions. GEPs are most often used by loads/stores. Look at test/Transforms/LoopReroll/basic.ll for an example with lots of them. test/Analysis/BasicAA/gep-alias.ll is another place to look.> > However, by reading LLVM IR manual, I don't see any restriction > stated on the possible user of bitcast/GEP instruction. So my > question is who impose the restriction ? Is it Clang ?There is definitely no such restriction. -Hal> > > Regards > -guoqing > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Hal Finkel Assistant Computational Scientist Leadership Computing Facility Argonne National Laboratory
Hi, If the special handling in the meg2reg pass is to look for lifetime intrinsics, shouldn't it cast to <IntrisicInst> and then use getInstrinsicID to check for lifetime_start and lifetime_end ? The thing that I don't understand is the following piece of code, which finds all the users and cast it to <Instruction> then eraseFromParent(). How can this guarantee that it only erase lifetime instrinsics ? -guoqing // The only users of this bitcast/GEP instruction are lifetime intrinsics. // Follow the use/def chain to erase them now instead of leaving it for // dead code elimination later. for (auto UUI = I->user_begin(), UUE = I->user_end(); UUI != UUE;) { Instruction *Inst = cast<Instruction>(*UUI); ++UUI; Inst->eraseFromParent(); } On Fri, Jan 30, 2015 at 1:55 PM, Hal Finkel <hfinkel at anl.gov> wrote:> ----- Original Message ----- > > From: "guoqing zhang" <gqzhang81 at gmail.com> > > To: llvmdev at cs.uiuc.edu > > Sent: Friday, January 30, 2015 4:29:16 AM > > Subject: [LLVMdev] About user of bitcast/GEP instruction > > > > Hi, > > > > > > In PromoteMemoryToRegister.cpp, it seems to rely on the fact that the > > only users of bitcast/GEP instruction are lifetime intrinsics > > (llvm.lifetime.start/end). > > You're misreading that code. There is special handling is that pass for > looking through those instructions to find lifetime intrinsics, but that's > all. > > > I did some searching in llvm/test folder, > > it seems to be true. > > > > bitcasts and GEPs are general-purpose instructions. GEPs are most often > used by loads/stores. Look at test/Transforms/LoopReroll/basic.ll for an > example with lots of them. test/Analysis/BasicAA/gep-alias.ll is another > place to look. > > > > > However, by reading LLVM IR manual, I don't see any restriction > > stated on the possible user of bitcast/GEP instruction. So my > > question is who impose the restriction ? Is it Clang ? > > There is definitely no such restriction. > > -Hal > > > > > > > Regards > > -guoqing > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > -- > Hal Finkel > Assistant Computational Scientist > Leadership Computing Facility > Argonne National Laboratory >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150130/c9e309dc/attachment.html>