Skip to content

Commit 6863270

Browse files
committed
Properly pass no-opaque-pointers to spirv translator
1 parent 97b4f77 commit 6863270

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

opencl_clang.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ Compile(const char *pszProgramSource, const char **pInputHeaders,
314314
pResult->GetIRSize());
315315
std::unique_ptr<llvm::MemoryBuffer> MB = llvm::MemoryBuffer::getMemBuffer(LLVM_IR, pResult->GetIRName(), false);
316316
llvm::LLVMContext Context;
317+
if (!optionsParser.hasOpaquePointers()){
318+
Context.setOpaquePointers(false);
319+
}
317320
auto E = llvm::getOwningLazyBitcodeModule(std::move(MB), Context,
318321
/*ShouldLazyLoadMetadata=*/true);
319322
llvm::logAllUnhandledErrors(E.takeError(), err_ostream, "error: ");

options.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class EffectiveOptionsFilter {
145145
class CompileOptionsParser {
146146
public:
147147
CompileOptionsParser(const char *pszOpenCLVersion)
148-
: m_commonFilter(pszOpenCLVersion), m_emitSPIRV(false), m_optDisable(false) {}
148+
: m_commonFilter(pszOpenCLVersion), m_emitSPIRV(false), m_optDisable(false), m_opaquePointers(true) {}
149149

150150
//
151151
// Validates and prepares the effective options to pass to clang upon
@@ -178,6 +178,7 @@ class CompileOptionsParser {
178178

179179
bool hasEmitSPIRV() const { return m_emitSPIRV; }
180180
bool hasOptDisable() const { return m_optDisable; }
181+
bool hasOpaquePointers() const { return m_opaquePointers; }
181182

182183
private:
183184
OpenCLCompileOptTable m_optTbl;
@@ -187,6 +188,7 @@ class CompileOptionsParser {
187188
std::string m_sourceName;
188189
bool m_emitSPIRV;
189190
bool m_optDisable;
191+
bool m_opaquePointers;
190192
};
191193

192194
// Tokenize a string into tokens separated by any char in 'delims'.

options_compile.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ void CompileOptionsParser::processOptions(const char *pszOptions,
418418
m_emitSPIRV = true;
419419
continue;
420420
}
421+
else if (it->compare("-no-opaque-pointers") == 0) {
422+
m_opaquePointers = false;
423+
}
421424
m_effectiveArgsRaw.push_back(it->c_str());
422425
}
423426
}

0 commit comments

Comments
 (0)