Handle removal of LLVMAddTargetData in SVN revision 260919
authorMatthew Dawson <matthew@mjdsystems.ca>
Tue, 16 Feb 2016 06:25:20 +0000 (01:25 -0500)
committerMichel Dänzer <michel@daenzer.net>
Tue, 16 Feb 2016 07:18:35 +0000 (16:18 +0900)
LLVM removed LLVMAddTargetData for the 3.9 release in r260919.  For the two
places in mesa where this is called, only enable the lines when compiling
for less then 3.9.

For the radeon driver, I'm not sure how to check if any other LLVM calls need
to be adjusted.  I think since the target data used is extracted from the
LLVMModule, it isn't necessary to pass it back to LLVM again.

The code does compile, and at least for radeonsi does run OpenGL games.

[ Michel Dänzer: Move #if closer to LLVMAddTargetData in lp_bld_init.c,
  and add HAVE_LLVM < 0x0309 guards around now unused occurrences of TD
  and data_layout ]

Signed-off-by: Matthew Dawson <matthew@mjdsystems.ca>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/auxiliary/gallivm/lp_bld_init.c
src/gallium/drivers/radeon/radeon_llvm_util.c

index 96aba7370c1f7364ccb69a4d2e15fea791ca41de..ab55be4c439c634a13c99dde95d15a32fdef8f2c 100644 (file)
@@ -118,8 +118,10 @@ create_pass_manager(struct gallivm_state *gallivm)
     * simple, or constant propagation into them, etc.
     */
 
+#if HAVE_LLVM < 0x0309
    // Old versions of LLVM get the DataLayout from the pass manager.
    LLVMAddTargetData(gallivm->target, gallivm->passmgr);
+#endif
 
    /* Setting the module's DataLayout to an empty string will cause the
     * ExecutionEngine to copy to the DataLayout string from its target
index 0dfd9ad4867988e840c1ee0dc142375361c7dd90..da19533b862106877f752e435264d7262d635aec 100644 (file)
@@ -55,8 +55,10 @@ unsigned radeon_llvm_get_num_kernels(LLVMContextRef ctx,
 
 static void radeon_llvm_optimize(LLVMModuleRef mod)
 {
+#if HAVE_LLVM < 0x0309
        const char *data_layout = LLVMGetDataLayout(mod);
        LLVMTargetDataRef TD = LLVMCreateTargetData(data_layout);
+#endif
        LLVMPassManagerBuilderRef builder = LLVMPassManagerBuilderCreate();
        LLVMPassManagerRef pass_manager = LLVMCreatePassManager();
 
@@ -77,14 +79,18 @@ static void radeon_llvm_optimize(LLVMModuleRef mod)
                }
        }
 
+#if HAVE_LLVM < 0x0309
        LLVMAddTargetData(TD, pass_manager);
+#endif
        LLVMAddAlwaysInlinerPass(pass_manager);
        LLVMPassManagerBuilderPopulateModulePassManager(builder, pass_manager);
 
        LLVMRunPassManager(pass_manager, mod);
        LLVMPassManagerBuilderDispose(builder);
        LLVMDisposePassManager(pass_manager);
+#if HAVE_LLVM < 0x0309
        LLVMDisposeTargetData(TD);
+#endif
 }
 
 LLVMModuleRef radeon_llvm_get_kernel_module(LLVMContextRef ctx, unsigned index,