This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] ignore non-SymbolRef MCExpr.
Needs ReviewPublic

Authored by patcheng on Jan 26 2018, 12:02 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

instead of static casting a MCExpr to MCSymbolRefExpr directly, use dyn_cast and added null check.

Also removed an unnecessary (?) assertion

Diff Detail

Event Timeline

patcheng created this revision.Jan 26 2018, 12:02 AM

Is this fixing a bug? It would help me to see what kind of code triggers this bug.

sbc100 added inline comments.Jan 28 2018, 11:18 AM
lib/MC/WasmObjectWriter.cpp
446

Why is this unnecessary? Were you hitting this case? Perhaps we need a test that triggers this? Also, if this is unrelated to the MCSymbolRefExpr change than perhaps make it a separate change?

patcheng updated this revision to Diff 131731.Jan 28 2018, 4:47 PM

Changes suggested by sbc100

I messed up the diff. I will upload a correct one soon. hopefully with detail on the case that were hitting the code in the original diff.

patcheng updated this revision to Diff 133991.Feb 12 2018, 10:10 PM

I rolled back the changes to ignore non-MCSymbolExpr.

Here is a dump of the MCExpr that I was encountering around line 1260 (in the for loop that's handling weak aliases.

$Ss10_ArrayBodyVN : isExternal: true isInSection: true isRegistered: true isUsed: true isVariable: true
	dumpMCExpr: 	Binary: opCode: Add
	LHS
		dumpMCExpr: 		Symbol: $Ss10_ArrayBodyVMf
	RHS
		dumpMCExpr: 		Constant: 4