| 1 |
// asmcheck -gcflags=-spectre=ret |
| 2 |
|
| 3 |
//go:build amd64 |
| 4 |
|
| 5 |
package codegen |
| 6 |
|
| 7 |
func CallFunc(f func()) { |
| 8 |
// amd64:`CALL\truntime.retpoline` |
| 9 |
f() |
| 10 |
} |
| 11 |
|
| 12 |
func CallInterface(x interface{ M() }) { |
| 13 |
// amd64:`CALL\truntime.retpoline` |
| 14 |
x.M() |
| 15 |
} |
| 16 |
|
| 17 |
// Check to make sure that jump tables are disabled |
| 18 |
// when retpoline is on. See issue 57097. |
| 19 |
func noJumpTables(x int) int { |
| 20 |
switch x { |
| 21 |
case 0: |
| 22 |
return 0 |
| 23 |
case 1: |
| 24 |
return 1 |
| 25 |
case 2: |
| 26 |
return 2 |
| 27 |
case 3: |
| 28 |
return 3 |
| 29 |
case 4: |
| 30 |
return 4 |
| 31 |
case 5: |
| 32 |
return 5 |
| 33 |
case 6: |
| 34 |
return 6 |
| 35 |
case 7: |
| 36 |
return 7 |
| 37 |
case 8: |
| 38 |
return 8 |
| 39 |
case 9: |
| 40 |
return 9 |
| 41 |
} |
| 42 |
return 10 |
| 43 |
} |