I'm trying to mock out a project so that I can test an opt pass that traverses the CG but I'm being blocked right in main by an odd compilation choice by clang that is further exacerbated by llvm-link. I'll give you some code:
main.c:
#include "xos/xos.h"
int main() {
playXOs();
return 0;
}
xos.h:
#ifndef SLICEREXAMPLEPROJECT_XOS_H
#define SLICEREXAMPLEPROJECT_XOS_H
void playXOs();
#endif // SLICEREXAMPLEPROJECT_XOS_H
I compile individually:
; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32 @main() #0 {
%1 = alloca i32, align 4
store i32 0, i32* %1, align 4
call void(...) @playXOs()
ret i32 0
}
declare dso_local void @playXOs(...) #1
Then link with other files:
define dso_local i32 @main() #0 {
%1 = alloca i32, align 4
store i32 0, i32* %1, align 4
call void (...) bitcast (void ()* @playXOs to void (...)*)()
ret i32 0
}
In the initial compilation, if I'm understanding correctly, thinks that playXOs
is a var arg function? If I manually edit main.ll to change the call site and forward declaration to not be playXOs(...)
then the linked file doesn't have the weird bitcast in it. Does anyone have a solution?
llvm info:
clang version 8.0.0 (git@github.com:llvm-mirror/clang.git 8ca7a0dcb7e9a0cd7bf71ff4b70e12462c16f205) (git@github.com:llvm-mirror/llvm.git e9eedd7fa6f4f861afbc7a2862f3f5504e6d340f)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Edit: I forgot to mention, this is a problem for me because, though the CG I get contains the call site for playXOs
, the CallGraphNode has a null function.