}
for (const auto &G : M.globals()) {
if (!G.hasInitializer() && G.hasExternalLinkage()) {
- uint16_t Size = M.getDataLayout().getTypeAllocSize(G.getValueType());
- if (TM.getTargetTriple().isOSBinFormatELF())
- getTargetStreamer()->emitGlobalImport(G.getGlobalIdentifier());
- OutStreamer->emitELFSize(getSymbol(&G),
- MCConstantExpr::create(Size, OutContext));
+ if (G.getValueType()->isSized()) {
+ uint16_t Size = M.getDataLayout().getTypeAllocSize(G.getValueType());
+ if (TM.getTargetTriple().isOSBinFormatELF())
+ getTargetStreamer()->emitGlobalImport(G.getGlobalIdentifier());
+ OutStreamer->emitELFSize(getSymbol(&G),
+ MCConstantExpr::create(Size, OutContext));
+ }
}
}
}
; CHECK-NEXT: .size pointer_to_array, 4
@array = internal constant [8 x i8] zeroinitializer, align 1
@pointer_to_array = constant i8* getelementptr inbounds ([8 x i8], [8 x i8]* @array, i32 0, i32 4), align 4
+
+; Handle external objects with opaque type.
+%struct.ASTRUCT = type opaque
+@g_struct = external global %struct.ASTRUCT, align 1
+define i32 @address_of_opaque() {
+ ret i32 ptrtoint (%struct.ASTRUCT* @g_struct to i32)
+}