llvm.org GIT mirror llvm / 744f579
An empty global constant (one of size 0) may have a section immediately following it. However, the EmitGlobalConstant method wasn't emitting a body for the constant. The assembler doesn't like that. Before, we were generating this: .zerofill __DATA, __common, __cmd, 1, 3 This fix puts us back to that semantic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95336 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 10 years ago
2 changed file(s) with 51 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
11191119 void AsmPrinter::EmitGlobalConstant(const Constant *CV, unsigned AddrSpace) {
11201120 if (isa(CV) || isa(CV)) {
11211121 uint64_t Size = TM.getTargetData()->getTypeAllocSize(CV->getType());
1122 if (Size == 0) Size = 1; // An empty "_foo:" followed by a section is undef.
11221123 return OutStreamer.EmitZeros(Size, AddrSpace);
11231124 }
11241125
0 ; RUN: llc < %s -mtriple=powerpc-apple-darwin10 -relocation-model=pic -disable-fp-elim | FileCheck %s
1 ;
2
3 %struct.NSString = type opaque
4 %struct._DTOpaqueAssertStruct = type { }
5 %struct.objc_selector = type opaque
6
7 @_cmd = constant %struct._DTOpaqueAssertStruct zeroinitializer ; <%struct._DTOpaqueAssertStruct*> [#uses=1]
8 @OBJC_IMAGE_INFO = private constant [2 x i32] zeroinitializer, section "__OBJC, __image_info,regular" ; <[2 x i32]*> [#uses=1]
9 @llvm.used = appending global [1 x i8*] [i8* bitcast ([2 x i32]* @OBJC_IMAGE_INFO to i8*)], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0]
10
11 define void @_DTAssertionFailureHandler(i8* %objp, i8* %selp, i32 %lineNumber, %struct.NSString* %msgFormat, ...) nounwind ssp {
12 entry:
13 %objp_addr = alloca i8* ; [#uses=1]
14 %selp_addr = alloca i8* ; [#uses=3]
15 %lineNumber_addr = alloca i32 ; [#uses=1]
16 %msgFormat_addr = alloca %struct.NSString* ; <%struct.NSString**> [#uses=1]
17 %iftmp.0 = alloca %struct.objc_selector* ; <%struct.objc_selector**> [#uses=3]
18 %sel = alloca %struct.objc_selector* ; <%struct.objc_selector**> [#uses=1]
19 %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
20 store i8* %objp, i8** %objp_addr
21 store i8* %selp, i8** %selp_addr
22 store i32 %lineNumber, i32* %lineNumber_addr
23 store %struct.NSString* %msgFormat, %struct.NSString** %msgFormat_addr
24 %0 = load i8** %selp_addr, align 4 ; [#uses=1]
25 %1 = icmp ne i8* %0, bitcast (%struct._DTOpaqueAssertStruct* @_cmd to i8*) ; [#uses=1]
26 br i1 %1, label %bb, label %bb1
27
28 bb: ; preds = %entry
29 %2 = load i8** %selp_addr, align 4 ; [#uses=1]
30 %3 = bitcast i8* %2 to %struct.objc_selector** ; <%struct.objc_selector**> [#uses=1]
31 %4 = load %struct.objc_selector** %3, align 4 ; <%struct.objc_selector*> [#uses=1]
32 store %struct.objc_selector* %4, %struct.objc_selector** %iftmp.0, align 4
33 br label %bb2
34
35 bb1: ; preds = %entry
36 store %struct.objc_selector* null, %struct.objc_selector** %iftmp.0, align 4
37 br label %bb2
38
39 bb2: ; preds = %bb1, %bb
40 %5 = load %struct.objc_selector** %iftmp.0, align 4 ; <%struct.objc_selector*> [#uses=1]
41 store %struct.objc_selector* %5, %struct.objc_selector** %sel, align 4
42 br label %return
43
44 return: ; preds = %bb2
45 ret void
46
47 ; CHECK: __cmd:
48 ; CHECK-NEXT: .space 1
49 }