Open Quuxplusone opened 8 years ago
Bugzilla Link | PR27704 |
Status | NEW |
Importance | P normal |
Reported by | Manoel Teixeira (mbsteixeira@gmail.com) |
Reported on | 2016-05-10 15:44:06 -0700 |
Last modified on | 2016-11-19 17:42:17 -0800 |
Version | trunk |
Hardware | PC Windows 2000 |
CC | compnerd@compnerd.org, llvm-bugs@lists.llvm.org |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
Do you have any sample code which exhibits this issue? It should be relatively simple, just a common symbol with a 0 alignment should trigger the behavior it seems.
(In reply to comment #1)
> Do you have any sample code which exhibits this issue? It should be
> relatively simple, just a common symbol with a 0 alignment should trigger
> the behavior it seems.
The problem occurs here %errorStatus_TOTVS_ASM = type { i32, i32, i8*, i32
(i8*)*, i32 } .
; ModuleID = 'totvs'
%errorStatus_TOTVS_ASM = type { i32, i32, i8*, i32 (i8*)*, i32 }
%VariantData_TOTVS_ASM = type { i32, [4 x i8], %genData_TOTVS_ASM }
%genData_TOTVS_ASM = type <{ double }>
@flags = common global [8191 x i8] zeroinitializer, align 16
@flags.1 = common global [8191 x i8] zeroinitializer, align 16
@0 = private unnamed_addr constant [20 x i8] c"\0AMSG : %s < ENTER >\00"
@1 = private unnamed_addr constant [13 x i8] c"\0ACONOUT : %s\00"
@errorStru_TOTVS_ASM = common global %errorStatus_TOTVS_ASM zeroinitializer
@2 = private unnamed_addr constant [79 x i8] c"\0ASetError Origem = %d destino
= %d Origem= %d destino = %d tem que ser igual \00"
@3 = private unnamed_addr constant [22 x i8] c"resolver estah errado\00"
@4 = private unnamed_addr constant [8 x i8] c"abcdefg\00"
@5 = private unnamed_addr constant [9 x i8] c"\0AstrS=%s\00"
@6 = private unnamed_addr constant [9 x i8] c"\0AstrS=%s\00"
@7 = private unnamed_addr constant [15 x i8] c"chamando Teste\00"
@8 = private unnamed_addr constant [98 x i8] c"extern Function printFN(n as
integer, d as double, cptr as string) as integer fromlib dllteste\0A\00"
@9 = private unnamed_addr constant [71 x i8] c"extern Function printf(dest as
string , outro as vararg ) as integer\0A\00"
@10 = private unnamed_addr constant [79 x i8] c"Function msgcb( texto as
string) as integer\0ALocal iRet as integer\0AiRet := 135\0A\00"
@11 = private unnamed_addr constant [60 x i8]
c"printFN(iRet,3.56,texto)\0Aprintf(\22MSGcb!!!!!!\22)\0Areturn iRet\0A\00"
@12 = private unnamed_addr constant [21 x i8] c"\0A ni=%d arrT[na]=%d\00"
@13 = private unnamed_addr constant [18 x i8] c"manoel ver agora:\00"
@14 = private unnamed_addr constant [12 x i8] c" memcpy....\00"
@15 = private unnamed_addr constant [132 x i8] c"111
1111ffff\00"
@16 = private unnamed_addr constant [23 x i8] c"notepad.exe 'C:\5Cb.prw'\00"
@17 = private unnamed_addr constant [20 x i8] c"chamando fntrstu...\00"
@18 = private unnamed_addr constant [18 x i8] c"\0AChamando fntrstu\00"
@19 = private unnamed_addr constant [2 x i8] c"\0A\00"
@20 = private unnamed_addr constant [7 x i8] c"\0Ani=%d\00"
@21 = private unnamed_addr constant [10 x i8] c"test1.prw\00"
@22 = private unnamed_addr constant [4 x i8] c"msg\00"
@23 = private unnamed_addr constant [54 x i8] c"\0AGetError ==XX Function Teste
: errorcode=%d line=%d\00"
declare extern_weak i32 @Mostra_TOTVS_ASM(i8*)
declare x86_fastcallcc i32 @getchar()
declare extern_weak x86_fastcallcc i32 @printFN(i32, double, i8*)
declare x86_fastcallcc i32 @printf(i8*, ...)
; Function Attrs: argmemonly nounwind
declare x86_fastcallcc void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8*
nocapture readonly, i32, i32, i1) #0
declare x86_fastcallcc void @fntrstu(%errorStatus_TOTVS_ASM*)
declare x86_fastcallcc i32 @strlen(i8*)
declare x86_fastcallcc i32 @atol(i8*)
declare x86_fastcallcc double @atof(i8*)
declare x86_fastcallcc void @execcmd(i8*, i8*, i32)
define i32 @totvs.teste1.prw.Len(i8* %texto_TOTVS_ASM) {
entry:
%ln_TOTVS_ASM = alloca i32, align 4
%__INTERNAL__RET_VAR__ = alloca i32, align 4
store i32 0, i32* %__INTERNAL__RET_VAR__
store i32 0, i32* %ln_TOTVS_ASM
%strlen = call i32 @strlen(i8* %texto_TOTVS_ASM)
store i32 %strlen, i32* %ln_TOTVS_ASM
%load_return = load i32, i32* %ln_TOTVS_ASM
store i32 %load_return, i32* %__INTERNAL__RET_VAR__
br label %cleanup
cleanup: ; preds = %entry
br label %return
return: ; preds = %cleanup
%finalize = load i32, i32* %__INTERNAL__RET_VAR__
ret i32 %finalize
}
define i32 @totvs.teste1.prw.msg(i8* %texto_TOTVS_ASM) {
entry:
%__INTERNAL__RET_VAR__ = alloca i32, align 4
store i32 0, i32* %__INTERNAL__RET_VAR__
%printf = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @0, i32 0, i32 0), i8* %texto_TOTVS_ASM)
%getchar = call i32 @getchar()
store i32 0, i32* %__INTERNAL__RET_VAR__
br label %cleanup
cleanup: ; preds = %entry
br label %return
return: ; preds = %cleanup
%finalize = load i32, i32* %__INTERNAL__RET_VAR__
ret i32 %finalize
}
define i32 @totvs.teste1.prw.conout(i8* %texto_TOTVS_ASM) {
entry:
%__INTERNAL__RET_VAR__ = alloca i32, align 4
store i32 0, i32* %__INTERNAL__RET_VAR__
%printf = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @1, i32 0, i32 0), i8* %texto_TOTVS_ASM)
store i32 0, i32* %__INTERNAL__RET_VAR__
br label %cleanup
cleanup: ; preds = %entry
br label %return
return: ; preds = %cleanup
%finalize = load i32, i32* %__INTERNAL__RET_VAR__
ret i32 %finalize
}
define i32 @totvs.teste1.prw.TstSoma() {
entry:
%a_TOTVS_ASM = alloca i32, align 4
%__INTERNAL__RET_VAR__ = alloca i32, align 4
store i32 0, i32* %__INTERNAL__RET_VAR__
store i32 0, i32* %a_TOTVS_ASM
%0 = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 10, i32 15)
%1 = extractvalue { i32, i1 } %0, 0
%2 = extractvalue { i32, i1 } %0, 1
br i1 %2, label %cleanup, label %overflow
overflow: ; preds = %entry
store i32 %1, i32* %a_TOTVS_ASM
%loadX = load i32, i32* %a_TOTVS_ASM
%3 = icmp eq i32 %loadX, 25
br i1 %3, label %if_body, label %elseblock
if_body: ; preds = %overflow
store i32 0, i32* %a_TOTVS_ASM
br label %if_end
elseblock: ; preds = %overflow
store i32 30, i32* %a_TOTVS_ASM
br label %if_end
if_end: ; preds = %elseblock, %if_body
%load_return = load i32, i32* %a_TOTVS_ASM
store i32 %load_return, i32* %__INTERNAL__RET_VAR__
br label %cleanup
cleanup: ; preds = %if_end, %entry
br label %return
return: ; preds = %cleanup
%finalize = load i32, i32* %__INTERNAL__RET_VAR__
ret i32 %finalize
}
define i32 @totvs.teste1.prw.SetError(i32 %ErrorID_TOTVS_ASM, i32
%sourceLine_TOTVS_ASM, i8* %sourceName_TOTVS_ASM, i8*
%calledFunction_TOTVS_ASM) {
entry:
%__INTERNAL__RET_VAR__ = alloca i32, align 4
store i32 0, i32* %__INTERNAL__RET_VAR__
%errorStru_TOTVS_ASM.ErrorID_TOTVS_ASM = getelementptr inbounds %errorStatus_TOTVS_ASM, %errorStatus_TOTVS_ASM* @errorStru_TOTVS_ASM, i32 0, i32 0
store i32 %ErrorID_TOTVS_ASM, i32* %errorStru_TOTVS_ASM.ErrorID_TOTVS_ASM, align 4
%errorStru_TOTVS_ASM.sourceLine_TOTVS_ASM = getelementptr inbounds %errorStatus_TOTVS_ASM, %errorStatus_TOTVS_ASM* @errorStru_TOTVS_ASM, i32 0, i32 1
store i32 %sourceLine_TOTVS_ASM, i32* %errorStru_TOTVS_ASM.sourceLine_TOTVS_ASM, align 4
%errorStru_TOTVS_ASM.sourceName_TOTVS_ASM = getelementptr inbounds %errorStatus_TOTVS_ASM, %errorStatus_TOTVS_ASM* @errorStru_TOTVS_ASM, i32 0, i32 2
store i8* %sourceName_TOTVS_ASM, i8** %errorStru_TOTVS_ASM.sourceName_TOTVS_ASM, align 4
%errorStru_TOTVS_ASM.ErrorID_TOTVS_ASM1 = getelementptr inbounds %errorStatus_TOTVS_ASM, %errorStatus_TOTVS_ASM* @errorStru_TOTVS_ASM, i32 0, i32 0
%set_paramtocall = load i32, i32* %errorStru_TOTVS_ASM.ErrorID_TOTVS_ASM1
%errorStru_TOTVS_ASM.sourceLine_TOTVS_ASM2 = getelementptr inbounds %errorStatus_TOTVS_ASM, %errorStatus_TOTVS_ASM* @errorStru_TOTVS_ASM, i32 0, i32 1
%set_paramtocall3 = load i32, i32* %errorStru_TOTVS_ASM.sourceLine_TOTVS_ASM2
%printf = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @2, i32 0, i32 0), i32 %ErrorID_TOTVS_ASM, i32 %set_paramtocall, i32 %sourceLine_TOTVS_ASM, i32 %set_paramtocall3)
store i32 0, i32* %__INTERNAL__RET_VAR__
br label %cleanup
cleanup: ; preds = %entry
br label %return
return: ; preds = %cleanup
%finalize = load i32, i32* %__INTERNAL__RET_VAR__
ret i32 %finalize
}
define i32 @totvs.teste1.prw.GetErrorID() {
entry:
%__INTERNAL__RET_VAR__ = alloca i32, align 4
store i32 0, i32* %__INTERNAL__RET_VAR__
%errorStru_TOTVS_ASM.ErrorID_TOTVS_ASM = getelementptr inbounds %errorStatus_TOTVS_ASM, %errorStatus_TOTVS_ASM* @errorStru_TOTVS_ASM, i32 0, i32 0
%errorStru_TOTVS_ASM.ErrorID_TOTVS_ASM.ret = ptrtoint i32* %errorStru_TOTVS_ASM.ErrorID_TOTVS_ASM to i32
store i32 %errorStru_TOTVS_ASM.ErrorID_TOTVS_ASM.ret, i32* %__INTERNAL__RET_VAR__
br label %cleanup
cleanup: ; preds = %entry
br label %return
return: ; preds = %cleanup
%finalize = load i32, i32* %__INTERNAL__RET_VAR__
ret i32 %finalize
}
define i32 @totvs.teste1.prw.GetErrorLine() {
entry:
%__INTERNAL__RET_VAR__ = alloca i32, align 4
store i32 0, i32* %__INTERNAL__RET_VAR__
%errorStru_TOTVS_ASM.sourceLine_TOTVS_ASM = getelementptr inbounds %errorStatus_TOTVS_ASM, %errorStatus_TOTVS_ASM* @errorStru_TOTVS_ASM, i32 0, i32 1
%errorStru_TOTVS_ASM.sourceLine_TOTVS_ASM.ret = ptrtoint i32* %errorStru_TOTVS_ASM.sourceLine_TOTVS_ASM to i32
store i32 %errorStru_TOTVS_ASM.sourceLine_TOTVS_ASM.ret, i32* %__INTERNAL__RET_VAR__
br label %cleanup
cleanup: ; preds = %entry
br label %return
return: ; preds = %cleanup
%finalize = load i32, i32* %__INTERNAL__RET_VAR__
ret i32 %finalize
}
define i8* @totvs.teste1.prw.GetErrorFunctionName() {
entry:
%__INTERNAL__RET_VAR__ = alloca i8*, align 4
store i8* null, i8** %__INTERNAL__RET_VAR__
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @3, i32 0, i32 0), i8** %__INTERNAL__RET_VAR__
br label %cleanup
cleanup: ; preds = %entry
br label %return
return: ; preds = %cleanup
%finalize = load i8*, i8** %__INTERNAL__RET_VAR__
ret i8* %finalize
}
define i8* @totvs.teste1.prw.GetErrorSource() {
entry:
%__INTERNAL__RET_VAR__ = alloca i8*, align 4
store i8* null, i8** %__INTERNAL__RET_VAR__
%errorStru_TOTVS_ASM.sourceName_TOTVS_ASM = getelementptr inbounds %errorStatus_TOTVS_ASM, %errorStatus_TOTVS_ASM* @errorStru_TOTVS_ASM, i32 0, i32 2
%val = load i8*, i8** %errorStru_TOTVS_ASM.sourceName_TOTVS_ASM
%val1 = bitcast i8* %val to i8*
store i8* %val1, i8** %__INTERNAL__RET_VAR__
br label %cleanup
cleanup: ; preds = %entry
br label %return
return: ; preds = %cleanup
%finalize = load i8*, i8** %__INTERNAL__RET_VAR__
ret i8* %finalize
}
define i1 @totvs.teste1.prw.OperVariant(%VariantData_TOTVS_ASM*
%left_TOTVS_ASM, %VariantData_TOTVS_ASM* %right_TOTVS_ASM,
%VariantData_TOTVS_ASM* %result_TOTVS_ASM, i32 %operador_TOTVS_ASM) {
entry:
%il_TOTVS_ASM = alloca i32, align 4
%sx_TOTVS_ASM = alloca i8*, align 4
%sr_TOTVS_ASM = alloca i8*, align 4
%sl_TOTVS_ASM = alloca i8*, align 4
%__INTERNAL__RET_VAR__ = alloca i1, align 4
store i1 false, i1* %__INTERNAL__RET_VAR__
store i8* null, i8** %sl_TOTVS_ASM
store i8* null, i8** %sr_TOTVS_ASM
store i8* null, i8** %sx_TOTVS_ASM
store i32 0, i32* %il_TOTVS_ASM
%left_TOTVS_ASM.tp_TOTVS_ASM = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %left_TOTVS_ASM, i32 0, i32 0
%right_TOTVS_ASM.tp_TOTVS_ASM = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %right_TOTVS_ASM, i32 0, i32 0
%loadX = load i32, i32* %left_TOTVS_ASM.tp_TOTVS_ASM
%loadX1 = load i32, i32* %right_TOTVS_ASM.tp_TOTVS_ASM
%0 = icmp ne i32 %loadX, %loadX1
br i1 %0, label %if_body, label %if_end
if_body: ; preds = %entry
store i1 false, i1* %__INTERNAL__RET_VAR__
br label %cleanup
if_end: ; preds = %entry
%result_TOTVS_ASM.tp_TOTVS_ASM = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %result_TOTVS_ASM, i32 0, i32 0
%left_TOTVS_ASM.tp_TOTVS_ASM2 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %left_TOTVS_ASM, i32 0, i32 0
%1 = load i32, i32* %left_TOTVS_ASM.tp_TOTVS_ASM2, align 4
store i32 %1, i32* %result_TOTVS_ASM.tp_TOTVS_ASM, align 4
%left_TOTVS_ASM.tp_TOTVS_ASM5 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %left_TOTVS_ASM, i32 0, i32 0
%loadX6 = load i32, i32* %left_TOTVS_ASM.tp_TOTVS_ASM5
%2 = icmp eq i32 %loadX6, 1
br i1 %2, label %if_body3, label %if_end4
if_body3: ; preds = %if_end
%result_TOTVS_ASM.value_TOTVS_ASM = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %result_TOTVS_ASM, i32 0, i32 2
%struc_elem_vInt_TOTVS_ASM = getelementptr inbounds %genData_TOTVS_ASM, %genData_TOTVS_ASM* %result_TOTVS_ASM.value_TOTVS_ASM, i32 0, i32 0
%left_TOTVS_ASM.value_TOTVS_ASM = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %left_TOTVS_ASM, i32 0, i32 2
%struc_elem_vInt_TOTVS_ASM7 = getelementptr inbounds %genData_TOTVS_ASM, %genData_TOTVS_ASM* %left_TOTVS_ASM.value_TOTVS_ASM, i32 0, i32 0
%right_TOTVS_ASM.value_TOTVS_ASM = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %right_TOTVS_ASM, i32 0, i32 2
%struc_elem_vInt_TOTVS_ASM8 = getelementptr inbounds %genData_TOTVS_ASM, %genData_TOTVS_ASM* %right_TOTVS_ASM.value_TOTVS_ASM, i32 0, i32 0
%3 = load double, double* %struc_elem_vInt_TOTVS_ASM7
%4 = load double, double* %struc_elem_vInt_TOTVS_ASM8
%5 = fadd double %3, %4
store double %5, double* %struc_elem_vInt_TOTVS_ASM
store i1 true, i1* %__INTERNAL__RET_VAR__
br label %cleanup
if_end4: ; preds = %if_end
%left_TOTVS_ASM.tp_TOTVS_ASM11 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %left_TOTVS_ASM, i32 0, i32 0
%loadX12 = load i32, i32* %left_TOTVS_ASM.tp_TOTVS_ASM11
%6 = icmp eq i32 %loadX12, 2
br i1 %6, label %if_body9, label %if_end10
if_body9: ; preds = %if_end4
%result_TOTVS_ASM.value_TOTVS_ASM13 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %result_TOTVS_ASM, i32 0, i32 2
%struc_elem_vDbl_TOTVS_ASM = getelementptr inbounds %genData_TOTVS_ASM, %genData_TOTVS_ASM* %result_TOTVS_ASM.value_TOTVS_ASM13, i32 0, i32 0
%left_TOTVS_ASM.value_TOTVS_ASM14 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %left_TOTVS_ASM, i32 0, i32 2
%struc_elem_vDbl_TOTVS_ASM15 = getelementptr inbounds %genData_TOTVS_ASM, %genData_TOTVS_ASM* %left_TOTVS_ASM.value_TOTVS_ASM14, i32 0, i32 0
%right_TOTVS_ASM.value_TOTVS_ASM16 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %right_TOTVS_ASM, i32 0, i32 2
%struc_elem_vDbl_TOTVS_ASM17 = getelementptr inbounds %genData_TOTVS_ASM, %genData_TOTVS_ASM* %right_TOTVS_ASM.value_TOTVS_ASM16, i32 0, i32 0
%7 = load double, double* %struc_elem_vDbl_TOTVS_ASM15
%8 = load double, double* %struc_elem_vDbl_TOTVS_ASM17
%9 = fadd double %7, %8
store double %9, double* %struc_elem_vDbl_TOTVS_ASM
store i1 true, i1* %__INTERNAL__RET_VAR__
br label %cleanup
if_end10: ; preds = %if_end4
%left_TOTVS_ASM.tp_TOTVS_ASM20 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %left_TOTVS_ASM, i32 0, i32 0
%loadX21 = load i32, i32* %left_TOTVS_ASM.tp_TOTVS_ASM20
%10 = icmp eq i32 %loadX21, 3
br i1 %10, label %if_body18, label %if_end19
if_body18: ; preds = %if_end10
%11 = load i8*, i8** %sl_TOTVS_ASM
%12 = load i8*, i8** %sl_TOTVS_ASM
%13 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @4, i32 0, i32 0))
%binAssignString = add i32 %13, 1
%mallocsize = mul i32 %binAssignString, ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i32)
%malloccall = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32 %mallocsize)
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %malloccall, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @4, i32 0, i32 0), i32 %binAssignString, i32 1, i1 false)
call void @FreePtr(i8** %sl_TOTVS_ASM)
store i8* %malloccall, i8** %sl_TOTVS_ASM
%result_TOTVS_ASM.value_TOTVS_ASM22 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %result_TOTVS_ASM, i32 0, i32 2
%struc_elem_vStr_TOTVS_ASM = getelementptr inbounds %genData_TOTVS_ASM, %genData_TOTVS_ASM* %result_TOTVS_ASM.value_TOTVS_ASM22, i32 0, i32 0
%set_paramtocall = load double, double* %struc_elem_vStr_TOTVS_ASM
%printf = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @5, i32 0, i32 0), double %set_paramtocall)
%result_TOTVS_ASM.value_TOTVS_ASM23 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %result_TOTVS_ASM, i32 0, i32 2
%struc_elem_vStr_TOTVS_ASM24 = getelementptr inbounds %genData_TOTVS_ASM, %genData_TOTVS_ASM* %result_TOTVS_ASM.value_TOTVS_ASM23, i32 0, i32 0
%set_paramtocall25 = load double, double* %struc_elem_vStr_TOTVS_ASM24
%printf26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @6, i32 0, i32 0), double %set_paramtocall25)
store i1 true, i1* %__INTERNAL__RET_VAR__
br label %cleanup
if_end19: ; preds = %if_end10
store i1 false, i1* %__INTERNAL__RET_VAR__
br label %cleanup
cleanup: ; preds = %if_end19,
%if_body18, %if_body9, %if_body3, %if_body
call void @FreePtr(i8** %sl_TOTVS_ASM)
br label %return
return: ; preds = %cleanup
%finalize = load i1, i1* %__INTERNAL__RET_VAR__
ret i1 %finalize
}
define double @totvs.teste1.prw.TesteCall(i32 %parami_TOTVS_ASM,
%VariantData_TOTVS_ASM* %paramv_TOTVS_ASM) {
entry:
%v3_TOTVS_ASM = alloca double, align 4
%__INTERNAL__RET_VAR__ = alloca double, align 4
store double 0.000000e+00, double* %__INTERNAL__RET_VAR__
store double 0.000000e+00, double* %v3_TOTVS_ASM
%0 = icmp sgt i32 3, 3
br i1 %0, label %outofbound, label %inbound
outofbound: ; preds = %entry
br label %return
inbound: ; preds = %entry
%tarr_elem_ = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %paramv_TOTVS_ASM, i32 2
%paramv_TOTVS_ASM.value_TOTVS_ASM = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %tarr_elem_, i32 0, i32 2
%1 = icmp sgt i32 1, 1
br i1 %1, label %outofbound1, label %inbound2
outofbound1: ; preds = %inbound
br label %return
inbound2: ; preds = %inbound
%tarr_elem_3 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %paramv_TOTVS_ASM, i32 0
%paramv_TOTVS_ASM.value_TOTVS_ASM4 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %tarr_elem_3, i32 0, i32 2
%paramtocall = bitcast %genData_TOTVS_ASM* %paramv_TOTVS_ASM.value_TOTVS_ASM4 to i32*
%paramtocall5 = load i32, i32* %paramtocall
%2 = icmp sgt i32 2, 2
br i1 %2, label %outofbound6, label %inbound7
outofbound6: ; preds = %inbound2
br label %return
inbound7: ; preds = %inbound2
%tarr_elem_8 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %paramv_TOTVS_ASM, i32 1
%paramv_TOTVS_ASM.value_TOTVS_ASM9 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %tarr_elem_8, i32 0, i32 2
%paramtocall10 = bitcast %genData_TOTVS_ASM* %paramv_TOTVS_ASM.value_TOTVS_ASM9 to i32*
%paramtocall11 = load i32, i32* %paramtocall10
%3 = icmp sgt i32 3, 3
br i1 %3, label %outofbound12, label %inbound13
outofbound12: ; preds = %inbound7
br label %return
inbound13: ; preds = %inbound7
%tarr_elem_14 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %paramv_TOTVS_ASM, i32 2
%paramv_TOTVS_ASM.value_TOTVS_ASM15 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %tarr_elem_14, i32 0, i32 2
%paramtocall16 = bitcast %genData_TOTVS_ASM* %paramv_TOTVS_ASM.value_TOTVS_ASM15 to double*
%paramtocall17 = load double, double* %paramtocall16
%4 = icmp sgt i32 4, 4
br i1 %4, label %outofbound18, label %inbound19
outofbound18: ; preds = %inbound13
br label %return
inbound19: ; preds = %inbound13
%tarr_elem_20 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %paramv_TOTVS_ASM, i32 3
%paramv_TOTVS_ASM.value_TOTVS_ASM21 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %tarr_elem_20, i32 0, i32 2
%paramtocall22 = bitcast %genData_TOTVS_ASM* %paramv_TOTVS_ASM.value_TOTVS_ASM21 to i8**
%paramtocall23 = load i8*, i8** %paramtocall22
%Teste = call double @totvs.teste1.prw.Teste(i32 %paramtocall5, i32 %paramtocall11, double %paramtocall17, i8* %paramtocall23)
%paramv_TOTVS_ASM.value_TOTVS_ASM24 = bitcast %genData_TOTVS_ASM* %paramv_TOTVS_ASM.value_TOTVS_ASM to double*
store double %Teste, double* %paramv_TOTVS_ASM.value_TOTVS_ASM24, align 4
%5 = icmp sgt i32 3, 3
br i1 %5, label %outofbound25, label %inbound26
outofbound25: ; preds = %inbound19
br label %return
inbound26: ; preds = %inbound19
%tarr_elem_27 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %paramv_TOTVS_ASM, i32 2
%paramv_TOTVS_ASM.value_TOTVS_ASM28 = getelementptr inbounds %VariantData_TOTVS_ASM, %VariantData_TOTVS_ASM* %tarr_elem_27, i32 0, i32 2
%VerifyStruct = bitcast %genData_TOTVS_ASM* %paramv_TOTVS_ASM.value_TOTVS_ASM28 to double*
%VerifyStruct29 = load double, double* %VerifyStruct
%.vDbl_TOTVS_ASM.ret = bitcast double %VerifyStruct29 to double
store double %.vDbl_TOTVS_ASM.ret, double* %__INTERNAL__RET_VAR__
br label %cleanup
cleanup: ; preds = %inbound26
br label %return
return: ; preds = %cleanup,
%outofbound25, %outofbound18, %outofbound12, %outofbound6, %outofbound1,
%outofbound
%finalize = load double, double* %__INTERNAL__RET_VAR__
ret double %finalize
}
define double @totvs.teste1.prw.Teste(i32 %parami1_TOTVS_ASM, i32
%parami2_TOTVS_ASM, double %paramd_TOTVS_ASM, i8* %params_TOTVS_ASM) {
entry:
%0 = alloca i8*, align 4
%1 = alloca i8*, align 4
%2 = alloca i8*, align 4
%3 = alloca i8*, align 4
%4 = alloca i8*, align 4
%scom_TOTVS_ASM = alloca i8*, align 4
%erro_TOTVS_ASM = alloca %errorStatus_TOTVS_ASM, align 4
%retorno_TOTVS_ASM = alloca i8*, align 4
%s_TOTVS_ASM = alloca i8*, align 4
%ret_TOTVS_ASM = alloca double, align 4
%nCount_TOTVS_ASM = alloca i32, align 4
%ni_TOTVS_ASM = alloca i32, align 4
%na_TOTVS_ASM = alloca i32, align 4
%__INTERNAL__RET_VAR__ = alloca double, align 4
store double 0.000000e+00, double* %__INTERNAL__RET_VAR__
%mallocsize = mul i32 %parami1_TOTVS_ASM, ptrtoint (i32* getelementptr (i32, i32* null, i32 1) to i32)
%malloccall = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32 %mallocsize)
%arrT_TOTVS_ASM = bitcast i8* %malloccall to i32*
store i32 0, i32* %na_TOTVS_ASM
store i32 0, i32* %ni_TOTVS_ASM
store i32 0, i32* %nCount_TOTVS_ASM
store double 0.000000e+00, double* %ret_TOTVS_ASM
store i8* null, i8** %s_TOTVS_ASM
store i8* null, i8** %retorno_TOTVS_ASM
store i8* null, i8** %scom_TOTVS_ASM
%printf = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @7, i32 0, i32 0))
%5 = load i8*, i8** %scom_TOTVS_ASM
%6 = load i8*, i8** %scom_TOTVS_ASM
%7 = call i32 @strlen(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @8, i32 0, i32 0))
%binAssignString = add i32 %7, 1
%mallocsize1 = mul i32 %binAssignString, ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i32)
%malloccall2 = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32 %mallocsize1)
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %malloccall2, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @8, i32 0, i32 0), i32 %binAssignString, i32 1, i1 false)
call void @FreePtr(i8** %scom_TOTVS_ASM)
store i8* %malloccall2, i8** %scom_TOTVS_ASM
%8 = load i8*, i8** %scom_TOTVS_ASM
%9 = call i32 @strlen(i8* %8)
%10 = call i32 @strlen(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @9, i32 0, i32 0))
%11 = add i32 %9, %10
%binX = add i32 %11, 1
%mallocsize3 = mul i32 %binX, ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i32)
%malloccall4 = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32 %mallocsize3)
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %malloccall4, i8* %8, i32 %9, i32 1, i1 false)
%12 = getelementptr inbounds i8, i8* %malloccall4, i32 %9
%binX5 = add i32 %10, 1
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %12, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @9, i32 0, i32 0), i32 %binX5, i32 1, i1 false)
%13 = load i8*, i8** %scom_TOTVS_ASM
%14 = load i8*, i8** %scom_TOTVS_ASM
%15 = call i32 @strlen(i8* %malloccall4)
%binAssignString6 = add i32 %15, 1
%mallocsize7 = mul i32 %binAssignString6, ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i32)
%malloccall8 = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32 %mallocsize7)
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %malloccall8, i8* %malloccall4, i32 %binAssignString6, i32 1, i1 false)
%castX = bitcast i8* %malloccall4 to i8*
store i8* %castX, i8** %4
call void @FreePtr(i8** %4)
call void @FreePtr(i8** %scom_TOTVS_ASM)
store i8* %malloccall8, i8** %scom_TOTVS_ASM
%16 = load i8*, i8** %scom_TOTVS_ASM
%17 = call i32 @strlen(i8* %16)
%18 = call i32 @strlen(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @10, i32 0, i32 0))
%19 = add i32 %17, %18
%binX9 = add i32 %19, 1
%mallocsize10 = mul i32 %binX9, ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i32)
%malloccall11 = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32 %mallocsize10)
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %malloccall11, i8* %16, i32 %17, i32 1, i1 false)
%20 = getelementptr inbounds i8, i8* %malloccall11, i32 %17
%binX12 = add i32 %18, 1
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %20, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @10, i32 0, i32 0), i32 %binX12, i32 1, i1 false)
%21 = load i8*, i8** %scom_TOTVS_ASM
%22 = load i8*, i8** %scom_TOTVS_ASM
%23 = call i32 @strlen(i8* %malloccall11)
%binAssignString13 = add i32 %23, 1
%mallocsize14 = mul i32 %binAssignString13, ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i32)
%malloccall15 = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32 %mallocsize14)
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %malloccall15, i8* %malloccall11, i32 %binAssignString13, i32 1, i1 false)
%castX16 = bitcast i8* %malloccall11 to i8*
store i8* %castX16, i8** %3
call void @FreePtr(i8** %3)
call void @FreePtr(i8** %scom_TOTVS_ASM)
store i8* %malloccall15, i8** %scom_TOTVS_ASM
%24 = load i8*, i8** %scom_TOTVS_ASM
%25 = call i32 @strlen(i8* %24)
%26 = call i32 @strlen(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @11, i32 0, i32 0))
%27 = add i32 %25, %26
%binX17 = add i32 %27, 1
%mallocsize18 = mul i32 %binX17, ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i32)
%malloccall19 = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32 %mallocsize18)
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %malloccall19, i8* %24, i32 %25, i32 1, i1 false)
%28 = getelementptr inbounds i8, i8* %malloccall19, i32 %25
%binX20 = add i32 %26, 1
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %28, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @11, i32 0, i32 0), i32 %binX20, i32 1, i1 false)
%29 = load i8*, i8** %scom_TOTVS_ASM
%30 = load i8*, i8** %scom_TOTVS_ASM
%31 = call i32 @strlen(i8* %malloccall19)
%binAssignString21 = add i32 %31, 1
%mallocsize22 = mul i32 %binAssignString21, ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i32)
%malloccall23 = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32 %mallocsize22)
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %malloccall23, i8* %malloccall19, i32 %binAssignString21, i32 1, i1 false)
%castX24 = bitcast i8* %malloccall19 to i8*
store i8* %castX24, i8** %2
call void @FreePtr(i8** %2)
call void @FreePtr(i8** %scom_TOTVS_ASM)
store i8* %malloccall23, i8** %scom_TOTVS_ASM
%32 = icmp uge i32 %parami1_TOTVS_ASM, 100
%iifX = select i1 %32, i32 100, i32 %parami1_TOTVS_ASM
store i32 %iifX, i32* %nCount_TOTVS_ASM
store i32 1, i32* %na_TOTVS_ASM
%loadX = load i32, i32* %na_TOTVS_ASM
%loadX25 = load i32, i32* %nCount_TOTVS_ASM
%pre_for_icmp = icmp sle i32 %loadX, %loadX25
br i1 %pre_for_icmp, label %adv_loop, label %adv_loop_end
adv_loop: ; preds = %continue, %entry
%33 = load i32, i32* %na_TOTVS_ASM
%34 = icmp sgt i32 %33, %parami1_TOTVS_ASM
br i1 %34, label %outofbound, label %inbound
outofbound: ; preds = %adv_loop
br label %return
inbound: ; preds = %adv_loop
%loadX26 = load i32, i32* %na_TOTVS_ASM
%icmp_iszero = icmp eq i32 %loadX26, 0
%iszero = select i1 %icmp_iszero, i32 1, i32 %loadX26
%binX27 = sub i32 %iszero, 1
%tarr_elem_ = getelementptr inbounds i32, i32* %arrT_TOTVS_ASM, i32 %binX27
%loadX28 = load i32, i32* %na_TOTVS_ASM
store i32 %loadX28, i32* %tarr_elem_
br label %continue
continue: ; preds = %inbound
%loadX29 = load i32, i32* %na_TOTVS_ASM
%for_incr = add i32 %loadX29, 1
store i32 %for_incr, i32* %na_TOTVS_ASM
%for_icmp = icmp sle i32 %for_incr, %loadX25
br i1 %for_icmp, label %adv_loop, label %adv_loop_end
adv_loop_end: ; preds = %continue, %entry
store i32 1, i32* %na_TOTVS_ASM
%loadX33 = load i32, i32* %na_TOTVS_ASM
%loadX34 = load i32, i32* %nCount_TOTVS_ASM
%pre_for_icmp35 = icmp sle i32 %loadX33, %loadX34
br i1 %pre_for_icmp35, label %adv_loop30, label %adv_loop_end32
adv_loop30: ; preds = %continue31,
%adv_loop_end
%35 = load i32, i32* %na_TOTVS_ASM
%36 = icmp sgt i32 %35, %parami1_TOTVS_ASM
br i1 %36, label %outofbound36, label %inbound37
outofbound36: ; preds = %adv_loop30
br label %return
inbound37: ; preds = %adv_loop30
%loadX38 = load i32, i32* %na_TOTVS_ASM
%icmp_iszero39 = icmp eq i32 %loadX38, 0
%iszero40 = select i1 %icmp_iszero39, i32 1, i32 %loadX38
%binX41 = sub i32 %iszero40, 1
%tarr_elem_42 = getelementptr inbounds i32, i32* %arrT_TOTVS_ASM, i32 %binX41
%37 = bitcast i32* %tarr_elem_42 to i32*
%38 = load i32, i32* %37
store i32 %38, i32* %ni_TOTVS_ASM
%loadX43 = load i32, i32* %ni_TOTVS_ASM
%39 = load i32, i32* %na_TOTVS_ASM
%40 = icmp sgt i32 %39, %parami1_TOTVS_ASM
br i1 %40, label %outofbound44, label %inbound45
outofbound44: ; preds = %inbound37
br label %return
inbound45: ; preds = %inbound37
%loadX46 = load i32, i32* %na_TOTVS_ASM
%icmp_iszero47 = icmp eq i32 %loadX46, 0
%iszero48 = select i1 %icmp_iszero47, i32 1, i32 %loadX46
%binX49 = sub i32 %iszero48, 1
%tarr_elem_50 = getelementptr inbounds i32, i32* %arrT_TOTVS_ASM, i32 %binX49
%set_paramtocall = load i32, i32* %tarr_elem_50
%printf51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @12, i32 0, i32 0), i32 %loadX43, i32 %set_paramtocall)
br label %continue31
continue31: ; preds = %inbound45
%loadX52 = load i32, i32* %na_TOTVS_ASM
%for_incr53 = add i32 %loadX52, 1
store i32 %for_incr53, i32* %na_TOTVS_ASM
%for_icmp54 = icmp sle i32 %for_incr53, %loadX34
br i1 %for_icmp54, label %adv_loop30, label %adv_loop_end32
adv_loop_end32: ; preds = %continue31,
%adv_loop_end
%41 = load i8*, i8** %s_TOTVS_ASM
%42 = load i8*, i8** %s_TOTVS_ASM
%43 = call i32 @strlen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @13, i32 0, i32 0))
%binAssignString55 = add i32 %43, 1
%mallocsize56 = mul i32 %binAssignString55, ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i32)
%malloccall57 = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32 %mallocsize56)
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %malloccall57, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @13, i32 0, i32 0), i32 %binAssignString55, i32 1, i1 false)
call void @FreePtr(i8** %s_TOTVS_ASM)
store i8* %malloccall57, i8** %s_TOTVS_ASM
%44 = load i8*, i8** %s_TOTVS_ASM
%45 = call i32 @strlen(i8* %44)
%46 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @14, i32 0, i32 0))
%47 = add i32 %45, %46
%binX58 = add i32 %47, 1
%mallocsize59 = mul i32 %binX58, ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i32)
%malloccall60 = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32 %mallocsize59)
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %malloccall60, i8* %44, i32 %45, i32 1, i1 false)
%48 = getelementptr inbounds i8, i8* %malloccall60, i32 %45
%binX61 = add i32 %46, 1
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %48, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @14, i32 0, i32 0), i32 %binX61, i32 1, i1 false)
%49 = load i8*, i8** %s_TOTVS_ASM
%50 = load i8*, i8** %s_TOTVS_ASM
%51 = call i32 @strlen(i8* %malloccall60)
%binAssignString62 = add i32 %51, 1
%mallocsize63 = mul i32 %binAssignString62, ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i32)
%malloccall64 = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32 %mallocsize63)
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %malloccall64, i8* %malloccall60, i32 %binAssignString62, i32 1, i1 false)
%castX65 = bitcast i8* %malloccall60 to i8*
store i8* %castX65, i8** %1
call void @FreePtr(i8** %1)
call void @FreePtr(i8** %s_TOTVS_ASM)
store i8* %malloccall64, i8** %s_TOTVS_ASM
%52 = load i8*, i8** %retorno_TOTVS_ASM
%53 = load i8*, i8** %retorno_TOTVS_ASM
%54 = call i32 @strlen(i8* getelementptr inbounds ([132 x i8], [132 x i8]* @15, i32 0, i32 0))
%binAssignString66 = add i32 %54, 1
%mallocsize67 = mul i32 %binAssignString66, ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i32)
%malloccall68 = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32 %mallocsize67)
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %malloccall68, i8* getelementptr inbounds ([132 x i8], [132 x i8]* @15, i32 0, i32 0), i32 %binAssignString66, i32 1, i1 false)
call void @FreePtr(i8** %retorno_TOTVS_ASM)
store i8* %malloccall68, i8** %retorno_TOTVS_ASM
%55 = load i8*, i8** %retorno_TOTVS_ASM
%strlen = call i32 @strlen(i8* %55)
store i32 %strlen, i32* %na_TOTVS_ASM
%56 = load i8*, i8** %retorno_TOTVS_ASM
%loadX69 = load i32, i32* %na_TOTVS_ASM
call void @execcmd(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @16, i32 0, i32 0), i8* %56, i32 %loadX69)
%57 = load i8*, i8** %retorno_TOTVS_ASM
%58 = load i8*, i8** %retorno_TOTVS_ASM
%59 = call i32 @strlen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @17, i32 0, i32 0))
%binAssignString70 = add i32 %59, 1
%mallocsize71 = mul i32 %binAssignString70, ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i32)
%malloccall72 = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32 %mallocsize71)
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %malloccall72, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @17, i32 0, i32 0), i32 %binAssignString70, i32 1, i1 false)
call void @FreePtr(i8** %retorno_TOTVS_ASM)
store i8* %malloccall72, i8** %retorno_TOTVS_ASM
%erro_TOTVS_ASM.ErrorID_TOTVS_ASM = getelementptr inbounds %errorStatus_TOTVS_ASM, %errorStatus_TOTVS_ASM* %erro_TOTVS_ASM, i32 0, i32 0
store i32 1234, i32* %erro_TOTVS_ASM.ErrorID_TOTVS_ASM, align 4
%erro_TOTVS_ASM.sourceLine_TOTVS_ASM = getelementptr inbounds %errorStatus_TOTVS_ASM, %errorStatus_TOTVS_ASM* %erro_TOTVS_ASM, i32 0, i32 1
store i32 5678, i32* %erro_TOTVS_ASM.sourceLine_TOTVS_ASM, align 4
%erro_TOTVS_ASM.sourceName_TOTVS_ASM = getelementptr inbounds %errorStatus_TOTVS_ASM, %errorStatus_TOTVS_ASM* %erro_TOTVS_ASM, i32 0, i32 2
%60 = load i8*, i8** %retorno_TOTVS_ASM
store i8* %60, i8** %erro_TOTVS_ASM.sourceName_TOTVS_ASM, align 4
%erro_TOTVS_ASM.fnToCall_TOTVS_ASM = getelementptr inbounds %errorStatus_TOTVS_ASM, %errorStatus_TOTVS_ASM* %erro_TOTVS_ASM, i32 0, i32 3
store i32 (i8*)* @totvs.teste1.prw.msg, i32 (i8*)** %erro_TOTVS_ASM.fnToCall_TOTVS_ASM, align 4
%printf73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @18, i32 0, i32 0))
call void @fntrstu(%errorStatus_TOTVS_ASM* %erro_TOTVS_ASM)
%erro_TOTVS_ASM.sourceName_TOTVS_ASM74 = getelementptr inbounds %errorStatus_TOTVS_ASM, %errorStatus_TOTVS_ASM* %erro_TOTVS_ASM, i32 0, i32 2
%set_paramtocall75 = load i8*, i8** %erro_TOTVS_ASM.sourceName_TOTVS_ASM74
%printf76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @19, i32 0, i32 0), i8* %set_paramtocall75)
store double 2.367000e+01, double* %ret_TOTVS_ASM
%loadX77 = load double, double* %ret_TOTVS_ASM
%61 = fadd double %loadX77, %paramd_TOTVS_ASM
store double %61, double* %ret_TOTVS_ASM
%loadX78 = load double, double* %ret_TOTVS_ASM
%62 = fsub double %loadX78, %paramd_TOTVS_ASM
store double %62, double* %ret_TOTVS_ASM
%loadX79 = load double, double* %ret_TOTVS_ASM
%63 = fmul double %loadX79, %paramd_TOTVS_ASM
store double %63, double* %ret_TOTVS_ASM
%loadX80 = load double, double* %ret_TOTVS_ASM
%64 = fcmp oeq double %paramd_TOTVS_ASM, 0.000000e+00
br i1 %64, label %cleanup, label %zero_div
zero_div: ; preds = %adv_loop_end32
%65 = fdiv double %loadX80, %paramd_TOTVS_ASM
store double %65, double* %ret_TOTVS_ASM
%66 = load i8*, i8** %scom_TOTVS_ASM
%strlen81 = call i32 @strlen(i8* %66)
store i32 %strlen81, i32* %ni_TOTVS_ASM
%loadX82 = load i32, i32* %ni_TOTVS_ASM
%67 = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %loadX82, i32 1)
%68 = extractvalue { i32, i1 } %67, 0
%69 = extractvalue { i32, i1 } %67, 1
br i1 %69, label %cleanup, label %overflow
overflow: ; preds = %zero_div
store i32 %68, i32* %ni_TOTVS_ASM
%loadX83 = load i32, i32* %ni_TOTVS_ASM
%printf84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @20, i32 0, i32 0), i32 %loadX83)
%70 = load i8*, i8** %scom_TOTVS_ASM
%loadX85 = load i32, i32* %ni_TOTVS_ASM
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %params_TOTVS_ASM, i8* %70, i32 %loadX85, i32 1, i1 false)
%SetError = call i32 @totvs.teste1.prw.SetError(i32 10000, i32 20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @21, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @22, i32 0, i32 0))
%GetErrorID = call i32 @totvs.teste1.prw.GetErrorID()
%GetErrorLine = call i32 @totvs.teste1.prw.GetErrorLine()
%printf86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @23, i32 0, i32 0), i32 %GetErrorID, i32 %GetErrorLine)
%load_return = load double, double* %ret_TOTVS_ASM
store double %load_return, double* %__INTERNAL__RET_VAR__
br label %cleanup
cleanup: ; preds = %overflow,
%zero_div, %adv_loop_end32
call void @FreePtr(i8** %retorno_TOTVS_ASM)
%castX87 = bitcast i32* %arrT_TOTVS_ASM to i8*
store i8* %castX87, i8** %0
call void @FreePtr(i8** %0)
call void @FreePtr(i8** %scom_TOTVS_ASM)
call void @FreePtr(i8** %s_TOTVS_ASM)
br label %return
return: ; preds = %cleanup,
%outofbound44, %outofbound36, %outofbound
%finalize = load double, double* %__INTERNAL__RET_VAR__
ret double %finalize
}
; Function Attrs: nounwind uwtable
define x86_fastcallcc void @FreePtr(i8** %ptr) #1 {
entry:
%ptr.addr = alloca i8**, align 8
store i8** %ptr, i8*** %ptr.addr, align 8
%0 = load i8**, i8*** %ptr.addr, align 8
%1 = load i8*, i8** %0, align 8
%tobool = icmp ne i8* %1, null
br i1 %tobool, label %if.then, label %if.end
if.then: ; preds = %entry
%2 = load i8**, i8*** %ptr.addr, align 8
%3 = load i8*, i8** %2, align 8
call x86_fastcallcc void @free(i8* %3) #2
br label %if.end
if.end: ; preds = %if.then, %entry
%4 = load i8**, i8*** %ptr.addr, align 8
store i8* null, i8** %4, align 8
ret void
}
; Function Attrs: nounwind
declare x86_fastcallcc void @free(i8*) #2
; Function Attrs: nounwind
define i8* @AllocPtr(i32 %szallocptr) #2 {
entryallocptr:
%sz.addrallocptr = alloca i32, align 4
store i32 %szallocptr, i32* %sz.addrallocptr, align 4
%0 = load i32, i32* %sz.addrallocptr, align 4
%convallocptr = sext i32 %0 to i64
%call = call i8* @malloc(i64 %convallocptr)
ret i8* %call
}
declare i8* @malloc(i64)
; Function Attrs: nounwind
define i32 @AssignPtr(i8** %destaptr, i8* %origaptr) #2 {
entryaptr:
%retvalaptr = alloca i32, align 4
%dest.addraptr = alloca i8**, align 8
%orig.addraptr = alloca i8*, align 8
store i8** %destaptr, i8*** %dest.addraptr, align 8
store i8* %origaptr, i8** %orig.addraptr, align 8
%0 = load i8*, i8** %orig.addraptr, align 8
%toboolaptr = icmp ne i8* %0, null
br i1 %toboolaptr, label %if.endaptr, label %if.thenaptr
if.thenaptr: ; preds = %entryaptr
store i32 0, i32* %retvalaptr
br label %returnaptr
if.endaptr: ; preds = %entryaptr
%1 = load i8**, i8*** %dest.addraptr, align 8
%tobool1aptr = icmp ne i8** %1, null
br i1 %tobool1aptr, label %if.end3aptr, label %if.then2aptr
if.then2aptr: ; preds = %if.endaptr
store i32 0, i32* %retvalaptr
br label %returnaptr
if.end3aptr: ; preds = %if.endaptr
%2 = load i8**, i8*** %dest.addraptr, align 8
%3 = load i8*, i8** %2, align 8
%tobool4aptr = icmp ne i8* %3, null
br i1 %tobool4aptr, label %if.end6aptr, label %if.then5aptr
if.then5aptr: ; preds = %if.end3aptr
store i32 0, i32* %retvalaptr
br label %returnaptr
if.end6aptr: ; preds = %if.end3aptr
%4 = load i8*, i8** %orig.addraptr, align 8
%5 = load i8**, i8*** %dest.addraptr, align 8
store i8* %4, i8** %5, align 8
store i32 1, i32* %retvalaptr
br label %returnaptr
returnaptr: ; preds = %if.end6aptr,
%if.then5aptr, %if.then2aptr, %if.thenaptr
%6 = load i32, i32* %retvalaptr
ret i32 %6
}
; Function Attrs: nounwind readnone
declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) #3
attributes #0 = { argmemonly nounwind }
attributes #1 = { nounwind uwtable }
attributes #2 = { nounwind }
attributes #3 = { nounwind readnone }
Could you share the C code rather than the IR. It should be easier to reproduce in IR, the question is, how did you get the 0 alignment in the first place in the original code.
The first step is load the bc file :
Module* ExecuteBin::InitParser(rtString &bcfile)
{
ADVPL_RT_Jit *jit = getJIT();
auto File = MemoryBuffer::getFile(bcfile);
if (std::error_code ec = File.getError()) {
errs() << ec.message();
return NULL;
}
if (File.getError().value())
{
return NULL;
}
auto bref = File->get()->getMemBufferRef();
auto llvm_module_parsed = parseBitcodeFile(bref, getContext());
if (std::error_code ec = llvm_module_parsed.getError())
return NULL;
auto m_ptr = std::move(llvm_module_parsed.get());
Module* M = m_ptr.get();
m_ptr.release();
M->setDataLayout(jit->getTargetMachine().createDataLayout());
std::string striple = sys::getProcessTriple();
M->setTargetTriple(striple);
return M;
}
bool ExecuteBin::getBin(rtString &bcfile)
{
if (!(llvm_module = ExecuteBin::InitParser(bcfile)))
return false;
modules.push_back(llvm_module);
getRegFunc()(this);
getJIT()->addModule(llvm_module);
return true;
}
After that, I should get a function ptr to execute:
void* ExecuteBin::getFuncPointer( llvm::Function *func)
{
try
{
if (func)
{
return (void*)getJIT()->getFuncPointer(func);
}
}
catch (...)
{
return NULL;
}
return NULL;
};
The JIT is called ....
void* getFuncPointer(llvm::Function *func)
{
if (!func)
{
return NULL;
}
std::string Name(func->getName());
if (auto ExprSymbol = findSymbol(Name))
{
return (void*)ExprSymbol.getAddress();
}
return getFuncPointer(Name);
};
TargetAddress getAddress() {
if (GetAddress) {
CachedAddr = GetAddress();
assert(CachedAddr && "Symbol could not be materialized.");
GetAddress = nullptr;
}
return CachedAddr;
}
JITSymbol findSymbol(const std::string &Name, bool bExported = false)
{
if (auto symb = LazyEmitLayer.findSymbol(Name, bExported))
return symb;
return nullptr;
}
Here in Lazy.EmittingLayer.h :
JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) {
// Look for the symbol among existing definitions.
if (auto Symbol = BaseLayer.findSymbol(Name, ExportedSymbolsOnly))
return Symbol;
// If not found then search the deferred sets. If any of these contain a
// definition of 'Name' then they will return a JITSymbol that will emit
// the corresponding module when the symbol address is requested.
for (auto &DeferredSet : ModuleSetList)
if (auto Symbol = DeferredSet->find(Name, ExportedSymbolsOnly, BaseLayer))
return Symbol;
// If no definition found anywhere return a null symbol.
return nullptr;
}
There several call :
RuntimeDyld::loadObject(const ObjectFile &Obj) RuntimeDyldCOFF::loadObject(const object::ObjectFile &O)
RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj)
void RuntimeDyldImpl::emitCommonSymbols
Until here, when the emitCommonSymbols finds the structure declaration
%errorStatus_TOTVS_ASM = type { i32, i32, i8*, i32 (i8*)*, i32 }
and always has returned 0 for alignment.
The new version calls a function the divide by zero in this moment.
If this does not help, I'll have to send all my project.
I'm using VS 2013 on MS Windows 7.
I meant the code being JIT'ed, not the JIT executor itself. The JIT will work on the code that gets pushed into it, not the executor's code.
The code been jitted is a high level proprietary language.
typedef Function Mostra( smsg as string ) as integer
typedef struct tString ( vData as string, vSize as integer, vRefCount as
integer)
typedef struct genData ( vDbl as double ,vInt as integer, vBool as bool, vStr
as string) union
typedef struct xotherStru ( vara as double, varb as double , varc as integer,
vars as genData )
typedef struct errorStatus ( ErrorID as integer, sourceLine as integer,
sourceName as string , fnToCall as Mostra, aux as integer)
typedef struct VariantData ( tp as integer , value as genData )
extern Function getchar( ) as integer
extern Function printFN(n as integer, d as double, cptr as string) as integer
fromlib dllteste
extern Function printf(dest as string , outro as vararg ) as integer
extern Function memcpy(dest as string , origem as string, size as integer )
as void
extern Function fntrstu( s as errorStatus ) as void
extern Function strlen( s as string ) as integer
extern Function atol( s as string ) as integer
extern Function atof( s as string ) as double
extern Function execcmd( cmd as string , retorno as string, retsize as
integer) as void
Function Len( texto as string ) as integer
local ln as integer
ln := strlen( texto )
return ln
Function msg( texto as string ) as integer
printf("\nMSG : %s < ENTER >",texto)
getchar();
return 0
Function conout( texto as string ) as integer
printf("\nCONOUT : %s",texto)
return 0
Function TstSoma() as integer
Local a as integer
a := 10 + 15
if a == 25
a := 0
else
a := 30
endif
return a
Function SetError( ErrorID as integer, sourceLine as integer, sourceName as
string, calledFunction as string ) as integer
Public errorStru as errorStatus
errorStru.ErrorID := ErrorID
errorStru.sourceLine := sourceLine
errorStru.sourceName := sourceName
printf("\nSetError Origem = %d destino = %d Origem= %d destino = %d tem que
ser igual ",ErrorID,errorStru.ErrorID,sourceLine,errorStru.sourceLine)
return 0
Function GetErrorID() as integer
return errorStru.ErrorID
Function GetErrorLine() as integer
return errorStru.sourceLine
Function GetErrorFunctionName() as string
return "resolver estah errado"
Function GetErrorSource() as string
return errorStru.sourceName
Function OperVariant( left as VariantData, right as VariantData, result as
VariantData, operador as integer ) as bool
Local sl as string
Local sr as string
Local sx as string
Local il as integer
if left.tp <> right.tp
return .F.
endif
result.tp := left.tp
if left.tp == 1
result.value.vInt := left.value.vInt + right.value.vInt
return .T.
endif
if left.tp == 2
result.value.vDbl := left.value.vDbl + right.value.vDbl
return .T.
endif
if left.tp == 3
sl := "abcdefg"
printf("\nstrS=%s",result.value.vStr)
printf("\nstrS=%s",result.value.vStr)
return .T.
endif
return .F.
From this source the application generates the .ll and the .bc files.
I will send you the .bc file
Hmm, could be an issue in that compiler then. The question is, how did you get an alignment of 0? It should have been an alignment of 1. We could add an assertion to make that more obvious though.
The symbol alignment comes from uint32_t ObjectFile::getSymbolAlignment(DataRefImpl DRI) const { return 0; } and it ALWAYS returns 0.