diff options
| author | Yong He <yonghe@outlook.com> | 2024-02-20 12:24:00 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-20 12:24:00 -0800 |
| commit | 4d20fd329956ac89408b1628a8291fea01bc9a6d (patch) | |
| tree | 8e62d9c1ec05142fd25d0b31073fdb56d44691b0 /source/slang/slang-ir-string-hash.cpp | |
| parent | 8e9b61e3bac69dbb37a1451b62302e688a017ced (diff) | |
Refactor compiler option representations. (#3598)
* Refactor compiler option representation.
* Fix binary compatibility.
* Add a test for specifying compiler options at link time.
* Fix binary compatibility.
* Fix binary compatibility.
* Fix backward compatibility on matrix layout.
* Fix.
* Fix.
* Fix.
* Fix gfx.
* Fix gfx.
* Fix dynamic dispatch.
* Polish.
Diffstat (limited to 'source/slang/slang-ir-string-hash.cpp')
| -rw-r--r-- | source/slang/slang-ir-string-hash.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/source/slang/slang-ir-string-hash.cpp b/source/slang/slang-ir-string-hash.cpp index b7e37d21e..8074bd149 100644 --- a/source/slang/slang-ir-string-hash.cpp +++ b/source/slang/slang-ir-string-hash.cpp @@ -56,26 +56,19 @@ void addGlobalHashedStringLiterals(const StringSlicePool& pool, IRModule* module const Index slicesCount = slices.getCount(); - // Note: This pass is using the extremely low-level `_allocateInst` operation on `IRModule` - // as an optimization. By allocating the instruction here in an "empty" state and then filling - // its operands in in place, we can avoid allocating space for a temporary `List<IRInst*>` to - // hold the IR string values created in the loop below. - // - // TODO: We should probably either eliminate this micro-optimization and just use a `List<IRInst*>` - // here, *or* we should devise a more first-class system for doing in-place instruction creation - // like that that can be compatible with desirable features like automatic deduplication. - // - IRInst* globalHashedInst = module->_allocateInst(kIROp_GlobalHashedStringLiterals, int(slicesCount)); - builder.addInst(globalHashedInst); - - auto operands = globalHashedInst->getOperands(); - + ShortList<IRInst*> operandInsts; for (Index i = 0; i < slicesCount; ++i) { IRStringLit* stringLit = builder.getStringValue(slices[i]); - operands[i].init(globalHashedInst, stringLit); + operandInsts.add(stringLit); } + IRInst* globalHashedInst = builder.emitIntrinsicInst( + nullptr, + kIROp_GlobalHashedStringLiterals, + UInt(slicesCount), + operandInsts.getArrayView().getBuffer()); + // Mark to keep alive builder.addKeepAliveDecoration(globalHashedInst); } |
