compiler: fix constant globals on AVR

Turn const globals into non-const globals, at least until pointers have
the correct address space attribute.
This commit is contained in:
Ayke van Laethem
2018-09-16 16:31:38 +02:00
parent a02426948b
commit e04f0868ed
2 changed files with 23 additions and 0 deletions
+11
View File
@@ -3129,6 +3129,17 @@ func (c *Compiler) ApplyFunctionSections() {
}
}
// Turn all global constants into global variables. This works around a
// limitation on Harvard architectures (e.g. AVR), where constant and
// non-constant pointers point to a different address space.
func (c *Compiler) NonConstGlobals() {
global := c.mod.FirstGlobal()
for !global.IsNil() {
global.SetGlobalConstant(false)
global = llvm.NextGlobal(global)
}
}
func (c *Compiler) Optimize(optLevel, sizeLevel int, inlinerThreshold uint) {
builder := llvm.NewPassManagerBuilder()
defer builder.Dispose()