Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Names of subroutines do not match between caller, callee, and declaration in same compilation unit #8

Open
carlobertolli opened this issue May 8, 2015 · 4 comments
Assignees

Comments

@carlobertolli
Copy link

No description provided.

@jleidel
Copy link
Contributor

jleidel commented May 9, 2015

Carlo, do you have a sample code to elicit the bug?

@carlobertolli
Copy link
Author

Yep:

 SUBROUTINE MYSUB(B,N)
  CHARACTER*1 B(1)
  CHARACTER*1 BLNK
  SAVE        BLNK
  DATA        BLNK /' '/

  DO 10 I=1,N
     B(I)=BLNK

10 CONTINUE
RETURN
END

  program invokecharblank
  character*1 STRING(10)
  integer*4 N
  external MYSUB

  N = 10
  call MYSUB(STRING,N)

  do 20 I=1,10
     print *, 'string = ', STRING(I), '.'

20 continue

  end

Compile with -S -emit-llvm and then pass it to clang with the rt library linked.
It will fail saying that the called function does not exist.

@jleidel jleidel self-assigned this May 16, 2015
@jleidel
Copy link
Contributor

jleidel commented May 16, 2015

In examining the IR, Flang appears to mangle the caller beyond appending the underscore. The IR shows:

subroutine definition:
define void @mysub_([1 x i8]* noalias %b, i32* noalias %n)

call location:
call void @mysub_.1([1 x i8]* %0, i32* %n)

The symbol is declared at the bottom of the IR as follows:
declare void @mysub_.1([1 x i8], i32)

@jleidel
Copy link
Contributor

jleidel commented May 16, 2015

The bug occurs when the subroutines are defined as "external"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants