Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit adba5d1

Browse files
committed
handle function pointers in SimplifyStructRegSignatures
1 parent 07e9d11 commit adba5d1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/Target/JSBackend/NaCl/SimplifyStructRegSignatures.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,16 @@ TCall *SimplifyStructRegSignatures::fixCallTargetAndArguments(
388388
}
389389
}
390390

391+
if (isa<Instruction>(NewTarget)) {
392+
Type* NewPointerType = PointerType::get(NewType, 0);
393+
if (NewPointerType != OldCall->getType()) {
394+
// This is a function pointer, and it has the wrong type after our
395+
// changes. Bitcast it.
396+
NewTarget = Builder.CreateBitCast(NewTarget, NewPointerType, ".casttarget");
397+
}
398+
}
399+
400+
391401
ArrayRef<Value *> ArrRef = NewArgs;
392402
TCall *NewCall = CreateCallFrom(OldCall, NewTarget, ArrRef, Builder);
393403

@@ -527,7 +537,7 @@ bool SimplifyStructRegSignatures::runOnModule(Module &M) {
527537
fixCallSite(Ctx, InvokeToFix, PreferredAlignment);
528538
}
529539

530-
// Update taking of a function's address
540+
// Update taking of a function's address from a parameter
531541
for (auto &Addressing : FunctionAddressings) {
532542
Value *Temp = Addressing.Temp;
533543
Function *Old = Addressing.Old;

0 commit comments

Comments
 (0)