File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -356,6 +356,16 @@ void Value::setNameImpl(const Twine &NewName) {
356
356
if (getSymTab (this , ST))
357
357
return ; // Cannot set a name on this value (e.g. constant).
358
358
359
+ // Copy NewName forcely if the memory overlaps.
360
+ if (!NameRef.empty ()) {
361
+ StringRef OldNameRef = getName ();
362
+ if ((OldNameRef.bytes_begin () < NameRef.bytes_end ()) &&
363
+ (NameRef.bytes_begin () < OldNameRef.bytes_end ())) {
364
+ NewName.toVector (NameData);
365
+ NameRef = StringRef (NameData.data (), NameData.size ());
366
+ }
367
+ }
368
+
359
369
if (!ST) { // No symbol table to update? Just do the change.
360
370
// NOTE: Could optimize for the case the name is shrinking to not deallocate
361
371
// then reallocated.
@@ -374,15 +384,6 @@ void Value::setNameImpl(const Twine &NewName) {
374
384
// NOTE: Could optimize for the case the name is shrinking to not deallocate
375
385
// then reallocated.
376
386
if (hasName ()) {
377
- if (!NameRef.empty ()) {
378
- StringRef OldNameRef = getName ();
379
- if ((OldNameRef.bytes_begin () < NameRef.bytes_end ()) &&
380
- (NameRef.bytes_begin () < OldNameRef.bytes_end ())) {
381
- NewName.toVector (NameData);
382
- NameRef = StringRef (NameData.data (), NameData.size ());
383
- }
384
- }
385
-
386
387
// Remove old name.
387
388
ST->removeValueName (getValueName ());
388
389
destroyValueName ();
You can’t perform that action at this time.
0 commit comments