LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 31674 - ExtractGV externalizes private strings
Summary: ExtractGV externalizes private strings
Status: NEW
Alias: None
Product: libraries
Classification: Unclassified
Component: Interprocedural Optimizations (show other bugs)
Version: trunk
Hardware: PC Windows NT
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-17 20:17 PST by Davide Italiano
Modified: 2017-01-17 20:17 PST (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Davide Italiano 2017-01-17 20:17:38 PST
Testcase:

$ cat test.ll
@.str.47 = private unnamed_addr constant [10 x i8] c"anonymous\00", align 1

define i32 @patatino(i8* nonnull %myptr) {
  %blah = call i32 @strcmp(i8* nonnull %myptr, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.47, i64 0, i64 0))
  ret i32 %blah
}

declare i32 @strcmp(i8* nocapture, i8* nocapture) local_unnamed_addr

$ ./llvm-extract patatino.ll -func=patatino -S
; ModuleID = 'patatino.ll'
source_filename = "patatino.ll"

@.str.47 = external hidden unnamed_addr constant [10 x i8], align 1

define i32 @patatino(i8* nonnull %myptr) {
  %blah = call i32 @strcmp(i8* nonnull %myptr, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.47, i64 0, i64 0))
  ret i32 %blah
}

declare i32 @strcmp(i8* nocapture, i8* nocapture) local_unnamed_addr

In the output, @.str.47 should be extracted (found out while reducing an optimization bug and moving a given function to its own object file, and observing a link failure because the private string was internalized and the linker wasn't able to resolve the symbol).