mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
Teach MemoryBuiltins and InstructionSimplify that operator new never returns NULL.
This is safe per C++11 18.6.1.1p3: [operator new returns] a non-null pointer to suitably aligned storage (3.7.4), or else throw a bad_alloc exception. This requirement is binding on a replacement version of this function. Brings us a tiny bit closer to eliminating more vector push_backs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191310 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -101,3 +101,23 @@ define float @test_idempotence(float %a) {
|
||||
|
||||
ret float %r4
|
||||
}
|
||||
|
||||
define i8* @operator_new() {
|
||||
entry:
|
||||
%call = tail call noalias i8* @_Znwm(i64 8)
|
||||
%cmp = icmp eq i8* %call, null
|
||||
br i1 %cmp, label %cast.end, label %cast.notnull
|
||||
|
||||
cast.notnull: ; preds = %entry
|
||||
%add.ptr = getelementptr inbounds i8* %call, i64 4
|
||||
br label %cast.end
|
||||
|
||||
cast.end: ; preds = %cast.notnull, %entry
|
||||
%cast.result = phi i8* [ %add.ptr, %cast.notnull ], [ null, %entry ]
|
||||
ret i8* %cast.result
|
||||
|
||||
; CHECK-LABEL: @operator_new
|
||||
; CHECK: br i1 false, label %cast.end, label %cast.notnull
|
||||
}
|
||||
|
||||
declare noalias i8* @_Znwm(i64)
|
||||
|
Reference in New Issue
Block a user