[LLVMbugs] [Bug 9178] New: NRVO after noreturn call causes clang to produce invalid module

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Feb 9 11:39:38 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=9178

           Summary: NRVO after noreturn call causes clang to produce
                    invalid module
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu


This program coaxes clang into producing an invalid module:

  void abort() __attribute__((__noreturn__));
  struct CoinModelLink {
    CoinModelLink();
    ~CoinModelLink();
  };
  class CoinModel {
    CoinModelLink firstInQuadraticColumn();
  };
  CoinModelLink CoinModel::firstInQuadraticColumn() {
    abort();
    CoinModelLink x;
    return x;
  }

which under "clang -cc1 -emit-llvm-bc" triggers the verifier into saying
"Instruction referencing instruction not embedded in a basic block!". Note that
if you run clang -O2 the verifier won't run and the crash is in SRoA instead.

Here's the verifier failure:

  Instruction referencing instruction not embedded in a basic block!
    %nrvo = alloca i1
    store i1 false, i1* %nrvo
  Broken module found, compilation aborted!

and here's the module at the time of the crash:

  ; ModuleID = '001.c'
  target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
  target triple = "x86_64-unknown-linux-gnu"

  %class.CoinModel = type { i8 }
  %struct.CoinModelLink = type { i8 }

  define void @_ZN9CoinModel22firstInQuadraticColumnEv(%class.CoinModel* sret
%agg.result, %class.CoinModel* %this) nounwind align 2 {
  entry:
    %this.addr = alloca %class.CoinModel*, align 8
    %nrvo = alloca i1
    store %class.CoinModel* %this, %class.CoinModel** %this.addr, align 8
    %this1 = load %class.CoinModel** %this.addr
    call void @_Z5abortv() noreturn
    unreachable

  return:                                           ; No predecessors!
    ret void
  }

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list