|
12 | 12 | // See the License for the specific language governing permissions and
|
13 | 13 | // limitations under the License.
|
14 | 14 |
|
| 15 | +#include "spirv-tools/optimizer.hpp" |
| 16 | + |
| 17 | +#include <sstream> |
15 | 18 | #include <string>
|
16 | 19 | #include <vector>
|
17 | 20 |
|
18 | 21 | #include "gmock/gmock.h"
|
19 | 22 | #include "spirv-tools/libspirv.hpp"
|
20 |
| -#include "spirv-tools/optimizer.hpp" |
21 | 23 | #include "test/opt/pass_fixture.h"
|
22 | 24 |
|
23 | 25 | namespace spvtools {
|
@@ -567,9 +569,32 @@ OpFunctionEnd
|
567 | 569 | SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
568 | 570 |
|
569 | 571 | // Test that the DebugBuildIdentifier is not removed after DCE.
|
570 |
| - bool found = after.find("DebugBuildIdentifier") != std::string::npos; |
571 |
| - EXPECT_TRUE(found) |
| 572 | + size_t dbi_pos = after.find("DebugBuildIdentifier"); |
| 573 | + EXPECT_NE(dbi_pos, std::string::npos) |
572 | 574 | << "Was expecting the DebugBuildIdentifier to have been kept.";
|
| 575 | + std::string string_id; |
| 576 | + std::string flags_id; |
| 577 | + if (dbi_pos != std::string::npos) { |
| 578 | + std::stringstream ss(after.substr(dbi_pos)); |
| 579 | + std::string temp; |
| 580 | + char percent; |
| 581 | + ss >> temp; // Consume "DebugBuildIdentifier" |
| 582 | + ss >> percent >> string_id; |
| 583 | + ss >> percent >> flags_id; |
| 584 | + } |
| 585 | + |
| 586 | + EXPECT_FALSE(string_id.empty()) |
| 587 | + << "Could not find string id for DebugBuildIdentifier."; |
| 588 | + EXPECT_FALSE(flags_id.empty()) |
| 589 | + << "Could not find flags id for DebugBuildIdentifier."; |
| 590 | + |
| 591 | + bool found = |
| 592 | + (after.find("%" + string_id + " = OpString") != std::string::npos); |
| 593 | + EXPECT_TRUE(found) |
| 594 | + << "Was expecting the DebugBuildIdentifier string to have been kept."; |
| 595 | + found = (after.find("%" + flags_id + " = OpConstant") != std::string::npos); |
| 596 | + EXPECT_TRUE(found) |
| 597 | + << "Was expecting the DebugBuildIdentifier constant to have been kept."; |
573 | 598 | }
|
574 | 599 |
|
575 | 600 | } // namespace
|
|
0 commit comments