[PATCH] D45736: [SimplifyLibcalls] Replace locked IO with unlocked IO
Dávid Bolvanský via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 17 16:21:45 PDT 2018
xbolva00 added a comment.
In https://reviews.llvm.org/D45736#1070347, @efriedma wrote:
> > So maybe somehow check if module has only static functions (+main)?
>
> You might be able to get this to work, but there are a lot of weird edge cases, and it wouldn't be very useful in practice; most programs have more than one source code file.
>
> The practical approach would be to use something like llvm::PointerMayBeCaptured to prove no other thread knows the value of the FILE*.
Code:
static void test(void) {
FILE *f = fopen("file", "w");
char s[10];
fwrite(s, 10, 10, f);
}
int main(void) {
capt_test();
}
static bool isInSingleThread(CallInst *CI, IRBuilder<> &B) {
for (unsigned i = 0; i < CI->getNumOperands(); ++i) {
Value *Op = CI->getOperand(i);
if (Op->getType()->isPointerTy() && !isa<GlobalValue>(Op)) {
errs() << "pty is " << i << " and "
<< PointerMayBeCaptured(Op, false, false) << "\n";
if (PointerMayBeCaptured(Op, false, false))
return false;
}
}
return true;
}
I got that that pointers may be captured. Did I use it wrongly?
Repository:
rL LLVM
https://reviews.llvm.org/D45736
More information about the llvm-commits
mailing list