[llvm-bugs] [Bug 34353] New: No lifetime markers for temp object used to call conversion operator

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 28 18:11:41 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=34353

            Bug ID: 34353
           Summary: No lifetime markers for temp object used to call
                    conversion operator
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: vitalybuka at google.com
                CC: llvm-bugs at lists.llvm.org

Check test_a (BAD) and test_b (GOOD) below. 

struct B {
  B() : p('B') {}
  char p;
};

struct C {
  const char* p;
  explicit C(const char* c) : p(c) {  }
  C(const B& b) : p(&b.p) {  }  // NOLINT
};

struct A {
  char p;
  explicit A() : p('C') {  }
  const operator C() const {
    return C(&p);
  }
};

volatile char r;
void test_a() {
  // conversion operator, temp object will have not lifetime markers
  C s = A();   
  r = *s.p;
}

void test_b() {
  // Copy constructor, temp object will have lifetime markers
  C s = B();
  r = *s.p;
}


*** IR Dump Before Module Verifier ***
; Function Attrs: nounwind uwtable
define void @_Z6test_av() #0 !dbg !7 {
entry:
  %s = alloca %struct.C, align 8
  %tmp = alloca %struct.A, align 1
  %0 = bitcast %struct.C* %s to i8*, !dbg !9
  call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #3, !dbg !9
  call void @_ZN1AC2Ev(%struct.A* %tmp), !dbg !10
  %call = call i8* @_ZNK1Acv1CEv(%struct.A* %tmp), !dbg !10
  %coerce.dive = getelementptr inbounds %struct.C, %struct.C* %s, i32 0, i32 0,
!dbg !10
  store i8* %call, i8** %coerce.dive, align 8, !dbg !10
  %p = getelementptr inbounds %struct.C, %struct.C* %s, i32 0, i32 0, !dbg !11
  %1 = load i8*, i8** %p, align 8, !dbg !11, !tbaa !12
  %2 = load i8, i8* %1, align 1, !dbg !17, !tbaa !18
  store volatile i8 %2, i8* @r, align 1, !dbg !19, !tbaa !18
  %3 = bitcast %struct.C* %s to i8*, !dbg !20
  call void @llvm.lifetime.end.p0i8(i64 8, i8* %3) #3, !dbg !20
  ret void, !dbg !20
}

*** IR Dump Before Module Verifier ***
; Function Attrs: nounwind uwtable
define void @_Z6test_bv() #0 !dbg !25 {
entry:
  %s = alloca %struct.C, align 8
  %ref.tmp = alloca %struct.B, align 1
  %0 = bitcast %struct.C* %s to i8*, !dbg !26
  call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #3, !dbg !26
  %1 = bitcast %struct.B* %ref.tmp to i8*, !dbg !27
  call void @llvm.lifetime.start.p0i8(i64 1, i8* %1) #3, !dbg !27
  call void @_ZN1BC2Ev(%struct.B* %ref.tmp), !dbg !27
  call void @_ZN1CC2ERK1B(%struct.C* %s, %struct.B* dereferenceable(1)
%ref.tmp), !dbg !27
  %2 = bitcast %struct.B* %ref.tmp to i8*, !dbg !28
  call void @llvm.lifetime.end.p0i8(i64 1, i8* %2) #3, !dbg !28
  %p = getelementptr inbounds %struct.C, %struct.C* %s, i32 0, i32 0, !dbg !29
  %3 = load i8*, i8** %p, align 8, !dbg !29, !tbaa !30
  %4 = load i8, i8* %3, align 1, !dbg !33, !tbaa !11
  store volatile i8 %4, i8* @r, align 1, !dbg !34, !tbaa !11
  %5 = bitcast %struct.C* %s to i8*, !dbg !35
  call void @llvm.lifetime.end.p0i8(i64 8, i8* %5) #3, !dbg !35
  ret void, !dbg !35
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170829/219a0095/attachment.html>


More information about the llvm-bugs mailing list