Normalize constant global variables (#366)
Addresses some failures in customer kernels due to the way clang
codegen's constant aggregates.
* New utility to normalize constant global variables
* called in cluster constants and spirv producer
* rewrites global constants with constant bitcast users that are just
simple reinterpret casts
* added several tests
diff --git a/lib/SPIRVProducerPass.cpp b/lib/SPIRVProducerPass.cpp
index 9f7ba12..f1afcae 100644
--- a/lib/SPIRVProducerPass.cpp
+++ b/lib/SPIRVProducerPass.cpp
@@ -53,6 +53,7 @@
#include "ConstantEmitter.h"
#include "Constants.h"
#include "DescriptorCounter.h"
+#include "NormalizeGlobalVariable.h"
#include "Passes.h"
#if defined(_MSC_VER)
@@ -877,6 +878,8 @@
}
void SPIRVProducerPass::FindGlobalConstVars(Module &M, const DataLayout &DL) {
+ clspv::NormalizeGlobalVariables(M);
+
SmallVector<GlobalVariable *, 8> GVList;
SmallVector<GlobalVariable *, 8> DeadGVList;
for (GlobalVariable &GV : M.globals()) {