Christian Convey
2015-Jun-25 16:38 UTC
[LLVMdev] Are Module / Function / Instruction iteration orders stable?
Hi guys, Suppose I have an IR file on disk, and I access it via a Module pass. Also suppose that the bitcode file hasn't changed, and no transformation passes have run. Then can I safely assume that every time my Module pass executes code like the following, it will always visit the Module's Functions, BasicBlocks, and Instructions in the same order? for (auto const & Fn : Module) {> for (auto const & BB : Fn) { > for (auto const & Ins : BB) { > } > } > } >I don't notice anything in the LLVM docs suggesting that I can count on the order staying the same when visiting a Module's Functions or a Function's BasicBlocks. But I'm told there was an IRC post the other day stating that the order *is* stable. Thanks, Christian -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150625/493ff67e/attachment.html>
Daniel Berlin
2015-Jun-25 18:33 UTC
[LLVMdev] Are Module / Function / Instruction iteration orders stable?
These specific things *should* be stable. The use order is not stable, however. On Thu, Jun 25, 2015 at 9:38 AM, Christian Convey <christian.convey at gmail.com> wrote:> Hi guys, > > Suppose I have an IR file on disk, and I access it via a Module pass. Also > suppose that the bitcode file hasn't changed, and no transformation passes > have run. > > Then can I safely assume that every time my Module pass executes code like > the following, it will always visit the Module's Functions, BasicBlocks, and > Instructions in the same order? > >> for (auto const & Fn : Module) { >> for (auto const & BB : Fn) { >> for (auto const & Ins : BB) { >> } >> } >> } > > > I don't notice anything in the LLVM docs suggesting that I can count on the > order staying the same when visiting a Module's Functions or a Function's > BasicBlocks. But I'm told there was an IRC post the other day stating that > the order *is* stable. > > Thanks, Christian > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Duncan P. N. Exon Smith
2015-Jun-25 21:39 UTC
[LLVMdev] Are Module / Function / Instruction iteration orders stable?
> On 2015-Jun-25, at 11:33, Daniel Berlin <dberlin at dberlin.org> wrote: > > These specific things *should* be stable.(Agreed.)> The use order is not stable, however.A fronted can opt-in to stable use-list ordering. `clang -cc1` has an `-emit-llvm-uselists` option that turns this on. The clang driver uses that for `clang -save-temps`, for example. The use-list order is only guaranteed to be stable if the reader/writer are the exact same version; otherwise it can degrade.> > > On Thu, Jun 25, 2015 at 9:38 AM, Christian Convey > <christian.convey at gmail.com> wrote: >> Hi guys, >> >> Suppose I have an IR file on disk, and I access it via a Module pass. Also >> suppose that the bitcode file hasn't changed, and no transformation passes >> have run. >> >> Then can I safely assume that every time my Module pass executes code like >> the following, it will always visit the Module's Functions, BasicBlocks, and >> Instructions in the same order? >> >>> for (auto const & Fn : Module) { >>> for (auto const & BB : Fn) { >>> for (auto const & Ins : BB) { >>> } >>> } >>> } >> >> >> I don't notice anything in the LLVM docs suggesting that I can count on the >> order staying the same when visiting a Module's Functions or a Function's >> BasicBlocks. But I'm told there was an IRC post the other day stating that >> the order *is* stable. >> >> Thanks, Christian >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev