Ungoliant is Shelob's mother and we know that Shelob lives high up in the mountains surrounding Mordor near Cirith Ungol (note the reference to Ungoliant) and eats whoever comes up there.
So what fate ultimately befell Ungoliant?
Science Fiction & Fantasy Stack Exchange is a question and answer site for science fiction and fantasy enthusiasts. It only takes a minute to sign up.Sign up to join this community
Chapter 9 of the Silmarillion ("Of the Flight of the Noldor") suggests that Ungoliant starved to death.
With their whips of flame they smote asunder the webs of Ungoliant, and she quailed, and turned to flight, belching black vapours to cover her; and fleeing from the north she went down into Beleriand, and dwelt beneath Ered Gorgoroth, in that dark valley that was after called Nan Dungortheb, the Valley of Dreadful Death, because of the horror that she bred there. For other foul creatures of spider form had dwelt there since the days of the delving of Angband, and she mated with them, and devoured them; and even after Ungoliant herself departed, and went whither she would into the forgotten south of the world, her offspring abode there and wove their hideous webs. Of the fate of Ungoliant no tale tells. Yet some have said that she ended long ago, when in her uttermost famine she devoured herself at last.
Tolkien's original and most consistent plan, up to and during the writing of The Lord of the Rings was to have Ungoliant slain by Eärendil. This is mentioned in various writings from 1914 to 1940, usually just in outline, but once with the event actually written out in a few lines of verse. However he later decided against this, and in 1944 she briefly appeared as a villain in The Lord of the Rings (occupying Shelob's part in the story). Two late writings from the 1950s say that her fate was ultimately unknown, with the first suggesting she was still alive and the other that she had "devoured herself".
This version can first be briefly glimpsed in three different outlines to the unwritten "Tale of Eärendel", as an item in the list of adventures that Eärendil was going to be having. The first of these Christopher Tolkien has dated to 1914 (making it among the first items in the entire legendarium to be written), but the other two are a bit later, probably written around c.1920 shortly before Tolkien abandoned The Book of Lost Tales.
a mighty wind and crest of great wave carry him to hotter climes, to back of West Wind. Land of strange men, land of magic. The home of Night. The Spider. He escapes from the meshes of Night with a few comrades, sees a great mountain island and a golden city - wind blows him southward.
Driven west. Ungweliantë. Magic Isles. Twilit Isle. Littleheart's gong awakes the Sleeper in the Tower of Pearl
The building of Wingelot. He searches for Elwing and is blown far to the South. Wirilómë. He escapes eastward.
The Book of Lost Tales part 2 - "The Tale of Eärendel"
This idea was then expounded on in various outlines of the Silmarillion material that Tolkien wrote in 1926, 1930, and 1937 respectively.
Here follow the marvellous adventures of Wingelot in the seas and isles, and of how Eärendel slew Ungoliant in the South.
The Shaping of Middle-earth - Sketch of the Mythology
In the Lay of Eärendel is many a thing sung of his adventures in the deep and in lands untrodden, and in many seas and many isles. Ungoliant in the South he slew, and her darkness was destroyed, and light came to many regions which had yet long been hid. But Elwing sat sorrowing at home.
The Shaping of Middle-earth - The Quenta Noldorinwa
But the unquiet had come also upon Eärendel, and he set sail in his ship Wingelot, Flower of the Foam, and he voyaged the far seas seeking Tuor, and seeking Valinor. But he found neither; yet the marvels that he did were many and renowned. Chief of these was the slaying of Ungoliantë.
The Lost Road and Other Writings - "The Later Annals of Beleriand"
And then finally, in 1940, one of the various drafts that Tolkien made of Bilbo's song in Rivendell in The Lord of the Rings included a verse about this.
and unto Evernight he came,
and like a flaming star he fell:
his javelins of diamond
as fire into the darkness fell.
Ungoliant abiding there
in Spider-lair her thread entwined;
for endless years a gloom she spun
the Sun and Moon in web to wind.
His sword was like a flashing light
as flashing bright he smote with it;
he shore away her poisoned neb,
her noisome webs he broke with it.
Then shining as a risen star
from prison bars he sped away,
and borne upon a blowing wind
on flowing wings he fled away.
The Treason of Isengard - "Bilbo's Song at Rivendell"
Not so long after this Tolkien decided to include Ungoliant as a villain in The Lord of the Rings, thus implying that she had survived up to at least the third age.
This may even date back to a 1941 outline where Tolkien had already decided to use giant spiders like the ones from the first age, but in that outline it's still multiple unnamed spiders, not Ungoliant herself. However if Tolkien was already thinking about using Ungoliant at this point it would explain why he cut out the relevant Eärendil verse about her being killed.
The three companions now approach Kirith Ungol, the dreadful ravine which leads into Gorgoroth. Kirith Ungol means Spider Glen: there dwelt great spiders, greater than those of Mirkwood, such as were once of old in the land of Elves and Men in the West that is now under sea, such as Beren fought in the dark canons of the Mountains of Terror above Doriath. Already Gollum knew these creatures well. He slips away. The spiders come and weave their nets over Frodo while Sam sleeps: sting Frodo. Sam wakes, and sees Frodo lying pale as death — greenish: reminding him of the faces in the pools of the marshes. He cannot rouse or wake him.
The Treason of Isengard - "The Story Foreseen from Lórien"
Regardless of what Tolkien had in mind when thinking about this in 1941, when he actually outlined and began writing these chapters in 1944, the spider was clearly identified as Ungoliant.
'Got you!' hissed Gollum in his ear. 'At last my precious one, we've got him yes, the nasty hobbit. We takes this one. She'll get the other. O yes. Ungoliant will get him.
The War of the Ring - "Kirith Ungol" (Marquette 3/2/17)
During the revision process of that chapter, Tolkien changed the name to Shelob and made her a separate spider, but seven years later in a 1951 writing on the first age Tolkien again implied that Ungoliant was still alive.
Then there came to his aid the Balrogs, who endured still in deep places in the North where the Valar had not discovered them. With their whips of flame they smote her webs asunder, and they drove Ungoliantë away, and she went down into Beleriand and dwelt awhile beneath Ered Orgoroth in that valley which after was named Nan Dungorthin, because of the fear and horror that she bred there. But when she had healed her hurts and spawned there a foul brood she passed away out of the Northlands, and returned into the South of the world, where she abides yet for all that the Eldar have heard.
Morgoth's Ring - The Annals of Aman §126
Later still, Tolkien seems to have continued the 1951 idea of her fate being ultimately unknown, but now with the theory that she killed herself off-screen. This is Tolkien's final writing on the matter, and so this was the source that Christopher used for the Silmarillion.
But when she had healed her hurts as best she could, and had spawned there a foul brood, she passed away. For there were other evil creatures of spider-form that had dwelt there since the days of the delving of Angband; and she mated with them and devoured them. But whither she went after no tale tells. It is said that she ended long ago, when in her uttermost famine she devoured herself at last.
Morgoth's Ring - Of the Thieves' Quarrel §20