mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 20:13:40 +00:00
interp: ignore inline assembly in markExternal
The markExternal function is used when a global (function or global variable) is somehow run at runtime. All the other globals it refers to are from then on no longer known at compile time, so can't be used by the interp package anymore. This can also include inline assembly. While it is possible to modify globals that way, it is only possible to modify exported globals: similar to calling an undefined function (in C for example).
This commit is contained in:
committed by
Ron Evans
parent
841f19f49e
commit
95e4dcfb53
Vendored
+12
@@ -66,6 +66,9 @@ entry:
|
||||
call void @modifyExternal(i32* bitcast (void ()* @willModifyGlobal to i32*))
|
||||
store i16 7, i16* @main.exposedValue2
|
||||
|
||||
; Test that inline assembly is ignored.
|
||||
call void @modifyExternal(i32* bitcast (void ()* @hasInlineAsm to i32*))
|
||||
|
||||
; Test switch statement.
|
||||
%switch1 = call i64 @testSwitch(i64 1) ; 1 returns 6
|
||||
%switch2 = call i64 @testSwitch(i64 9) ; 9 returns the default value -1
|
||||
@@ -102,6 +105,15 @@ entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
; Inline assembly should be ignored in the interp package. While it is possible
|
||||
; to modify other globals that way, usually that's not the case and there is no
|
||||
; real way to check.
|
||||
define void @hasInlineAsm() {
|
||||
entry:
|
||||
call void asm sideeffect "", ""()
|
||||
ret void
|
||||
}
|
||||
|
||||
define i64 @testSwitch(i64 %val) {
|
||||
entry:
|
||||
; Test switch statement.
|
||||
|
||||
Reference in New Issue
Block a user