@@ -50,31 +50,61 @@ TEST(LlpcContextTests, MatchPipelineOptLevel) {
5050
5151 Context *context = new Context (GfxIp);
5252
53+ #if LLVM_MAIN_REVISION && LLVM_MAIN_REVISION < 474768
54+ // Old version of the code
5355 for (auto optLevel : {Level::None, Level::Less, Level::Default, Level::Aggressive}) {
56+ #else
57+ // New version of the code (also handles unknown version, which we treat as latest)
58+ // Returns the optimization level for the context.
59+ for (auto optLevel :
60+ {CodeGenOptLevel::None, CodeGenOptLevel::Less, CodeGenOptLevel::Default, CodeGenOptLevel::Aggressive}) {
61+ #endif
5462 GraphicsPipelineBuildInfo pipelineInfo = {};
55- pipelineInfo.options .optimizationLevel = optLevel;
63+ pipelineInfo.options .optimizationLevel = static_cast < uint32_t >( optLevel) ;
5664
5765 GraphicsContext graphicsContext (GfxIp, &pipelineInfo, &pipelineHash, &cacheHash);
5866
5967 context->attachPipelineContext (&graphicsContext);
6068
69+ #if LLVM_MAIN_REVISION && LLVM_MAIN_REVISION < 474768
70+ // Old version of the code
6171 if (optLevel == Level::None) {
72+ #else
73+ // New version of the code (also handles unknown version, which we treat as latest)
74+ // Returns the optimization level for the context.
75+ if (optLevel == CodeGenOptLevel::None) {
76+ #endif
6277 // None might not be possible, so accept >= Level::None
6378 EXPECT_GE (context->getLgcContext ()->getOptimizationLevel (), optLevel);
6479 } else {
6580 EXPECT_EQ (context->getLgcContext ()->getOptimizationLevel (), optLevel);
6681 }
6782 }
6883
84+ #if LLVM_MAIN_REVISION && LLVM_MAIN_REVISION < 474768
85+ // Old version of the code
6986 for (auto optLevel : {Level::None, Level::Less, Level::Default, Level::Aggressive}) {
87+ #else
88+ // New version of the code (also handles unknown version, which we treat as latest)
89+ // Returns the optimization level for the context.
90+ for (auto optLevel :
91+ {CodeGenOptLevel::None, CodeGenOptLevel::Less, CodeGenOptLevel::Default, CodeGenOptLevel::Aggressive}) {
92+ #endif
7093 ComputePipelineBuildInfo pipelineInfo = {};
71- pipelineInfo.options .optimizationLevel = optLevel;
94+ pipelineInfo.options .optimizationLevel = static_cast < uint32_t >( optLevel) ;
7295
7396 ComputeContext computeContext (GfxIp, &pipelineInfo, &pipelineHash, &cacheHash);
7497
7598 context->attachPipelineContext (&computeContext);
7699
100+ #if LLVM_MAIN_REVISION && LLVM_MAIN_REVISION < 474768
101+ // Old version of the code
77102 if (optLevel == Level::None) {
103+ #else
104+ // New version of the code (also handles unknown version, which we treat as latest)
105+ // Returns the optimization level for the context.
106+ if (optLevel == CodeGenOptLevel::None) {
107+ #endif
78108 // None might not be possible, so accept >= Level::None
79109 EXPECT_GE (context->getLgcContext ()->getOptimizationLevel (), optLevel);
80110 } else {
0 commit comments