Well, let's start at the tank and work our way down.
First off, you should be using good, fresh gas and your air filter should be newly cleaned. Bad gas and clogged air filters cause a lot of issues.
The KLR has a vacuum operated petcock. Both the vacuum line and the petcock can go bad. When that happens the petcock may deliver enough fuel to run at idle, but crap out above that.
To test the petcock, get a length of vacuum hose and stick it on the back of the petcock. Remove the fuel line from the petcock and get something to catch the fuel. Apply a vacuum to it (you should be able to suck on it and open the petcock - I know of know genteel way to say that). If the petcock works, fuel will flow quite copiously. If not, then either the fuel pipes are clogged up or the vacuum bits in the petcock have gone south. If you have a bad petcock I would recommend replacing with a non-gravity operated petcock - see here
If the petcock does work, then suspect the vacuum line; remove it and inspect/replace it. If it does need replacement, see if the bike works better.
The next item in the chain would be the float level in the bowl. There is a simple test for that using a piece of clear tubing that gets attached to the nipple on the bottom of the carb. See here
and subsequent posts for a discussion; Damocles set me straight on this procedure.
If all of the above are good, then you may want to drain the tank of all but a half gallon and give it a good dose of Sea Foam. Let it run on the Sea Foam for a bit and see if it gets better. Since all you can really do at this point is idle, be very mindful of the temperature guage and don't let it overheat.
Let us know what's going on!