ac/llvm: don't create the target machine if the LLVM processor is unsupported
If a processor is unsupported, LLVM chooses "tahiti", which hangs everything except gfx6. Check for support manually. Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16112>
This commit is contained in:
parent
fc0e6fdcce
commit
b8a6bbc6c5
3 changed files with 16 additions and 1 deletions
|
|
@ -28,6 +28,7 @@
|
|||
#include <llvm/IR/IRBuilder.h>
|
||||
#include <llvm/IR/LegacyPassManager.h>
|
||||
#include <llvm/Target/TargetMachine.h>
|
||||
#include <llvm/MC/MCSubtargetInfo.h>
|
||||
#include <llvm/Transforms/IPO.h>
|
||||
|
||||
#include <cstring>
|
||||
|
|
@ -43,6 +44,12 @@
|
|||
#include "ac_llvm_build.h"
|
||||
#include "util/macros.h"
|
||||
|
||||
bool ac_is_llvm_processor_supported(LLVMTargetMachineRef tm, const char *processor)
|
||||
{
|
||||
llvm::TargetMachine *TM = reinterpret_cast<llvm::TargetMachine *>(tm);
|
||||
return TM->getMCSubtargetInfo()->isCPUStringValid(processor);
|
||||
}
|
||||
|
||||
void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes)
|
||||
{
|
||||
llvm::Argument *A = llvm::unwrap<llvm::Argument>(val);
|
||||
|
|
|
|||
|
|
@ -189,11 +189,18 @@ static LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family,
|
|||
assert(family >= CHIP_TAHITI);
|
||||
const char *triple = (tm_options & AC_TM_SUPPORTS_SPILL) ? "amdgcn-mesa-mesa3d" : "amdgcn--";
|
||||
LLVMTargetRef target = ac_get_llvm_target(triple);
|
||||
const char *name = ac_get_llvm_processor_name(family);
|
||||
|
||||
LLVMTargetMachineRef tm =
|
||||
LLVMCreateTargetMachine(target, triple, ac_get_llvm_processor_name(family), "", level,
|
||||
LLVMCreateTargetMachine(target, triple, name, "", level,
|
||||
LLVMRelocDefault, LLVMCodeModelDefault);
|
||||
|
||||
if (!ac_is_llvm_processor_supported(tm, name)) {
|
||||
LLVMDisposeTargetMachine(tm);
|
||||
fprintf(stderr, "amd: LLVM doesn't support %s, bailing out...\n", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (out_triple)
|
||||
*out_triple = triple;
|
||||
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ struct ac_llvm_compiler {
|
|||
};
|
||||
|
||||
const char *ac_get_llvm_processor_name(enum radeon_family family);
|
||||
bool ac_is_llvm_processor_supported(LLVMTargetMachineRef tm, const char *processor);
|
||||
void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes);
|
||||
void ac_add_attr_alignment(LLVMValueRef val, uint64_t bytes);
|
||||
bool ac_is_sgpr_param(LLVMValueRef param);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue