Giter VIP home page Giter VIP logo

Comments (6)

achuykov-sc avatar achuykov-sc commented on September 25, 2024

Hi @gambaman,

It seems a compiler issue, the application becomes overoptimized. I'm looking into details to find the root cause and stable fix.

BR,
Alexander

from scr1.

gambaman avatar gambaman commented on September 25, 2024

Hi @gambaman,

It seems a compiler issue, the application becomes overoptimized. I'm looking into details to find the root cause and stable fix.

BR, Alexander

Hello, Alexander. I thought it could be a compiler issue, but then I looked at the assembler code in the dump file and the store half instruction is unconditionally executed when little_endian_SH is called. Look bellow:

00481106 <little_endian_SH>:
  481106:	95b2                	add	a1,a1,a2
  481108:	300027f3          	csrr	a5,mstatus
  48110c:	30079073          	csrw	mstatus,a5
  481110:	0542                	sll	a0,a0,0x10
  481112:	01055293          	srl	t0,a0,0x10
  481116:	00559023          	sh	t0,0(a1)
  48111a:	4681                	li	a3,0
  48111c:	4601                	li	a2,0
  48111e:	4581                	li	a1,0
  481120:	aa818513          	add	a0,gp,-1368 # 4820c8 <__clz_tab+0x150>
  481124:	b5f1                	j	480ff0 <sc_printf>

from scr1.

kv-sc avatar kv-sc commented on September 25, 2024

You have strict aliasing violation between:

uint32_t result
volatile uint16_t* efective_address

You can compile with -fno-strict-aliasing all will work.

Reduced x86 example: https://godbolt.org/z/Eqao1K9T1

from scr1.

gambaman avatar gambaman commented on September 25, 2024

You have strict aliasing violation between:

uint32_t result
volatile uint16_t* efective_address

You can compile with -fno-strict-aliasing all will work.

Reduced x86 example: https://godbolt.org/z/Eqao1K9T1

Hello, Kv-sc. The example code I used is helpless. I could just remove the CSR access or the sc_printf call and it will work. That is not the problem. The problem is that (apparently) scr1 is not working properly.

from scr1.

gambaman avatar gambaman commented on September 25, 2024

You have strict aliasing violation between:

uint32_t result
volatile uint16_t* efective_address

You can compile with -fno-strict-aliasing all will work.

Reduced x86 example: https://godbolt.org/z/Eqao1K9T1

Hello, Kv-sc. You are right. Because of the strict aliasing violation the compiler use the constant 0x88888888 as actual parameter in when calling test_instruction:

481144: 21060613 add a2,a2,528 # 88883210 <__C_STACK_TOP__+0x883f3210> 481148: 88858593 add a1,a1,-1912 # 88888888 <__C_STACK_TOP__+0x883f8888> 48114c: b0418513 add a0,gp,-1276 # 482124 <__clz_tab+0x1ac> 481150: 35d9 jal 481016 <test_instruction>

Thank you very much

from scr1.

gambaman avatar gambaman commented on September 25, 2024

Hi @gambaman,

It seems a compiler issue, the application becomes overoptimized. I'm looking into details to find the root cause and stable fix.

BR, Alexander

As noted by you and by Kv-sc, it is a compiler issue.

from scr1.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.