llvm.org GIT mirror llvm / 113753f
[WebAssembly] Don't try to emit size information for unsized types Patch by John Sully! Fixes PR35164. Differential Revision: https://reviews.llvm.org/D39519 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319991 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 2 years ago
2 changed file(s) with 14 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
8989 }
9090 for (const auto &G : M.globals()) {
9191 if (!G.hasInitializer() && G.hasExternalLinkage()) {
92 uint16_t Size = M.getDataLayout().getTypeAllocSize(G.getValueType());
93 if (TM.getTargetTriple().isOSBinFormatELF())
94 getTargetStreamer()->emitGlobalImport(G.getGlobalIdentifier());
95 OutStreamer->emitELFSize(getSymbol(&G),
96 MCConstantExpr::create(Size, OutContext));
92 if (G.getValueType()->isSized()) {
93 uint16_t Size = M.getDataLayout().getTypeAllocSize(G.getValueType());
94 if (TM.getTargetTriple().isOSBinFormatELF())
95 getTargetStreamer()->emitGlobalImport(G.getGlobalIdentifier());
96 OutStreamer->emitELFSize(getSymbol(&G),
97 MCConstantExpr::create(Size, OutContext));
98 }
9799 }
98100 }
99101 }
212212 ; CHECK-NEXT: .size pointer_to_array, 4
213213 @array = internal constant [8 x i8] zeroinitializer, align 1
214214 @pointer_to_array = constant i8* getelementptr inbounds ([8 x i8], [8 x i8]* @array, i32 0, i32 4), align 4
215
216 ; Handle external objects with opaque type.
217 %struct.ASTRUCT = type opaque
218 @g_struct = external global %struct.ASTRUCT, align 1
219 define i32 @address_of_opaque() {
220 ret i32 ptrtoint (%struct.ASTRUCT* @g_struct to i32)
221 }