================
@@ -30,53 +30,113 @@ struct GotoSolverPass : public
impl::GotoSolverBase<GotoSolverPass> {
};
static void process(cir::FuncOp func,
- const llvm::StringSet<> &globalBlockAddrLabel) {
+ llvm::ArrayRef<StringRef> globalBlockAddrLabels) {
mlir::OpBuilder rewriter(func.getContext());
llvm::StringMap<Block *> labels;
llvm::SmallVector<cir::GotoOp, 4> gotos;
- llvm::SmallSet<StringRef, 4> blockAddrLabel;
+ llvm::SmallVector<cir::IndirectGotoOp> indirectGotos;
+ // Labels whose address is taken by a cir.block_address op in this function,
+ // in IR order.
+ llvm::SmallVector<StringRef> opBlockAddrLabels;
func.getBody().walk([&](mlir::Operation *op) {
if (auto lab = dyn_cast<cir::LabelOp>(op)) {
labels.try_emplace(lab.getLabel(), lab->getBlock());
} else if (auto goTo = dyn_cast<cir::GotoOp>(op)) {
gotos.push_back(goTo);
+ } else if (auto indirect = dyn_cast<cir::IndirectGotoOp>(op)) {
+ indirectGotos.push_back(indirect);
} else if (auto blockAddr = dyn_cast<cir::BlockAddressOp>(op)) {
- blockAddrLabel.insert(blockAddr.getBlockAddrInfo().getLabel());
+ opBlockAddrLabels.push_back(blockAddr.getBlockAddrInfo().getLabel());
}
});
+ // Address-taken labels in a deterministic order: those referenced from
+ // global initializers first (in initializer order), then those taken by a
+ // cir.block_address op (in IR order). A label may be named more than once
(a
+ // dispatch table can list it twice); a block only needs to be a successor
+ // once, so keep the first occurrence.
+ llvm::SmallVector<StringRef> addrTakenLabels;
----------------
andykaylor wrote:
What's the purpose of having these as two separate collections? If you're doing
that for ordering, SmallSetVector will do that for you. You could initialize
the set like this:
`SmallSetVector<StringRef> addrTakenLabels(llvm::from_range,
globalBlockAddrLabels);`
If you do that on line 40, you can insert the labels directly into this set on
line 50 and you won't need the loops below at all.
https://github.com/llvm/llvm-project/pull/206176
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits