Index: lib/Driver/ToolChains/HIP.cpp =================================================================== --- lib/Driver/ToolChains/HIP.cpp +++ lib/Driver/ToolChains/HIP.cpp @@ -157,12 +157,20 @@ Compilation &C, const JobAction &JA, const InputInfoList &Inputs, const llvm::opt::ArgList &Args, llvm::StringRef SubArchName, llvm::StringRef OutputFilePrefix, const char *InputFileName) const { + + llvm::StringRef CodeObjectVersion; + // Add Code Object Version + if (Args.hasArg(options::OPT_mno_code_object_v3)) + CodeObjectVersion = "-mattr=-code-object-v3"; + else + CodeObjectVersion = "-mattr=+code-object-v3"; + // Construct llc command. // FIXME: -disable-promote-alloca-to-lds is a workaround for issues in // AMDGPUPromoteAlloca pass which cause invalid memory access in PyTorch. // Remove this once the issue is fixed. ArgStringList LlcArgs{InputFileName, "-mtriple=amdgcn-amd-amdhsa", - "-filetype=obj", "-mattr=-code-object-v3", + "-filetype=obj", Args.MakeArgString(CodeObjectVersion), "-disable-promote-alloca-to-lds", Args.MakeArgString("-mcpu=" + SubArchName), "-o"}; std::string LlcOutputFileName =