ac: simplify LLVM alloca helpers
authorMarek Olšák <marek.olsak@amd.com>
Fri, 21 Sep 2018 07:27:06 +0000 (03:27 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Sun, 7 Oct 2018 01:50:09 +0000 (21:50 -0400)
src/amd/common/ac_llvm_build.c

index 93bd35239b28eecfa3e27b7bc97a0d54f75b2e26..81158940b8d60437aba720292cbe31f2dbe8d9ac 100644 (file)
@@ -2747,7 +2747,7 @@ void ac_build_uif(struct ac_llvm_context *ctx, LLVMValueRef value,
        if_cond_emit(ctx, cond, label_id);
 }
 
-LLVMValueRef ac_build_alloca(struct ac_llvm_context *ac, LLVMTypeRef type,
+LLVMValueRef ac_build_alloca_undef(struct ac_llvm_context *ac, LLVMTypeRef type,
                             const char *name)
 {
        LLVMBuilderRef builder = ac->builder;
@@ -2765,18 +2765,15 @@ LLVMValueRef ac_build_alloca(struct ac_llvm_context *ac, LLVMTypeRef type,
        }
 
        res = LLVMBuildAlloca(first_builder, type, name);
-       LLVMBuildStore(builder, LLVMConstNull(type), res);
-
        LLVMDisposeBuilder(first_builder);
-
        return res;
 }
 
-LLVMValueRef ac_build_alloca_undef(struct ac_llvm_context *ac,
+LLVMValueRef ac_build_alloca(struct ac_llvm_context *ac,
                                   LLVMTypeRef type, const char *name)
 {
-       LLVMValueRef ptr = ac_build_alloca(ac, type, name);
-       LLVMBuildStore(ac->builder, LLVMGetUndef(type), ptr);
+       LLVMValueRef ptr = ac_build_alloca_undef(ac, type, name);
+       LLVMBuildStore(ac->builder, LLVMConstNull(type), ptr);
        return ptr;
 }