diff --git a/clang/lib/Driver/ToolChains/HIP.cpp b/clang/lib/Driver/ToolChains/HIP.cpp --- a/clang/lib/Driver/ToolChains/HIP.cpp +++ b/clang/lib/Driver/ToolChains/HIP.cpp @@ -155,6 +155,7 @@ LlcArgs.push_back(Args.MakeArgString("-mcpu=" + SubArchName)); LlcArgs.push_back( Args.MakeArgString(Twine("-filetype=") + (OutputIsAsm ? "asm" : "obj"))); + LlcArgs.push_back("--amdgpu-enable-structurizer-workarounds"); // Extract all the -m options std::vector Features; diff --git a/clang/test/Driver/hip-structurizer-workarounds.hip b/clang/test/Driver/hip-structurizer-workarounds.hip new file mode 100644 --- /dev/null +++ b/clang/test/Driver/hip-structurizer-workarounds.hip @@ -0,0 +1,11 @@ +// REQUIRES: clang-driver +// REQUIRES: x86-registered-target +// REQUIRES: amdgpu-registered-target + +// RUN: %clang -### -x hip %s 2>&1 | FileCheck %s -check-prefix=CHECK +// RUN: %clang -### -x hip -mllvm --amdgpu-enable-structurizer-workarounds=false %s 2>&1 | FileCheck %s -check-prefix=CHECK -check-prefix=MLLVM + +// CHECK: "{{.*llc}}" +// CHECK-SAME: "-mtriple=amdgcn-amd-amdhsa" +// CHECK-SAME: "--amdgpu-enable-structurizer-workarounds" +// MLLVM-SAME: "--amdgpu-enable-structurizer-workarounds=false" diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -195,7 +195,7 @@ static cl::opt EnableStructurizerWorkarounds( "amdgpu-enable-structurizer-workarounds", cl::desc("Enable workarounds for the StructurizeCFG pass"), cl::init(false), - cl::Hidden); + cl::Hidden, cl::ZeroOrMore); extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTarget() { // Register the target