@@ -68,32 +68,38 @@ unsigned Program::createGlobalString(const StringLiteral *S, const Expr *Base) {
6868 /* isExtern=*/ false );
6969 G->block ()->invokeCtor ();
7070
71- new (G->block ()->rawData ()) InlineDescriptor (Desc);
71+ new (G->block ()->rawData ())
72+ GlobalInlineDescriptor{GlobalInitState::Initialized};
7273 Globals.push_back (G);
7374
74- // Construct the string in storage.
7575 const Pointer Ptr (G->block ());
76- for (unsigned I = 0 ; I <= StringLength; ++I) {
77- Pointer Field = Ptr.atIndex (I);
78- const uint32_t CodePoint = I == StringLength ? 0 : S->getCodeUnit (I);
79- switch (CharType) {
80- case PT_Sint8: {
81- using T = PrimConv<PT_Sint8>::T;
82- Field.deref <T>() = T::from (CodePoint, BitWidth);
83- break ;
84- }
85- case PT_Uint16: {
86- using T = PrimConv<PT_Uint16>::T;
87- Field.deref <T>() = T::from (CodePoint, BitWidth);
88- break ;
89- }
90- case PT_Uint32: {
91- using T = PrimConv<PT_Uint32>::T;
92- Field.deref <T>() = T::from (CodePoint, BitWidth);
93- break ;
94- }
95- default :
96- llvm_unreachable (" unsupported character type" );
76+ if (CharWidth == 1 ) {
77+ std::memcpy (&Ptr.atIndex (0 ).deref <char >(), S->getString ().data (),
78+ StringLength);
79+ } else {
80+ // Construct the string in storage.
81+ for (unsigned I = 0 ; I <= StringLength; ++I) {
82+ Pointer Field = Ptr.atIndex (I);
83+ const uint32_t CodePoint = I == StringLength ? 0 : S->getCodeUnit (I);
84+ switch (CharType) {
85+ case PT_Sint8: {
86+ using T = PrimConv<PT_Sint8>::T;
87+ Field.deref <T>() = T::from (CodePoint, BitWidth);
88+ break ;
89+ }
90+ case PT_Uint16: {
91+ using T = PrimConv<PT_Uint16>::T;
92+ Field.deref <T>() = T::from (CodePoint, BitWidth);
93+ break ;
94+ }
95+ case PT_Uint32: {
96+ using T = PrimConv<PT_Uint32>::T;
97+ Field.deref <T>() = T::from (CodePoint, BitWidth);
98+ break ;
99+ }
100+ default :
101+ llvm_unreachable (" unsupported character type" );
102+ }
97103 }
98104 }
99105 Ptr.initialize ();
0 commit comments