Labels are stored in a Label Information Base (LIB) this database holds all label and forwarding information needed to forward packets. FIB and LFIB only contains labels for best path to a prefix, LIB contains all labels regardless if they’re used or not.
To choose what label to apply the router depends on the routing protocols decision about the best route. Relying on the routing protocol allows for the LIB to take advantage of its loop prevention mechanisms to get to the destination.
LSRs make the following decision during convergence of routes:
for each route in the routing table, find the corresponding label information in the LIB, and based on the outgoing interface and next hop the LSR adds the label to the FIB and LFIB.