mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-28 07:05:03 +00:00
Fix yet another memory leak found by the vg-leak bot. Folks (including
me) should start watching this bot more as its catching lots of bugs. The fix here is to not construct the global if we aren't going to need it. That's cheaper anyways, and globals have highly predictable types in practice. I've added an assert to catch skew between our manual testing of the type and the actual type just for paranoia's sake. Note that this pattern is actually fine in most globals because when you build a global with a module it automatically is moved to be owned by that module. But here, we're in isel and don't really want to do that. The solution of not creating a global is simpler anyways. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187302 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
05497cc965
commit
6c54b3dfb4
@ -2185,10 +2185,14 @@ unsigned ARMFastISel::ARMSelectCallOp(bool UseReg) {
|
||||
}
|
||||
|
||||
unsigned ARMFastISel::getLibcallReg(const Twine &Name) {
|
||||
// Manually compute the global's type to avoid building it when unnecessary.
|
||||
Type *GVTy = Type::getInt32PtrTy(*Context, /*AS=*/0);
|
||||
EVT LCREVT = TLI.getValueType(GVTy);
|
||||
if (!LCREVT.isSimple()) return 0;
|
||||
|
||||
GlobalValue *GV = new GlobalVariable(Type::getInt32Ty(*Context), false,
|
||||
GlobalValue::ExternalLinkage, 0, Name);
|
||||
EVT LCREVT = TLI.getValueType(GV->getType());
|
||||
if (!LCREVT.isSimple()) return 0;
|
||||
assert(GV->getType() == GVTy && "We miscomputed the type for the global!");
|
||||
return ARMMaterializeGV(GV, LCREVT.getSimpleVT());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user