mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-29 06:53:53 +00:00
SimplifyLibCalls: Use IRBuilder.CreateGlobalString when creating a string for printf->puts, which correctly sets the unnamed_addr bit on the resulting GlobalVariable.
Fixes PR11264. llvm-svn: 143289
This commit is contained in:
parent
ce47648159
commit
d32c541fe4
@ -1123,10 +1123,8 @@ struct PrintFOpt : public LibCallOptimization {
|
||||
// Create a string literal with no \n on it. We expect the constant merge
|
||||
// pass to be run after this pass, to merge duplicate strings.
|
||||
FormatStr.erase(FormatStr.end()-1);
|
||||
Constant *C = ConstantArray::get(*Context, FormatStr, true);
|
||||
C = new GlobalVariable(*Callee->getParent(), C->getType(), true,
|
||||
GlobalVariable::InternalLinkage, C, "str");
|
||||
EmitPutS(C, B, TD);
|
||||
Value *GV = B.CreateGlobalString(FormatStr, "str");
|
||||
EmitPutS(GV, B, TD);
|
||||
return CI->use_empty() ? (Value*)CI :
|
||||
ConstantInt::get(CI->getType(), FormatStr.size()+1);
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
; RUN: opt < %s -simplify-libcalls -S -o %t
|
||||
; RUN: FileCheck < %t %s
|
||||
; RUN: opt < %s -simplify-libcalls -S | FileCheck %s
|
||||
|
||||
@str = internal constant [13 x i8] c"hello world\0A\00" ; <[13 x i8]*> [#uses=1]
|
||||
@str1 = internal constant [2 x i8] c"h\00" ; <[2 x i8]*> [#uses=1]
|
||||
|
||||
; CHECK: internal unnamed_addr constant [12 x i8] c"hello world\00"
|
||||
|
||||
declare i32 @printf(i8*, ...)
|
||||
|
||||
; CHECK: define void @f0
|
||||
|
Loading…
Reference in New Issue
Block a user